Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1029 error message regex parsing uses indexes matches, not subgroups

None
closed-fixed
nobody
v1.24
5
2014-02-21
2014-02-13
Dimitar Zhekov
No

As discussed in the "Compiler tab suggestions" mailing list thread, Geany regex error message parsing is a bit buggy: it fetches the matching strings by index, but GRegex indexes all subgroups, returning empty string for the non-matching ones. So, for example, using | for alternatives does not work, and parsing a set of strings like:

filename:line:column: warning: passing argument # of 'function' from incompatible pointer type
In file included from filename:line,
from filename:line,
...
from filename:line:
filename:line:column: note: expected 'foo' but argument is of type 'bar'

is either impossible, or requires a very complex expression.
This is a regression caused by our switch to GRegex.

git patch attached. Of course, it's a simple loop skipping the non-matching
groups by their start position. Tested with both filename:line and
line:filename, on the left and right side of |.

1 Attachments

Discussion

  • Lex Trotman
    Lex Trotman
    2014-02-13

    • status: open --> closed-fixed
     
  • Lex Trotman
    Lex Trotman
    2014-02-13

    Pushed, thanks for the reminder.

     
  • Dimitar Zhekov
    Dimitar Zhekov
    2014-02-14

    Sorry to bother you again, but as it turned out, "the number of matched substrings" in GLib documentation should be read as "the number of substrings GRegex tried to match", and not "the number of substrings that matched". :)

    So, g_match_info_get_match_count(minfo) >= 3 is not a valid check, and with specific expressions that I haven't tested previously, the current fix may even segfault.

    Attached is a git patch against the current Geany. Let's hope there won't be any more surprises...

     
  • Matthew Brush
    Matthew Brush
    2014-02-14

    • labels: --> compiler tab build commands regex error warning line number column
    • status: closed-fixed --> open
    • Priority: 4 --> 5
     
  • Lex Trotman
    Lex Trotman
    2014-02-15

    Hmm, I read the glib docs the same as you, and since that test is original code, clearly so do others. The Glib docs should read "Retrieves the number of substrings in the pattern" not "Retrieves the number of matched substrings".

    Fix committed.

     
  • Dimitar Zhekov
    Dimitar Zhekov
    2014-02-20

    Unless there are counter examples, I think this should be re-closed.

     
  • Lex Trotman
    Lex Trotman
    2014-02-21

    done

     
  • Lex Trotman
    Lex Trotman
    2014-02-21

    • status: open --> closed-fixed