[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master bc52fdd1d15: * src/regex-emacs.c (analyze_first): Fix incorrect o
From: |
Stefan Monnier |
Subject: |
master bc52fdd1d15: * src/regex-emacs.c (analyze_first): Fix incorrect optimization |
Date: |
Wed, 27 Sep 2023 13:31:32 -0400 (EDT) |
branch: master
commit bc52fdd1d153b36a9da74d7aa7f1e6150ff6b2eb
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* 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.
---
src/regex-emacs.c | 6 ++++--
test/src/regex-resources/PTESTS | 1 +
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/regex-emacs.c b/src/regex-emacs.c
index 338323cf79e..ae82dd63917 100644
--- a/src/regex-emacs.c
+++ b/src/regex-emacs.c
@@ -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;
diff --git a/test/src/regex-resources/PTESTS b/test/src/regex-resources/PTESTS
index 68acc314d37..59dd4b3bc21 100644
--- a/test/src/regex-resources/PTESTS
+++ b/test/src/regex-resources/PTESTS
@@ -269,6 +269,7 @@
#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¦
# GA142
1¦3¦a\{2,3\}¦aaaa¦
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master bc52fdd1d15: * src/regex-emacs.c (analyze_first): Fix incorrect optimization,
Stefan Monnier <=