diff options
| author | Alan Mackenzie | 2022-07-02 16:12:59 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2022-07-02 16:12:59 +0000 |
| commit | dc3d01a5aff4017ac071bf7f72ab4df493d2b2f6 (patch) | |
| tree | 734bde0249208a6a3c8859e8608c6c6ad8fe9c77 | |
| parent | e390396e684c99b4b0b27aa2e0bc1822d8854550 (diff) | |
| download | emacs-dc3d01a5aff4017ac071bf7f72ab4df493d2b2f6.tar.gz emacs-dc3d01a5aff4017ac071bf7f72ab4df493d2b2f6.zip | |
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.
| -rw-r--r-- | lisp/progmodes/cc-fonts.el | 23 |
1 files changed, 13 insertions, 10 deletions
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." | |||
| 1826 | ;; font-lock-keyword-face. It always returns NIL to inhibit this and | 1826 | ;; font-lock-keyword-face. It always returns NIL to inhibit this and |
| 1827 | ;; prevent a repeat invocation. See elisp/lispref page "Search-based | 1827 | ;; prevent a repeat invocation. See elisp/lispref page "Search-based |
| 1828 | ;; Fontification". | 1828 | ;; Fontification". |
| 1829 | (let (mode capture-default id-start id-end declaration sub-begin sub-end) | 1829 | (let (mode capture-default id-start id-end declaration sub-begin sub-end tem) |
| 1830 | (while (and (< (point) limit) | 1830 | (while (and (< (point) limit) |
| 1831 | (search-forward "[" limit t)) | 1831 | (search-forward "[" limit t)) |
| 1832 | (when (progn (backward-char) | 1832 | (when (progn (backward-char) |
| @@ -1838,15 +1838,18 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 1838 | (char-after))) | 1838 | (char-after))) |
| 1839 | ;; Is the first element of the list a bare "=" or "&"? | 1839 | ;; Is the first element of the list a bare "=" or "&"? |
| 1840 | (when mode | 1840 | (when mode |
| 1841 | (forward-char) | 1841 | (setq tem nil) |
| 1842 | (c-forward-syntactic-ws) | 1842 | (save-excursion |
| 1843 | (if (memq (char-after) '(?, ?\])) | 1843 | (forward-char) |
| 1844 | (progn | 1844 | (c-forward-syntactic-ws) |
| 1845 | (setq capture-default mode) | 1845 | (if (memq (char-after) '(?, ?\])) |
| 1846 | (when (eq (char-after) ?,) | 1846 | (progn |
| 1847 | (forward-char) | 1847 | (setq capture-default mode) |
| 1848 | (c-forward-syntactic-ws))) | 1848 | (when (eq (char-after) ?,) |
| 1849 | (c-backward-token-2))) | 1849 | (forward-char) |
| 1850 | (c-forward-syntactic-ws)) | ||
| 1851 | (setq tem (point))))) | ||
| 1852 | (if tem (goto-char tem))) | ||
| 1850 | 1853 | ||
| 1851 | ;; Go round the following loop once per captured item. We use "\\s)" | 1854 | ;; Go round the following loop once per captured item. We use "\\s)" |
| 1852 | ;; rather than "\\]" here to avoid infinite looping in this situation: | 1855 | ;; rather than "\\]" here to avoid infinite looping in this situation: |