From: Alan Mackenzie Date: Sat, 2 Jul 2022 16:12:59 +0000 (+0000) Subject: CC Mode: Fix a c-backward-token-2 call wrongly jumping back over macros. X-Git-Tag: emacs-28.1.91~72 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dc3d01a5af;p=emacs.git 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. --- diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index 63df267b43f..49e8763a28e 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el @@ -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: