diff options
| author | Alan Mackenzie | 2011-02-21 21:25:35 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2011-02-21 21:25:35 +0000 |
| commit | e84efb7078b7251b8c8bf15f71fed653cfa535a5 (patch) | |
| tree | c81b2a99881768c3b3bcf91f5e68235a169c75a6 | |
| parent | 9f8370e63f65f76887b319ab6a0368d4a332777c (diff) | |
| download | emacs-e84efb7078b7251b8c8bf15f71fed653cfa535a5.tar.gz emacs-e84efb7078b7251b8c8bf15f71fed653cfa535a5.zip | |
(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.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 42 |
2 files changed, 46 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 05c765e0881..e4b30dfa310 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2011-02-21 Alan Mackenzie <acm@muc.de> | ||
| 2 | |||
| 3 | Fix bug #7930. | ||
| 4 | * progmodes/cc-engine.el (c-state-literal-at): Prevent positions | ||
| 5 | in macros finding their way into c-state-nonlit-pos-cache. | ||
| 6 | Strengthen the comments. | ||
| 7 | (c-state-dump): New commented out diagnostic routine. | ||
| 8 | |||
| 1 | 2011-02-21 Michael Albinus <michael.albinus@gmx.de> | 9 | 2011-02-21 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 10 | ||
| 3 | * net/tramp.el (tramp-rfn-eshadow-setup-minibuffer): Do not use | 11 | * net/tramp.el (tramp-rfn-eshadow-setup-minibuffer): Do not use |
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index de1debd6456..654323e03e4 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -2023,9 +2023,9 @@ comment at the start of cc-engine.el for more info." | |||
| 2023 | 2023 | ||
| 2024 | (defvar c-state-nonlit-pos-cache nil) | 2024 | (defvar c-state-nonlit-pos-cache nil) |
| 2025 | (make-variable-buffer-local 'c-state-nonlit-pos-cache) | 2025 | (make-variable-buffer-local 'c-state-nonlit-pos-cache) |
| 2026 | ;; A list of buffer positions which are known not to be in a literal. This is | 2026 | ;; A list of buffer positions which are known not to be in a literal or a cpp |
| 2027 | ;; ordered with higher positions at the front of the list. Only those which | 2027 | ;; construct. This is ordered with higher positions at the front of the list. |
| 2028 | ;; are less than `c-state-nonlit-pos-cache-limit' are valid. | 2028 | ;; Only those which are less than `c-state-nonlit-pos-cache-limit' are valid. |
| 2029 | 2029 | ||
| 2030 | (defvar c-state-nonlit-pos-cache-limit 1) | 2030 | (defvar c-state-nonlit-pos-cache-limit 1) |
| 2031 | (make-variable-buffer-local 'c-state-nonlit-pos-cache-limit) | 2031 | (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." | |||
| 2056 | ;; This function is almost the same as `c-literal-limits'. It differs in | 2056 | ;; This function is almost the same as `c-literal-limits'. It differs in |
| 2057 | ;; that it is a lower level function, and that it rigourously follows the | 2057 | ;; that it is a lower level function, and that it rigourously follows the |
| 2058 | ;; syntax from BOB, whereas `c-literal-limits' uses a "local" safe position. | 2058 | ;; syntax from BOB, whereas `c-literal-limits' uses a "local" safe position. |
| 2059 | ;; | ||
| 2060 | ;; NOTE: This function manipulates `c-state-nonlit-pos-cache'. This cache | ||
| 2061 | ;; MAY NOT contain any positions within macros, since macros are frequently | ||
| 2062 | ;; turned into comments by use of the `c-cpp-delimiter' category properties. | ||
| 2063 | ;; We cannot rely on this mechanism whilst determining a cache pos since | ||
| 2064 | ;; this function is also called from outwith `c-parse-state'. | ||
| 2059 | (save-restriction | 2065 | (save-restriction |
| 2060 | (widen) | 2066 | (widen) |
| 2061 | (save-excursion | 2067 | (save-excursion |
| @@ -2074,6 +2080,11 @@ comment at the start of cc-engine.el for more info." | |||
| 2074 | here) | 2080 | here) |
| 2075 | (setq lit (c-state-pp-to-literal pos npos)) | 2081 | (setq lit (c-state-pp-to-literal pos npos)) |
| 2076 | (setq pos (or (cdr lit) npos)) ; end of literal containing npos. | 2082 | (setq pos (or (cdr lit) npos)) ; end of literal containing npos. |
| 2083 | (goto-char pos) | ||
| 2084 | (when (and (c-beginning-of-macro) (/= (point) pos)) | ||
| 2085 | (c-syntactic-end-of-macro) | ||
| 2086 | (or (eobp) (forward-char)) | ||
| 2087 | (setq pos (point))) | ||
| 2077 | (setq c-state-nonlit-pos-cache (cons pos c-state-nonlit-pos-cache))) | 2088 | (setq c-state-nonlit-pos-cache (cons pos c-state-nonlit-pos-cache))) |
| 2078 | 2089 | ||
| 2079 | (if (> pos c-state-nonlit-pos-cache-limit) | 2090 | (if (> pos c-state-nonlit-pos-cache-limit) |
| @@ -2158,7 +2169,7 @@ comment at the start of cc-engine.el for more info." | |||
| 2158 | ;; of fruitless backward scans. | 2169 | ;; of fruitless backward scans. |
| 2159 | (defvar c-state-brace-pair-desert nil) | 2170 | (defvar c-state-brace-pair-desert nil) |
| 2160 | (make-variable-buffer-local 'c-state-brace-pair-desert) | 2171 | (make-variable-buffer-local 'c-state-brace-pair-desert) |
| 2161 | ;; Used only in `c-append-lower-brace-pair-to-state-cache'. It is set when an | 2172 | ;; Used only in `c-append-lower-brace-pair-to-state-cache'. It is set when |
| 2162 | ;; that defun has searched backwards for a brace pair and not found one. Its | 2173 | ;; that defun has searched backwards for a brace pair and not found one. Its |
| 2163 | ;; value is either nil or a cons (PA . FROM), where PA is the position of the | 2174 | ;; value is either nil or a cons (PA . FROM), where PA is the position of the |
| 2164 | ;; enclosing opening paren/brace/bracket which bounds the backwards search (or | 2175 | ;; 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." | |||
| 2843 | c-state-old-cpp-end nil) | 2854 | c-state-old-cpp-end nil) |
| 2844 | (c-state-mark-point-min-literal)) | 2855 | (c-state-mark-point-min-literal)) |
| 2845 | 2856 | ||
| 2857 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 2858 | ;; Debugging routines to dump `c-state-cache' in a "replayable" form. | ||
| 2859 | ;; (defmacro c-sc-de (elt) ; "c-state-cache-dump-element" | ||
| 2860 | ;; `(format ,(concat "(setq " (symbol-name elt) " %s) ") ,elt)) | ||
| 2861 | ;; (defmacro c-sc-qde (elt) ; "c-state-cache-quote-dump-element" | ||
| 2862 | ;; `(format ,(concat "(setq " (symbol-name elt) " '%s) ") ,elt)) | ||
| 2863 | ;; (defun c-state-dump () | ||
| 2864 | ;; ;; For debugging. | ||
| 2865 | ;; ;(message | ||
| 2866 | ;; (concat | ||
| 2867 | ;; (c-sc-qde c-state-cache) | ||
| 2868 | ;; (c-sc-de c-state-cache-good-pos) | ||
| 2869 | ;; (c-sc-qde c-state-nonlit-pos-cache) | ||
| 2870 | ;; (c-sc-de c-state-nonlit-pos-cache-limit) | ||
| 2871 | ;; (c-sc-qde c-state-brace-pair-desert) | ||
| 2872 | ;; (c-sc-de c-state-point-min) | ||
| 2873 | ;; (c-sc-de c-state-point-min-lit-type) | ||
| 2874 | ;; (c-sc-de c-state-point-min-lit-start) | ||
| 2875 | ;; (c-sc-de c-state-min-scan-pos) | ||
| 2876 | ;; (c-sc-de c-state-old-cpp-beg) | ||
| 2877 | ;; (c-sc-de c-state-old-cpp-end))) | ||
| 2878 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 2879 | |||
| 2846 | (defun c-invalidate-state-cache-1 (here) | 2880 | (defun c-invalidate-state-cache-1 (here) |
| 2847 | ;; Invalidate all info on `c-state-cache' that applies to the buffer at HERE | 2881 | ;; Invalidate all info on `c-state-cache' that applies to the buffer at HERE |
| 2848 | ;; or higher and set `c-state-cache-good-pos' accordingly. The cache is | 2882 | ;; or higher and set `c-state-cache-good-pos' accordingly. The cache is |