regex.c (mutually_exclusive_p): Fix initial value of loop_beg
* src/regex-emacs.c (mutually_exclusive_p): Don't pretend that pattern position 0 has been checked already. * test/src/regex-emacs-tests.el (regexp-tests-backtrack-optimization): Add a corresponding regression test plus some other related tests I had around.
This commit is contained in:
parent
215bfb24dd
commit
e88be844bf
2 changed files with 20 additions and 2 deletions
|
@ -3941,7 +3941,7 @@ static bool
|
|||
mutually_exclusive_p (struct re_pattern_buffer *bufp, re_char *p1,
|
||||
re_char *p2)
|
||||
{
|
||||
return mutually_exclusive_aux (bufp, p1, p2, bufp->buffer, NULL);
|
||||
return mutually_exclusive_aux (bufp, p1, p2, bufp->buffer - 1, NULL);
|
||||
}
|
||||
|
||||
/* Matching routines. */
|
||||
|
|
|
@ -878,10 +878,28 @@ This evaluates the TESTS test cases from glibc."
|
|||
(erase-buffer)
|
||||
(insert (make-string 1000000 ?x) "=")
|
||||
(goto-char (point-min))
|
||||
;; Make sure we do perform the optimization (if we don't, the
|
||||
;; below will burp with regexp-stack-overflow).
|
||||
(should (looking-at "x*=*"))
|
||||
(should (looking-at "x*\\(=\\|:\\)"))
|
||||
(should (looking-at "x*\\(=\\|:\\)*"))
|
||||
(should (looking-at "x*=*?"))))
|
||||
(should (looking-at "x*=*?"))
|
||||
(should (looking-at "x*\\(=*\\|h\\)*?"))
|
||||
(should (looking-at "x*\\(=*\\|h\\)*"))
|
||||
(should (looking-at "x*\\(=*?\\|h\\)*"))
|
||||
(should (looking-at "x*\\(=*?\\|h\\)*?"))
|
||||
(should (looking-at "x*\\(=*\\|h\\)+?"))
|
||||
(should (looking-at "x*\\(=*\\|h\\)+"))
|
||||
(should (looking-at "x*\\(=*?\\|h\\)+"))
|
||||
(should (looking-at "x*\\(=*?\\|h\\)+?"))
|
||||
(should (looking-at "x*\\(=+\\|h\\)+?"))
|
||||
(should (looking-at "x*\\(=+\\|h\\)+"))
|
||||
(should (looking-at "x*\\(=+?\\|h\\)+"))
|
||||
(should (looking-at "x*\\(=+?\\|h\\)+?"))
|
||||
;; Regression check for overly optimistic optimization.
|
||||
(should (eq 0 (string-match "\\(ca*\\|ab\\)+d" "cabd")))
|
||||
(should (string-match "\\(aa*\\|b\\)*c" "ababc"))
|
||||
))
|
||||
|
||||
(ert-deftest regexp-tests-zero-width-assertion-repetition ()
|
||||
;; Check compatibility behaviour with repetition operators after
|
||||
|
|
Loading…
Add table
Reference in a new issue