1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

Proper fix for CC mode Bug#7722.

* lisp/progmodes/cc-fonts.el (c-font-lock-declarations): Remove a
narrow-to-region call that cuts context off the end (Bug#7722).

* lisp/progmodes/cc-engine.el (c-forward-<>-arglist-recur): Refactor
nested if-forms with a simple cond.
(c-forward-<>-arglist): Revert 2011-01-31 change.
This commit is contained in:
Alan Mackenzie 2011-02-13 15:25:15 -05:00 committed by Chong Yidong
parent d4eb88c7ab
commit abfc152b45
3 changed files with 55 additions and 53 deletions

View file

@ -5371,8 +5371,6 @@ comment at the start of cc-engine.el for more info."
;; cc-mode requires cc-fonts.
(declare-function c-fontify-recorded-types-and-refs "cc-fonts" ())
(defvar c-forward-<>-arglist-recur-depth)
(defun c-forward-<>-arglist (all-types)
;; The point is assumed to be at a "<". Try to treat it as the open
;; paren of an angle bracket arglist and move forward to the
@ -5398,8 +5396,7 @@ comment at the start of cc-engine.el for more info."
;; If `c-record-type-identifiers' is set then activate
;; recording of any found types that constitute an argument in
;; the arglist.
(c-record-found-types (if c-record-type-identifiers t))
(c-forward-<>-arglist-recur--depth 0))
(c-record-found-types (if c-record-type-identifiers t)))
(if (catch 'angle-bracket-arglist-escape
(setq c-record-found-types
(c-forward-<>-arglist-recur all-types)))
@ -5416,14 +5413,6 @@ comment at the start of cc-engine.el for more info."
nil)))
(defun c-forward-<>-arglist-recur (all-types)
;; Temporary workaround for Bug#7722.
(when (boundp 'c-forward-<>-arglist-recur--depth)
(if (> c-forward-<>-arglist-recur--depth 200)
(error "Max recursion depth reached in <> arglist")
(setq c-forward-<>-arglist-recur--depth
(1+ c-forward-<>-arglist-recur--depth))))
;; Recursive part of `c-forward-<>-arglist'.
;;
;; This function might do hidden buffer changes.
@ -5455,9 +5444,11 @@ comment at the start of cc-engine.el for more info."
(goto-char start)
nil))
(forward-char)
(forward-char) ; Forward over the opening '<'.
(unless (looking-at c-<-op-cont-regexp)
;; go forward one non-alphanumeric character (group) per iteration of
;; this loop.
(while (and
(progn
(c-forward-syntactic-ws)
@ -5486,7 +5477,7 @@ comment at the start of cc-engine.el for more info."
(c-forward-type)
(c-forward-syntactic-ws))))))
(setq pos (point))
(setq pos (point)) ; e.g. first token inside the '<'
;; Note: These regexps exploit the match order in \| so
;; that "<>" is matched by "<" rather than "[^>:-]>".
@ -5522,37 +5513,35 @@ comment at the start of cc-engine.el for more info."
;; Either an operator starting with '<' or a nested arglist.
(setq pos (point))
(let (id-start id-end subres keyword-match)
(if (if (looking-at c-<-op-cont-regexp)
(setq tmp (match-end 0))
(setq tmp pos)
(backward-char)
(not
(and
(save-excursion
;; There's always an identifier before an angle
;; bracket arglist, or a keyword in
;; `c-<>-type-kwds' or `c-<>-arglist-kwds'.
(c-backward-syntactic-ws)
(setq id-end (point))
(c-simple-skip-symbol-backward)
(when (or (setq keyword-match
(looking-at c-opt-<>-sexp-key))
(not (looking-at c-keywords-regexp)))
(setq id-start (point))))
(setq subres
(let ((c-promote-possible-types t)
(c-record-found-types t))
(c-forward-<>-arglist-recur
(and keyword-match
(c-keyword-member
(c-keyword-sym (match-string 1))
'c-<>-type-kwds)))))
)))
;; It was not an angle bracket arglist.
(goto-char tmp)
(cond
;; The '<' begins a multi-char operator.
((looking-at c-<-op-cont-regexp)
(setq tmp (match-end 0))
(goto-char (match-end 0)))
;; We're at a nested <.....>
((progn
(setq tmp pos)
(backward-char) ; to the '<'
(and
(save-excursion
;; There's always an identifier before an angle
;; bracket arglist, or a keyword in `c-<>-type-kwds'
;; or `c-<>-arglist-kwds'.
(c-backward-syntactic-ws)
(setq id-end (point))
(c-simple-skip-symbol-backward)
(when (or (setq keyword-match
(looking-at c-opt-<>-sexp-key))
(not (looking-at c-keywords-regexp)))
(setq id-start (point))))
(setq subres
(let ((c-promote-possible-types t)
(c-record-found-types t))
(c-forward-<>-arglist-recur
(and keyword-match
(c-keyword-member
(c-keyword-sym (match-string 1))
'c-<>-type-kwds)))))))
;; It was an angle bracket arglist.
(setq c-record-found-types subres)
@ -5567,8 +5556,13 @@ comment at the start of cc-engine.el for more info."
(c-forward-syntactic-ws)
(looking-at c-opt-identifier-concat-key)))
(c-record-ref-id (cons id-start id-end))
(c-record-type-id (cons id-start id-end))))))
t)
(c-record-type-id (cons id-start id-end)))))
;; At a "less than" operator.
(t
(forward-char)
)))
t) ; carry on looping.
((and (not c-restricted-<>-arglists)
(or (and (eq (char-before) ?&)