1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-02-08 20:58:58 +00:00

CC Mode: Fix a c-backward-token-2 call wrongly jumping back over macros.

This fixes bug #56256.

* lisp/progmodes/cc-fonts.el (c-font-lock-c++-lambda-captures): Replace a
c-backward-token-2, which could jump back too far leading to an infinite
loop, with a save-excursion to remember the point we've got to go back to.
This commit is contained in:
Alan Mackenzie 2022-07-02 16:12:59 +00:00
parent e390396e68
commit dc3d01a5af

View File

@ -1826,7 +1826,7 @@ casts and declarations are fontified. Used on level 2 and higher."
;; font-lock-keyword-face. It always returns NIL to inhibit this and
;; prevent a repeat invocation. See elisp/lispref page "Search-based
;; Fontification".
(let (mode capture-default id-start id-end declaration sub-begin sub-end)
(let (mode capture-default id-start id-end declaration sub-begin sub-end tem)
(while (and (< (point) limit)
(search-forward "[" limit t))
(when (progn (backward-char)
@ -1838,15 +1838,18 @@ casts and declarations are fontified. Used on level 2 and higher."
(char-after)))
;; Is the first element of the list a bare "=" or "&"?
(when mode
(forward-char)
(c-forward-syntactic-ws)
(if (memq (char-after) '(?, ?\]))
(progn
(setq capture-default mode)
(when (eq (char-after) ?,)
(forward-char)
(c-forward-syntactic-ws)))
(c-backward-token-2)))
(setq tem nil)
(save-excursion
(forward-char)
(c-forward-syntactic-ws)
(if (memq (char-after) '(?, ?\]))
(progn
(setq capture-default mode)
(when (eq (char-after) ?,)
(forward-char)
(c-forward-syntactic-ws))
(setq tem (point)))))
(if tem (goto-char tem)))
;; Go round the following loop once per captured item. We use "\\s)"
;; rather than "\\]" here to avoid infinite looping in this situation: