]> git.eshelyaron.com Git - emacs.git/commit
Fix regexp matching with atomic strings and optimised backtracking
authorMattias Engdegård <mattiase@acm.org>
Sun, 23 Oct 2022 13:40:37 +0000 (15:40 +0200)
committerMattias Engdegård <mattiase@acm.org>
Mon, 24 Oct 2022 09:50:13 +0000 (11:50 +0200)
commit36f5a1a7e74442272796413575f85ba9bd18cb53
tree8a01195f9d287dfa53f48792afd5e0ad5da81d34
parentb5ada7aa6fcb14019df207259609d602150b03a4
Fix regexp matching with atomic strings and optimised backtracking

This bug occurs when an atomic pattern is matched at the end of
a string and the on-failure-keep-string-jump optimisation is
in effect, as in:

  (string-match "\\'\\(?:ab\\)*\\'" "a")

which succeeded but clearly should not (bug#58726).

Reported by Michael Heerdegen.

* src/regex-emacs.c (PREFETCH): Add reset parameter.
(re_match_2_internal): Use it for proper atomic pattern treatment.
* test/src/regex-emacs-tests.el (regexp-atomic-failure): New test.
src/regex-emacs.c
test/src/regex-emacs-tests.el