diff options
| author | Alan Mackenzie | 2017-10-25 18:14:00 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2017-10-25 18:14:00 +0000 |
| commit | 46540a1c7adb1b89b6c2f6c9150fe8680c3a5fba (patch) | |
| tree | 72a61f000cc2c6b4bbaba29502c3eae8c500af41 | |
| parent | 57ca409111997176a8428a06cc65f037d4217f3a (diff) | |
| download | emacs-46540a1c7adb1b89b6c2f6c9150fe8680c3a5fba.tar.gz emacs-46540a1c7adb1b89b6c2f6c9150fe8680c3a5fba.zip | |
Fix a "wrong side of point" error in CC Mode. Fixes bug #28850.
The cause was a scanning over a bracket pair taking us beyond the supplied
LIMIT parameter in c-forward-declarator.
* lisp/progmodes/cc-engine.el (c-forward-declarator): Add three checks (<
(point) limit) whilst dealing with tokens after the declared identifier.
* lisp/progmodes/cc-fonts.el (c-font-lock-declarators): Don't supply a LIMIT
argument to `c-forward-declarator' (twice), since we want to fontify up till
the end of a declarator, not an arbitrary jit-lock chunk end.
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 6 | ||||
| -rw-r--r-- | lisp/progmodes/cc-fonts.el | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index c506294c5a0..457f95f2ca3 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -8112,12 +8112,14 @@ comment at the start of cc-engine.el for more info." | |||
| 8112 | ;; initializing brace lists. | 8112 | ;; initializing brace lists. |
| 8113 | (let (found) | 8113 | (let (found) |
| 8114 | (while | 8114 | (while |
| 8115 | (and (progn | 8115 | (and (< (point) limit) |
| 8116 | (progn | ||
| 8116 | ;; In the next loop, we keep searching forward whilst | 8117 | ;; In the next loop, we keep searching forward whilst |
| 8117 | ;; we find ":"s which aren't single colons inside C++ | 8118 | ;; we find ":"s which aren't single colons inside C++ |
| 8118 | ;; "for" statements. | 8119 | ;; "for" statements. |
| 8119 | (while | 8120 | (while |
| 8120 | (and | 8121 | (and |
| 8122 | (< (point) limit) | ||
| 8121 | (setq found | 8123 | (setq found |
| 8122 | (c-syntactic-re-search-forward | 8124 | (c-syntactic-re-search-forward |
| 8123 | "[;:,]\\|\\s)\\|\\(=\\|\\s(\\)" | 8125 | "[;:,]\\|\\s)\\|\\(=\\|\\s(\\)" |
| @@ -8139,7 +8141,7 @@ comment at the start of cc-engine.el for more info." | |||
| 8139 | (c-go-up-list-forward)) | 8141 | (c-go-up-list-forward)) |
| 8140 | (setq brackets-after-id t)) | 8142 | (setq brackets-after-id t)) |
| 8141 | (when found (backward-char)) | 8143 | (when found (backward-char)) |
| 8142 | t)) | 8144 | (<= (point) limit))) |
| 8143 | (list id-start id-end brackets-after-id (match-beginning 1) decorated) | 8145 | (list id-start id-end brackets-after-id (match-beginning 1) decorated) |
| 8144 | 8146 | ||
| 8145 | (goto-char here) | 8147 | (goto-char here) |
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index acdb1ad1334..a2ac2a32535 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el | |||
| @@ -1062,7 +1062,7 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 1062 | ;; The following `while' fontifies a single declarator id each time round. | 1062 | ;; The following `while' fontifies a single declarator id each time round. |
| 1063 | ;; It loops only when LIST is non-nil. | 1063 | ;; It loops only when LIST is non-nil. |
| 1064 | (while | 1064 | (while |
| 1065 | (and pos (setq decl-res (c-forward-declarator limit))) | 1065 | (and pos (setq decl-res (c-forward-declarator))) |
| 1066 | (setq next-pos (point) | 1066 | (setq next-pos (point) |
| 1067 | id-start (car decl-res) | 1067 | id-start (car decl-res) |
| 1068 | id-face (if (and (eq (char-after) ?\() | 1068 | id-face (if (and (eq (char-after) ?\() |
| @@ -1091,7 +1091,7 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 1091 | (throw 'is-function nil)) | 1091 | (throw 'is-function nil)) |
| 1092 | ((not (eq got-type 'maybe)) | 1092 | ((not (eq got-type 'maybe)) |
| 1093 | (throw 'is-function t))) | 1093 | (throw 'is-function t))) |
| 1094 | (c-forward-declarator limit t) | 1094 | (c-forward-declarator nil t) |
| 1095 | (eq (char-after) ?,)) | 1095 | (eq (char-after) ?,)) |
| 1096 | (forward-char) | 1096 | (forward-char) |
| 1097 | (c-forward-syntactic-ws)) | 1097 | (c-forward-syntactic-ws)) |