mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-26 07:33:47 +00:00
regex.c (mutually_exclusive_aux) <wordbound>: Remove optimization
Another case that was too optimistic. Better use \> or \< rather than \b if you want your regexp to be handled efficiently. * src/regex-emacs.c (mutually_exclusive_aux) <wordbound>: Cancel optimization. * test/src/regex-emacs-tests.el (regexp-tests-backtrack-optimization): New test.
This commit is contained in:
parent
0c15c7d946
commit
7c26501175
@ -3874,9 +3874,22 @@ mutually_exclusive_aux (struct re_pattern_buffer *bufp, re_char *p1,
|
||||
return ((re_opcode_t) *p1 == notsyntaxspec && p1[1] == p2[1]);
|
||||
|
||||
case wordbound:
|
||||
/* FIXME: This optimization seems correct after the first iteration
|
||||
of the loop, but not for the very first :-(
|
||||
IOW we'd need to pull out the first iteration and do:
|
||||
|
||||
syntaxspec w
|
||||
on_failure_keep_string_jump end
|
||||
loop:
|
||||
syntaxspec w
|
||||
goto loop
|
||||
end:
|
||||
wordbound
|
||||
|
||||
return (((re_opcode_t) *p1 == notsyntaxspec
|
||||
|| (re_opcode_t) *p1 == syntaxspec)
|
||||
&& p1[1] == Sword);
|
||||
|| (re_opcode_t) *p1 == syntaxspec)
|
||||
&& p1[1] == Sword); */
|
||||
return false;
|
||||
|
||||
case categoryspec:
|
||||
return ((re_opcode_t) *p1 == notcategoryspec && p1[1] == p2[1]);
|
||||
|
@ -907,6 +907,7 @@ This evaluates the TESTS test cases from glibc."
|
||||
;; Regression check for overly optimistic optimization.
|
||||
(should (eq 0 (string-match "\\(ca*\\|ab\\)+d" "cabd")))
|
||||
(should (string-match "\\(aa*\\|b\\)*c" "ababc"))
|
||||
(should (string-match " \\sw*\\bfoo" " foo"))
|
||||
))
|
||||
|
||||
(ert-deftest regexp-tests-zero-width-assertion-repetition ()
|
||||
|
Loading…
Reference in New Issue
Block a user