1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-18 11:50:38 -08: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 ;; font-lock-keyword-face. It always returns NIL to inhibit this and
;; prevent a repeat invocation. See elisp/lispref page "Search-based ;; prevent a repeat invocation. See elisp/lispref page "Search-based
;; Fontification". ;; 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) (while (and (< (point) limit)
(search-forward "[" limit t)) (search-forward "[" limit t))
(when (progn (backward-char) (when (progn (backward-char)
@ -1838,15 +1838,18 @@ casts and declarations are fontified. Used on level 2 and higher."
(char-after))) (char-after)))
;; Is the first element of the list a bare "=" or "&"? ;; Is the first element of the list a bare "=" or "&"?
(when mode (when mode
(forward-char) (setq tem nil)
(c-forward-syntactic-ws) (save-excursion
(if (memq (char-after) '(?, ?\])) (forward-char)
(progn (c-forward-syntactic-ws)
(setq capture-default mode) (if (memq (char-after) '(?, ?\]))
(when (eq (char-after) ?,) (progn
(forward-char) (setq capture-default mode)
(c-forward-syntactic-ws))) (when (eq (char-after) ?,)
(c-backward-token-2))) (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)" ;; Go round the following loop once per captured item. We use "\\s)"
;; rather than "\\]" here to avoid infinite looping in this situation: ;; rather than "\\]" here to avoid infinite looping in this situation: