aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorStefan Monnier2023-02-20 21:22:41 -0500
committerStefan Monnier2023-02-20 21:22:41 -0500
commit5a864f23eb8a36ef435136c5b41cb01b875df399 (patch)
treecc7b6d2ebd44f079f0f1a2ce99783a72bcba0eaf /test/src
parente83c78b8c7784254c2c6f043530ab325c2fa7f16 (diff)
downloademacs-5a864f23eb8a36ef435136c5b41cb01b875df399.tar.gz
emacs-5a864f23eb8a36ef435136c5b41cb01b875df399.zip
regex-emacs.c: Reduce the use of backtracking a bit further
bug#61514 exhibited some undesirable backtracking in a case where it's easy to avoid it by making `mutually_exclusive_p` just a bit more careful. * src/regex-emacs.c (mutually_exclusive_p): Handle `on_failure_jump`s. * test/src/regex-emacs-tests.el (regexp-tests-backtrack-optimization): Add a few tests.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/regex-emacs-tests.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/src/regex-emacs-tests.el b/test/src/regex-emacs-tests.el
index cd4924f9785..c8f161c9b24 100644
--- a/test/src/regex-emacs-tests.el
+++ b/test/src/regex-emacs-tests.el
@@ -872,4 +872,15 @@ This evaluates the TESTS test cases from glibc."
872 (should (equal (string-match "\\`\\(?:ab\\)*\\'" "a") nil)) 872 (should (equal (string-match "\\`\\(?:ab\\)*\\'" "a") nil))
873 (should (equal (string-match "\\`a\\{2\\}*\\'" "a") nil))) 873 (should (equal (string-match "\\`a\\{2\\}*\\'" "a") nil)))
874 874
875(ert-deftest regexp-tests-backtrack-optimization () ;bug#61514
876 ;; Make sure we don't use up the regexp stack needlessly.
877 (with-current-buffer (get-buffer-create "*bug*")
878 (erase-buffer)
879 (insert (make-string 1000000 ?x) "=")
880 (goto-char (point-min))
881 (should (looking-at "x*=*"))
882 (should (looking-at "x*\\(=\\|:\\)"))
883 (should (looking-at "x*\\(=\\|:\\)*"))
884 (should (looking-at "x*=*?"))))
885
875;;; regex-emacs-tests.el ends here 886;;; regex-emacs-tests.el ends here