[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master ba1508ed17: CC Mode: Fix infinite loop in noise macro near end of
From: |
Alan Mackenzie |
Subject: |
master ba1508ed17: CC Mode: Fix infinite loop in noise macro near end of buffer |
Date: |
Sat, 18 Jun 2022 07:25:27 -0400 (EDT) |
branch: master
commit ba1508ed17f57642421f510fd9e1ac35e17bf208
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>
CC Mode: Fix infinite loop in noise macro near end of buffer
This fixes bug #55771. Also fix an inaccuracy in c-defun-name-1 with the
same
cause.
* lisp/progmodes/cc-cmds.el (c-defun-name-1)
* lisp/progmodes/cc-engine.el (c-forward-noise-clause): Check the return
value of c-forward-token-2 and act upon it when not zero.
---
lisp/progmodes/cc-cmds.el | 11 +++++------
lisp/progmodes/cc-engine.el | 9 +++++----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index e9cc63709e..82268f4943 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -2115,13 +2115,12 @@ with a brace block."
(c-forward-syntactic-ws)
(when (eq (char-after) ?\")
(forward-sexp 1)
+ (c-forward-syntactic-ws)
(c-forward-token-2)) ; over the comma and following WS.
- (buffer-substring-no-properties
- (point)
- (progn
- (c-forward-token-2)
- (c-backward-syntactic-ws)
- (point))))
+ (setq pos (point))
+ (and (zerop (c-forward-token-2))
+ (progn (c-backward-syntactic-ws) t)
+ (buffer-substring-no-properties pos (point))))
((and (c-major-mode-is 'objc-mode) (looking-at "[-+]\\s-*(")) ;
Objective-C method
;; Move to the beginning of the method name.
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 8794a527f8..f9c33f5149 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -1239,7 +1239,7 @@ comment at the start of cc-engine.el for more info."
(not comma-delimited)
(not (c-looking-at-inexpr-block lim nil t))
(save-excursion
- (c-backward-token-2 1 t nil)
+ (c-backward-token-2 1 t nil) ; Don't test the value
(not (looking-at "=\\([^=]\\|$\\)")))
(or
(not c-opt-block-decls-with-vars-key)
@@ -8289,9 +8289,10 @@ multi-line strings (but not C++, for example)."
(defun c-forward-noise-clause ()
;; Point is at a c-noise-macro-with-parens-names macro identifier. Go
;; forward over this name, any parenthesis expression which follows it, and
- ;; any syntactic WS, ending up at the next token. If there is an unbalanced
- ;; paren expression, leave point at it. Always Return t.
- (c-forward-token-2)
+ ;; any syntactic WS, ending up at the next token or EOB. If there is an
+ ;; unbalanced paren expression, leave point at it. Always Return t.
+ (or (zerop (c-forward-token-2))
+ (goto-char (point-max)))
(if (and (eq (char-after) ?\()
(c-go-list-forward))
(c-forward-syntactic-ws))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master ba1508ed17: CC Mode: Fix infinite loop in noise macro near end of buffer,
Alan Mackenzie <=