summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-cmds.el
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2022-06-18 11:23:06 +0000
committerAlan Mackenzie <acm@muc.de>2022-06-18 11:23:06 +0000
commitba1508ed17f57642421f510fd9e1ac35e17bf208 (patch)
tree9a5068c2b816923a98686cf8566302fd66769500 /lisp/progmodes/cc-cmds.el
parent2cb5ed66c094cc1ea937c72eb7958c2dc674ac7f (diff)
downloademacs-ba1508ed17f57642421f510fd9e1ac35e17bf208.tar.gz
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.
Diffstat (limited to 'lisp/progmodes/cc-cmds.el')
-rw-r--r--lisp/progmodes/cc-cmds.el11
1 files changed, 5 insertions, 6 deletions
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index e9cc63709e6..82268f49433 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.