[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 93c67f6: Fix an infinite loop in C++ Mode when we h
From: |
Alan Mackenzie |
Subject: |
[Emacs-diffs] master 93c67f6: Fix an infinite loop in C++ Mode when we have "{ .... [ .... }" |
Date: |
Thu, 25 Aug 2016 16:24:30 +0000 (UTC) |
branch: master
commit 93c67f6b2c98ab69e25d2ca7417bcf6c15a165db
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>
Fix an infinite loop in C++ Mode when we have "{ .... [ .... }"
* lisp/progmodes/cc-fonts.el (c-font-lock-c++-lambda-captures): In the inner
`while' form's condition, check for "\\s)" rather than merely "\\]", so that
the loop won't hang at a "terminating" paren of a different type (due to the
c-syntactic-re-search-forward at the end of the loop stopping at such
characters).
---
lisp/progmodes/cc-fonts.el | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 60b8b6d..bf8b857 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1654,8 +1654,13 @@ casts and declarations are fontified. Used on level 2
and higher."
(c-forward-syntactic-ws)))
(c-backward-token-2)))
- ;; Go round the following loop once per captured item.
- (while (and (not (eq (char-after) ?\]))
+ ;; Go round the following loop once per captured item. We use "\\s)"
+ ;; rather than "\\]" here to avoid infinite looping in this situation:
+ ;; "unsigned items [] { [ }". The second "[" triggers this function,
+ ;; but if we don't match the "}" with an "\\s)", the
+ ;; `c-syntactic-re-search-forward' at the end of the loop fails to
+ ;; move forward over it, leaving point stuck at the "}".
+ (while (and (not (looking-at "\\s)"))
(< (point) limit))
(if (eq (char-after) ?&)
(progn (setq mode ?&)
@@ -1704,7 +1709,8 @@ casts and declarations are fontified. Used on level 2
and higher."
(c-forward-syntactic-ws)))
(setq capture-default nil)
- (forward-char)))) ; over the terminating "]".
+ (if (< (point) limit)
+ (forward-char))))) ; over the terminating "]" or other close paren.
nil)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 93c67f6: Fix an infinite loop in C++ Mode when we have "{ .... [ .... }",
Alan Mackenzie <=