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.
This commit is contained in:
parent
57ca409111
commit
46540a1c7a
2 changed files with 6 additions and 4 deletions
|
@ -8112,12 +8112,14 @@ comment at the start of cc-engine.el for more info."
|
||||||
;; initializing brace lists.
|
;; initializing brace lists.
|
||||||
(let (found)
|
(let (found)
|
||||||
(while
|
(while
|
||||||
(and (progn
|
(and (< (point) limit)
|
||||||
|
(progn
|
||||||
;; In the next loop, we keep searching forward whilst
|
;; In the next loop, we keep searching forward whilst
|
||||||
;; we find ":"s which aren't single colons inside C++
|
;; we find ":"s which aren't single colons inside C++
|
||||||
;; "for" statements.
|
;; "for" statements.
|
||||||
(while
|
(while
|
||||||
(and
|
(and
|
||||||
|
(< (point) limit)
|
||||||
(setq found
|
(setq found
|
||||||
(c-syntactic-re-search-forward
|
(c-syntactic-re-search-forward
|
||||||
"[;:,]\\|\\s)\\|\\(=\\|\\s(\\)"
|
"[;:,]\\|\\s)\\|\\(=\\|\\s(\\)"
|
||||||
|
@ -8139,7 +8141,7 @@ comment at the start of cc-engine.el for more info."
|
||||||
(c-go-up-list-forward))
|
(c-go-up-list-forward))
|
||||||
(setq brackets-after-id t))
|
(setq brackets-after-id t))
|
||||||
(when found (backward-char))
|
(when found (backward-char))
|
||||||
t))
|
(<= (point) limit)))
|
||||||
(list id-start id-end brackets-after-id (match-beginning 1) decorated)
|
(list id-start id-end brackets-after-id (match-beginning 1) decorated)
|
||||||
|
|
||||||
(goto-char here)
|
(goto-char here)
|
||||||
|
|
|
@ -1062,7 +1062,7 @@ casts and declarations are fontified. Used on level 2 and higher."
|
||||||
;; The following `while' fontifies a single declarator id each time round.
|
;; The following `while' fontifies a single declarator id each time round.
|
||||||
;; It loops only when LIST is non-nil.
|
;; It loops only when LIST is non-nil.
|
||||||
(while
|
(while
|
||||||
(and pos (setq decl-res (c-forward-declarator limit)))
|
(and pos (setq decl-res (c-forward-declarator)))
|
||||||
(setq next-pos (point)
|
(setq next-pos (point)
|
||||||
id-start (car decl-res)
|
id-start (car decl-res)
|
||||||
id-face (if (and (eq (char-after) ?\()
|
id-face (if (and (eq (char-after) ?\()
|
||||||
|
@ -1091,7 +1091,7 @@ casts and declarations are fontified. Used on level 2 and higher."
|
||||||
(throw 'is-function nil))
|
(throw 'is-function nil))
|
||||||
((not (eq got-type 'maybe))
|
((not (eq got-type 'maybe))
|
||||||
(throw 'is-function t)))
|
(throw 'is-function t)))
|
||||||
(c-forward-declarator limit t)
|
(c-forward-declarator nil t)
|
||||||
(eq (char-after) ?,))
|
(eq (char-after) ?,))
|
||||||
(forward-char)
|
(forward-char)
|
||||||
(c-forward-syntactic-ws))
|
(c-forward-syntactic-ws))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue