[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r103377: (c-state-literal-at): Preven
From: |
Alan Mackenzie |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r103377: (c-state-literal-at): Prevent positions in macros finding their way into |
Date: |
Mon, 21 Feb 2011 21:25:35 +0000 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 103377
committer: Alan Mackenzie <address@hidden>
branch nick: trunk
timestamp: Mon 2011-02-21 21:25:35 +0000
message:
(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.
modified:
lisp/ChangeLog
lisp/progmodes/cc-engine.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2011-02-21 19:14:56 +0000
+++ b/lisp/ChangeLog 2011-02-21 21:25:35 +0000
@@ -1,3 +1,11 @@
+2011-02-21 Alan Mackenzie <address@hidden>
+
+ 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 <address@hidden>
* net/tramp.el (tramp-rfn-eshadow-setup-minibuffer): Do not use
=== modified file 'lisp/progmodes/cc-engine.el'
--- a/lisp/progmodes/cc-engine.el 2011-02-13 20:25:15 +0000
+++ b/lisp/progmodes/cc-engine.el 2011-02-21 21:25:35 +0000
@@ -2023,9 +2023,9 @@
(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 @@
;; 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 @@
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 @@
;; 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 @@
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r103377: (c-state-literal-at): Prevent positions in macros finding their way into,
Alan Mackenzie <=