Regular expression matching fixes
Patch by Dennis Nezic <dennisn@dennisn.mooo.com>: Currently, in matches.cfg, "Title *bla ..." will match any title with "bla" in it ... but it should only match if the title ends in bla, right?
This commit is contained in:
parent
091e3684dd
commit
44b31fbbd1
19
src/regex.c
19
src/regex.c
|
@ -102,9 +102,26 @@ matchregexp(const char *rx, const char *s)
|
||||||
i = isafter(i, s, rx2);
|
i = isafter(i, s, rx2);
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
// Because the for loop will increment i (the index
|
||||||
|
// into string s) at the end of this block, but i now
|
||||||
|
// already points to the next char in s, this next char
|
||||||
|
// gets ignored.
|
||||||
|
// Without this next decrement, if the regex is *bla,
|
||||||
|
// it will incorrectly say that blax matches, although
|
||||||
|
// correctly say that blaxy doesn't. Ie. char x is skipped
|
||||||
|
if (i > 0)
|
||||||
|
i--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return match;
|
{
|
||||||
|
// We arrived at the end of the regex BUT if it doesn't
|
||||||
|
// end with the wildcard * and there are more chars
|
||||||
|
// in s remaining to be matched, we should return 0
|
||||||
|
if ((i < len) && (rx[l - 1] != '*'))
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return match;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue