aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/progmodes/cc-engine.el53
2 files changed, 54 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f2d0ec37b32..86ae2d06679 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12011-10-22 Alan Mackenzie <bug-cc-mode@gnu.org>
2
3 Fix bug #9560, sporadic wrong indentation; improve instrumentation
4 of c-parse-state.
5
6 * cc-engine.el (c-append-lower-brace-pair-to-state-cache): correct
7 faulty logical expression.
8 (c-parse-state-state, c-record-parse-state-state):
9 (c-replay-parse-state-state): New defvar/defuns.
10 (c-debug-parse-state): Use new functions.
11
12011-10-22 Martin Rudalics <rudalics@gmx.at> 122011-10-22 Martin Rudalics <rudalics@gmx.at>
2 13
3 * mouse.el (mouse-drag-line): Fix minibuffer resizing broken by 14 * mouse.el (mouse-drag-line): Fix minibuffer resizing broken by
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index a1cbdc16560..b2c548847c3 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -2456,7 +2456,7 @@ comment at the start of cc-engine.el for more info."
2456 (<= from (cdr c-state-brace-pair-desert))) 2456 (<= from (cdr c-state-brace-pair-desert)))
2457 ;; Only search what we absolutely need to: 2457 ;; Only search what we absolutely need to:
2458 (if (and c-state-brace-pair-desert 2458 (if (and c-state-brace-pair-desert
2459 (> from (cdr c-state-brace-pair-desert))) 2459 (eq cache-pos (car c-state-brace-pair-desert)))
2460 (narrow-to-region (cdr c-state-brace-pair-desert) (point-max))) 2460 (narrow-to-region (cdr c-state-brace-pair-desert) (point-max)))
2461 2461
2462 ;; In the next pair of nested loops, the inner one moves back past a 2462 ;; In the next pair of nested loops, the inner one moves back past a
@@ -3127,6 +3127,33 @@ comment at the start of cc-engine.el for more info."
3127(unless (fboundp 'c-real-parse-state) 3127(unless (fboundp 'c-real-parse-state)
3128 (fset 'c-real-parse-state (symbol-function 'c-parse-state))) 3128 (fset 'c-real-parse-state (symbol-function 'c-parse-state)))
3129(cc-bytecomp-defun c-real-parse-state) 3129(cc-bytecomp-defun c-real-parse-state)
3130
3131(defvar c-parse-state-state nil)
3132(defun c-record-parse-state-state ()
3133 (setq c-parse-state-state
3134 (mapcar
3135 (lambda (arg)
3136 (cons arg (symbol-value arg)))
3137 '(c-state-cache
3138 c-state-cache-good-pos
3139 c-state-nonlit-pos-cache
3140 c-state-nonlit-pos-cache-limit
3141 c-state-brace-pair-desert
3142 c-state-point-min
3143 c-state-point-min-lit-type
3144 c-state-point-min-lit-start
3145 c-state-min-scan-pos
3146 c-state-old-cpp-beg
3147 c-state-old-cpp-end))))
3148(defun c-replay-parse-state-state ()
3149 (message
3150 (concat "(setq "
3151 (mapconcat
3152 (lambda (arg)
3153 (format "%s %s%s" (car arg) (if (atom (cdr arg)) "" "'") (cdr arg)))
3154 c-parse-state-state " ")
3155 ")")))
3156
3130(defun c-debug-parse-state () 3157(defun c-debug-parse-state ()
3131 (let ((here (point)) (res1 (c-real-parse-state)) res2) 3158 (let ((here (point)) (res1 (c-real-parse-state)) res2)
3132 (let ((c-state-cache nil) 3159 (let ((c-state-cache nil)
@@ -3145,15 +3172,21 @@ comment at the start of cc-engine.el for more info."
3145 ;; The cache can actually go further back due to the ad-hoc way 3172 ;; The cache can actually go further back due to the ad-hoc way
3146 ;; the first paren is found, so try to whack off a bit of its 3173 ;; the first paren is found, so try to whack off a bit of its
3147 ;; start before complaining. 3174 ;; start before complaining.
3148 (save-excursion 3175 ;; (save-excursion
3149 (goto-char (or (c-least-enclosing-brace res2) (point))) 3176 ;; (goto-char (or (c-least-enclosing-brace res2) (point)))
3150 (c-beginning-of-defun-1) 3177 ;; (c-beginning-of-defun-1)
3151 (while (not (or (bobp) (eq (char-after) ?{))) 3178 ;; (while (not (or (bobp) (eq (char-after) ?{)))
3152 (c-beginning-of-defun-1)) 3179 ;; (c-beginning-of-defun-1))
3153 (unless (equal (c-whack-state-before (point) res1) res2) 3180 ;; (unless (equal (c-whack-state-before (point) res1) res2)
3154 (message (concat "c-parse-state inconsistency at %s: " 3181 ;; (message (concat "c-parse-state inconsistency at %s: "
3155 "using cache: %s, from scratch: %s") 3182 ;; "using cache: %s, from scratch: %s")
3156 here res1 res2)))) 3183 ;; here res1 res2)))
3184 (message (concat "c-parse-state inconsistency at %s: "
3185 "using cache: %s, from scratch: %s")
3186 here res1 res2)
3187 (message "Old state:")
3188 (c-replay-parse-state-state))
3189 (c-record-parse-state-state)
3157 res1)) 3190 res1))
3158 3191
3159(defun c-toggle-parse-state-debug (&optional arg) 3192(defun c-toggle-parse-state-debug (&optional arg)