Commit e84efb70 authored by Alan Mackenzie's avatar Alan Mackenzie
Browse files

(c-state-literal-at): Prevent positions in macros finding their way into

c-state-nonlit-pos-cache.  Strengthen the comments.

(c-state-dump): New commented out diagnostic routine.
parent 9f8370e6
2011-02-21 Alan Mackenzie <acm@muc.de>
Fix bug #7930.
* progmodes/cc-engine.el (c-state-literal-at): Prevent positions
in macros finding their way into c-state-nonlit-pos-cache.
Strengthen the comments.
(c-state-dump): New commented out diagnostic routine.
2011-02-21 Michael Albinus <michael.albinus@gmx.de>
 
* net/tramp.el (tramp-rfn-eshadow-setup-minibuffer): Do not use
......
......@@ -2023,9 +2023,9 @@ comment at the start of cc-engine.el for more info."
(defvar c-state-nonlit-pos-cache nil)
(make-variable-buffer-local 'c-state-nonlit-pos-cache)
;; A list of buffer positions which are known not to be in a literal. This is
;; ordered with higher positions at the front of the list. Only those which
;; are less than `c-state-nonlit-pos-cache-limit' are valid.
;; A list of buffer positions which are known not to be in a literal or a cpp
;; construct. This is ordered with higher positions at the front of the list.
;; Only those which are less than `c-state-nonlit-pos-cache-limit' are valid.
(defvar c-state-nonlit-pos-cache-limit 1)
(make-variable-buffer-local 'c-state-nonlit-pos-cache-limit)
......@@ -2056,6 +2056,12 @@ comment at the start of cc-engine.el for more info."
;; This function is almost the same as `c-literal-limits'. It differs in
;; that it is a lower level function, and that it rigourously follows the
;; syntax from BOB, whereas `c-literal-limits' uses a "local" safe position.
;;
;; NOTE: This function manipulates `c-state-nonlit-pos-cache'. This cache
;; MAY NOT contain any positions within macros, since macros are frequently
;; turned into comments by use of the `c-cpp-delimiter' category properties.
;; We cannot rely on this mechanism whilst determining a cache pos since
;; this function is also called from outwith `c-parse-state'.
(save-restriction
(widen)
(save-excursion
......@@ -2074,6 +2080,11 @@ comment at the start of cc-engine.el for more info."
here)
(setq lit (c-state-pp-to-literal pos npos))
(setq pos (or (cdr lit) npos)) ; end of literal containing npos.
(goto-char pos)
(when (and (c-beginning-of-macro) (/= (point) pos))
(c-syntactic-end-of-macro)
(or (eobp) (forward-char))
(setq pos (point)))
(setq c-state-nonlit-pos-cache (cons pos c-state-nonlit-pos-cache)))
(if (> pos c-state-nonlit-pos-cache-limit)
......@@ -2158,7 +2169,7 @@ comment at the start of cc-engine.el for more info."
;; of fruitless backward scans.
(defvar c-state-brace-pair-desert nil)
(make-variable-buffer-local 'c-state-brace-pair-desert)
;; Used only in `c-append-lower-brace-pair-to-state-cache'. It is set when an
;; Used only in `c-append-lower-brace-pair-to-state-cache'. It is set when
;; that defun has searched backwards for a brace pair and not found one. Its
;; value is either nil or a cons (PA . FROM), where PA is the position of the
;; enclosing opening paren/brace/bracket which bounds the backwards search (or
......@@ -2843,6 +2854,29 @@ comment at the start of cc-engine.el for more info."
c-state-old-cpp-end nil)
(c-state-mark-point-min-literal))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Debugging routines to dump `c-state-cache' in a "replayable" form.
;; (defmacro c-sc-de (elt) ; "c-state-cache-dump-element"
;; `(format ,(concat "(setq " (symbol-name elt) " %s) ") ,elt))
;; (defmacro c-sc-qde (elt) ; "c-state-cache-quote-dump-element"
;; `(format ,(concat "(setq " (symbol-name elt) " '%s) ") ,elt))
;; (defun c-state-dump ()
;; ;; For debugging.
;; ;(message
;; (concat
;; (c-sc-qde c-state-cache)
;; (c-sc-de c-state-cache-good-pos)
;; (c-sc-qde c-state-nonlit-pos-cache)
;; (c-sc-de c-state-nonlit-pos-cache-limit)
;; (c-sc-qde c-state-brace-pair-desert)
;; (c-sc-de c-state-point-min)
;; (c-sc-de c-state-point-min-lit-type)
;; (c-sc-de c-state-point-min-lit-start)
;; (c-sc-de c-state-min-scan-pos)
;; (c-sc-de c-state-old-cpp-beg)
;; (c-sc-de c-state-old-cpp-end)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c-invalidate-state-cache-1 (here)
;; Invalidate all info on `c-state-cache' that applies to the buffer at HERE
;; or higher and set `c-state-cache-good-pos' accordingly. The cache is
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment