* src/regex-emacs.c (analyze_first): Fix incorrect optimization
The optimization was incorrect in a particular corner case.
In this fix I just disable it conservatively for more cases because
it's not obvious how to fix it while preserving the "good" cases.
We may find a better fix by using an approach like the one
in `mutually_exhaustive_aux`, but for now this is good enough,
especially since \{..\} repetitions are not used very frequently.
* test/src/regex-resources/PTESTS: New test.
This commit is contained in:
@@ -3086,8 +3086,10 @@ analyze_first (re_char *p, re_char *pend, char *fastmap, bool multibyte)
|
||||
/* We only care about one iteration of the loop, so we don't
|
||||
need to consider the case where this behaves like an
|
||||
on_failure_jump. */
|
||||
continue;
|
||||
|
||||
/* FIXME: Sadly, the above is not true when the loop's body
|
||||
can match the empty string :-( */
|
||||
/* continue; */
|
||||
return -1;
|
||||
|
||||
case set_number_at:
|
||||
p += 4;
|
||||
|
||||
@@ -269,6 +269,7 @@
|
||||
# GA141
|
||||
1¦7¦\([a-c]*\)\{0,\}¦aabcaab¦
|
||||
#W the expected result for \([a-c]*\)\{2,\} is failure which isn't correct
|
||||
1¦3¦\([a-c]*\)\{2,\}¦abcdefg¦
|
||||
1¦3¦\([a-c]*\)\{1,\}¦abcdefg¦
|
||||
0¦0¦\([a-c]*\)\{2,\}¦gabcdefg¦
|
||||
-1¦-1¦a\{64,\}¦aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa¦
|
||||
|
||||
Reference in New Issue
Block a user