emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master f821ac29e0c: * src/regex-emacs.c (forall_firstchar_1): Improve co


From: Stefan Monnier
Subject: master f821ac29e0c: * src/regex-emacs.c (forall_firstchar_1): Improve corner case
Date: Mon, 22 Jan 2024 15:06:34 -0500 (EST)

branch: master
commit f821ac29e0cf69316d6c721bafe9b749b47a6db3
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * src/regex-emacs.c (forall_firstchar_1): Improve corner case
    
    Fixes a "FORALL_FIRSTCHAR: Broken assumption2!!" warning with:
    
        "^\\(# *\\)\\([^ ]+?\\) *: *\\(.*?\\(?:\n\\1[ 
\t]+.*?\\)*\\)[[:space:]]*$"
---
 src/regex-emacs.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/regex-emacs.c b/src/regex-emacs.c
index dfc6c1fd691..0ec0c6eb63f 100644
--- a/src/regex-emacs.c
+++ b/src/regex-emacs.c
@@ -2923,8 +2923,18 @@ forall_firstchar_1 (re_char *p, re_char *pend,
                forward over a subsequent `jump`.  Recognize this pattern
                since that subsequent `jump` is the one that jumps to the
                loop-entry.  */
-           newp2 = ((re_opcode_t) *newp2 == jump)
-                   ? extract_address (newp2 + 1) : newp2;
+           if ((re_opcode_t) *newp2 == jump)
+             {
+               re_char *p3 = extract_address (newp2 + 1);
+               /* Only recognize this pattern if one of the two destinations
+                  is going forward, otherwise we'll fall into the pessimistic
+                  "Both destinations go backward" below.
+                  This is important if the `jump` at newp2 is the end of an
+                  outer loop while the `on_failure_jump` is the end of an
+                  inner loop.  */
+               if (p3 > p_orig || newp1 > p_orig)
+                 newp2 = p3;
+             }
 
          do_twoway_jump:
            /* We have to check that both destinations are safe.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]