aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2016-08-25 16:21:55 +0000
committerAlan Mackenzie2016-08-25 16:21:55 +0000
commit93c67f6b2c98ab69e25d2ca7417bcf6c15a165db (patch)
treee93367ebdc233f2097be01ca3bed05e67a9d9e4b
parent5e84dcefb4b7fcf3b5af985345ed1ee5ef5df135 (diff)
downloademacs-93c67f6b2c98ab69e25d2ca7417bcf6c15a165db.tar.gz
emacs-93c67f6b2c98ab69e25d2ca7417bcf6c15a165db.zip
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).
-rw-r--r--lisp/progmodes/cc-fonts.el12
1 files changed, 9 insertions, 3 deletions
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 60b8b6db3cc..bf8b857ca6e 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."
1654 (c-forward-syntactic-ws))) 1654 (c-forward-syntactic-ws)))
1655 (c-backward-token-2))) 1655 (c-backward-token-2)))
1656 1656
1657 ;; Go round the following loop once per captured item. 1657 ;; Go round the following loop once per captured item. We use "\\s)"
1658 (while (and (not (eq (char-after) ?\])) 1658 ;; rather than "\\]" here to avoid infinite looping in this situation:
1659 ;; "unsigned items [] { [ }". The second "[" triggers this function,
1660 ;; but if we don't match the "}" with an "\\s)", the
1661 ;; `c-syntactic-re-search-forward' at the end of the loop fails to
1662 ;; move forward over it, leaving point stuck at the "}".
1663 (while (and (not (looking-at "\\s)"))
1659 (< (point) limit)) 1664 (< (point) limit))
1660 (if (eq (char-after) ?&) 1665 (if (eq (char-after) ?&)
1661 (progn (setq mode ?&) 1666 (progn (setq mode ?&)
@@ -1704,7 +1709,8 @@ casts and declarations are fontified. Used on level 2 and higher."
1704 (c-forward-syntactic-ws))) 1709 (c-forward-syntactic-ws)))
1705 1710
1706 (setq capture-default nil) 1711 (setq capture-default nil)
1707 (forward-char)))) ; over the terminating "]". 1712 (if (< (point) limit)
1713 (forward-char))))) ; over the terminating "]" or other close paren.
1708 nil) 1714 nil)
1709 1715
1710 1716