emacs-diffs
[Top][All Lists]
Advanced

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

master c19ca5eb7f: CC Mode: Fix infinite loop in c-brace-stack-at.


From: Alan Mackenzie
Subject: master c19ca5eb7f: CC Mode: Fix infinite loop in c-brace-stack-at.
Date: Mon, 7 Nov 2022 07:22:03 -0500 (EST)

branch: master
commit c19ca5eb7f27344ca03fa300a65ec9b33dc7253e
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>

    CC Mode: Fix infinite loop in c-brace-stack-at.
    
    This fixes bug #59038.  The infinite loop occurred with a buffer containing
    Base-64 encoded text rather than appropriate C Mode text.
    
    * lisp/progmodes/cc-engine.el (c-update-brace-stack): Don't execute
    c-beginning-of-current-token unless the previous 
c-syntactic-re-search-forward
    has succeeded at least once.
---
 lisp/progmodes/cc-engine.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index d730fddeb0..8cf882d569 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -6158,9 +6158,10 @@ comment at the start of cc-engine.el for more info."
            (setq s (cdr s))))
         ((c-keyword-member kwd-sym 'c-flat-decl-block-kwds)
          (push 0 s))))
-      ;; The failing `c-syntactic-re-search-forward' may have left us in the
-      ;; middle of a token, which might be a significant token.  Fix this!
-      (c-beginning-of-current-token)
+      (when (> prev-match-pos 1)      ; Has the search matched at least once?
+       ;; The failing `c-syntactic-re-search-forward' may have left us in the
+       ;; middle of a token, which might be a significant token.  Fix this!
+       (c-beginning-of-current-token))
       (cons (point)
            (cons bound-<> s)))))
 



reply via email to

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