2 new commits in cc-mode:
https://bitbucket.org/xemacs/cc-mode/commits/ea4257fccf9b/
changeset: ea4257fccf9b
user: acm
date: 2013-01-17 21:06:14
summary: Fix bugs in the state cache. Enhance a debugging mechanism.
cc-engine.el (c-state-old-cpp-beg-marker, c-state-old-cpp-end-marker):
New variables.
(c-parse-state-get-strategy): Don't use "brace at column zero" strategy
for C++.
(c-append-lower-brace-pair-to-state-cache): Repair algorithm. Start a
backward search for "}" definitively outside CPP constructs.
(c-remove-stale-state-cache): Inform the caller of a need to search back
for a brace pair in certain circumstances.
(c-state-maybe-marker): New macro.
(c-parse-state): Reuse markers when appropriate.
(c-parse-state-point): New variable.
(c-record-parse-state-state): Record old parse state with `copy-tree'.
Record previous value of point.
(c-replay-parse-state-state): Replay markers more correctly.
(c-debug-parse-state-double-cons): New debugging function.
(c-debug-parse-state): Call the above new function.
(c-toggle-parse-state-debug): Output a confirmatory message.
cc-mode.el (c-before-change, c-after-change): Call
c-invalidate-state-cache from `c-before-change' instead of
`c-after-change'.
affected #: 2 files
diff -r e6f8eb00235954a871e6f44c161e09d34cd2af69 -r
ea4257fccf9b3cbe323b3b04323c083096dabd70 cc-engine.el
--- a/cc-engine.el
+++ b/cc-engine.el
@@ -2463,8 +2463,12 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Variables which keep track of preprocessor constructs.
+(defvar c-state-old-cpp-beg-marker nil)
+(make-variable-buffer-local 'c-state-old-cpp-beg-marker)
(defvar c-state-old-cpp-beg nil)
(make-variable-buffer-local 'c-state-old-cpp-beg)
+(defvar c-state-old-cpp-end-marker nil)
+(make-variable-buffer-local 'c-state-old-cpp-end-marker)
(defvar c-state-old-cpp-end nil)
(make-variable-buffer-local 'c-state-old-cpp-end)
;; These are the limits of the macro containing point at the previous call of
@@ -2573,8 +2577,11 @@
start-point cache-pos)))
;; Might we be better off starting from the top level, two defuns back,
- ;; instead?
- (when (> how-far c-state-cache-too-far)
+ ;; instead? This heuristic no longer works well in C++, where
+ ;; declarations inside namespace brace blocks are frequently placed at
+ ;; column zero.
+ (when (and (not (c-major-mode-is 'c++-mode))
+ (> how-far c-state-cache-too-far))
(setq BOD-pos (c-get-fallback-scan-pos here)) ; somewhat EXPENSIVE!!!
(if (< (- here BOD-pos) how-far)
(setq strategy 'BOD
@@ -2649,29 +2656,40 @@
;; reduce the time wasted in repeated fruitless searches in brace deserts.
(save-excursion
(save-restriction
- (let ((bra from) ce ; Positions of "{" and "}".
- new-cons
- (cache-pos (c-state-cache-top-lparen)) ; might be nil.
- (macro-start-or-from
- (progn (goto-char from)
- (c-beginning-of-macro)
- (point))))
+ (let* (new-cons
+ (cache-pos (c-state-cache-top-lparen)) ; might be nil.
+ (macro-start-or-from
+ (progn (goto-char from)
+ (c-beginning-of-macro)
+ (point)))
+ (bra ; Position of "{".
+ ;; Don't start scanning in the middle of a CPP construct unless
+ ;; it contains HERE - these constructs, in Emacs, are "commented
+ ;; out" with category properties.
+ (if (eq (c-get-char-property macro-start-or-from 'category)
+ 'c-cpp-delimiter)
+ macro-start-or-from
+ from))
+ ce) ; Position of "}"
(or upper-lim (setq upper-lim from))
;; If we're essentially repeating a fruitless search, just give up.
(unless (and c-state-brace-pair-desert
(eq cache-pos (car c-state-brace-pair-desert))
+ (or (null (car c-state-brace-pair-desert))
+ (> from (car c-state-brace-pair-desert)))
(<= from (cdr c-state-brace-pair-desert)))
- ;; DESERT-LIM. Only search what we absolutely need to,
+ ;; DESERT-LIM. Avoid repeated searching through the cached desert.
(let ((desert-lim
(and c-state-brace-pair-desert
(eq cache-pos (car c-state-brace-pair-desert))
+ (>= from (cdr c-state-brace-pair-desert))
(cdr c-state-brace-pair-desert)))
;; CACHE-LIM. This limit will be necessary when an opening
;; paren at `cache-pos' has just had its matching close paren
- ;; inserted. `cache-pos' continues to be a search bound, even
- ;; though the algorithm below would skip over the new paren
- ;; pair.
+ ;; inserted into the buffer. `cache-pos' continues to be a
+ ;; search bound, even though the algorithm below would skip
+ ;; over the new paren pair.
(cache-lim (and cache-pos (< cache-pos from) cache-pos)))
(narrow-to-region
(cond
@@ -2892,7 +2910,9 @@
(point-max)
(min (point-max) c-state-old-cpp-beg)))
(while (and c-state-cache (>= (c-state-cache-top-lparen) upper-lim))
+ (setq scan-back-pos (car-safe (car c-state-cache)))
(setq c-state-cache (cdr c-state-cache)))
+
;; If `upper-lim' is inside the last recorded brace pair, remove its
;; RBrace and indicate we'll need to search backwards for a previous
;; brace pair.
@@ -3325,6 +3345,13 @@
;; XEmacs
(c-invalidate-state-cache-1 here)))
+(defmacro c-state-maybe-marker (place marker)
+ ;; If PLACE is non-nil, return a marker marking it, otherwise nil.
+ ;; We (re)use MARKER.
+ `(and ,place
+ (or ,marker (setq ,marker (make-marker)))
+ (set-marker ,marker ,place)))
+
(defun c-parse-state ()
;; This is a wrapper over `c-parse-state-1'. See that function for a
;; description of the functionality and return value.
@@ -3356,9 +3383,10 @@
(c-parse-state-1))))
;; XEmacs
(c-parse-state-1))
- (setq c-state-old-cpp-beg (and here-cpp-beg (copy-marker here-cpp-beg t))
- c-state-old-cpp-end (and here-cpp-end (copy-marker here-cpp-end t)))
- )))
+ (setq c-state-old-cpp-beg
+ (c-state-maybe-marker here-cpp-beg c-state-old-cpp-beg-marker)
+ c-state-old-cpp-end
+ (c-state-maybe-marker here-cpp-end c-state-old-cpp-end-marker)))))
;; Debug tool to catch cache inconsistencies. This is called from
;; 000tests.el.
@@ -3367,13 +3395,26 @@
(fset 'c-real-parse-state (symbol-function 'c-parse-state)))
(cc-bytecomp-defun c-real-parse-state)
+(defvar c-parse-state-point nil)
(defvar c-parse-state-state nil)
(make-variable-buffer-local 'c-parse-state-state)
(defun c-record-parse-state-state ()
+ (setq c-parse-state-point (point))
(setq c-parse-state-state
(mapcar
(lambda (arg)
- (cons arg (symbol-value arg)))
+ (let ((val (symbol-value arg)))
+ (cons arg
+
+ ;; (if (consp val)
+ ;; (copy-tree val)
+ ;; val)
+
+ (cond ((consp val) (copy-tree val))
+ ((markerp val) (copy-marker val))
+ (t val))
+
+)))
'(c-state-cache
c-state-cache-good-pos
c-state-nonlit-pos-cache
@@ -3386,16 +3427,31 @@
c-state-point-min-lit-start
c-state-min-scan-pos
c-state-old-cpp-beg
- c-state-old-cpp-end))))
+ c-state-old-cpp-end
+ c-parse-state-point))))
(defun c-replay-parse-state-state ()
(message
(concat "(setq "
(mapconcat
(lambda (arg)
- (format "%s %s%s" (car arg) (if (atom (cdr arg)) ""
"'") (cdr arg)))
+ (format "%s %s%s" (car arg)
+ (if (atom (cdr arg)) "" "'")
+ (if (markerp (cdr arg))
+ (format "(copy-marker %s)" (marker-position (cdr arg)))
+ (cdr arg))))
c-parse-state-state " ")
")")))
+(defun c-debug-parse-state-double-cons (state)
+ (let (state-car conses-not-ok)
+ (while state
+ (setq state-car (car state)
+ state (cdr state))
+ (if (and (consp state-car)
+ (consp (car state)))
+ (setq conses-not-ok t)))
+ conses-not-ok))
+
(defun c-debug-parse-state ()
(let ((here (point)) (res1 (c-real-parse-state)) res2)
(let ((c-state-cache nil)
@@ -3428,8 +3484,16 @@
here res1 res2)
(message "Old state:")
(c-replay-parse-state-state))
+
+ (when (c-debug-parse-state-double-cons res1)
+ (message "c-parse-state INVALIDITY at %s: %s"
+ here res1)
+ (message "Old state:")
+ (c-replay-parse-state-state))
+
(c-record-parse-state-state)
- res1))
+ res2 ; res1 correct a cascading series of errors ASAP
+ ))
(defun c-toggle-parse-state-debug (&optional arg)
(interactive "P")
@@ -3437,7 +3501,9 @@
(fset 'c-parse-state (symbol-function (if c-debug-parse-state
'c-debug-parse-state
'c-real-parse-state)))
- (c-keep-region-active))
+ (c-keep-region-active)
+ (message "c-debug-parse-state %sabled"
+ (if c-debug-parse-state "en" "dis")))
(when c-debug-parse-state
(c-toggle-parse-state-debug 1))
diff -r e6f8eb00235954a871e6f44c161e09d34cd2af69 -r
ea4257fccf9b3cbe323b3b04323c083096dabd70 cc-mode.el
--- a/cc-mode.el
+++ b/cc-mode.el
@@ -1058,7 +1058,10 @@
(mapc (lambda (fn)
(funcall fn beg end))
c-get-state-before-change-functions))
- )))))
+ )))
+ ;; The following must be done here rather than in `c-after-change' because
+ ;; newly inserted parens would foul up the invalidation algorithm.
+ (c-invalidate-state-cache beg)))
(defvar c-in-after-change-fontification nil)
(make-variable-buffer-local 'c-in-after-change-fontification)
@@ -1108,7 +1111,7 @@
(c-trim-found-types beg end old-len) ; maybe we don't need all of these.
(c-invalidate-sws-region-after beg end)
- (c-invalidate-state-cache beg)
+ ;; (c-invalidate-state-cache beg) ; moved to `c-before-change'.
(c-invalidate-find-decl-cache beg)
(when c-recognize-<>-arglists
https://bitbucket.org/xemacs/cc-mode/commits/2b353db0dc37/
changeset: 2b353db0dc37
user: acm
date: 2013-01-17 22:08:49
summary: Merge.
affected #: 3 files
diff -r ea4257fccf9b3cbe323b3b04323c083096dabd70 -r
2b353db0dc37b60febfd99f3fbb796f2fd4e24f6 .hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -91,3 +91,4 @@
2475272d8bae991446e6b5fe927fb9a489b6df5d cc-mode-1_56
a9aff1813e2a4aa3d8af1ae40b69bcaf033f7905 cc-mode-1_57
46f8e9f7f8174bdf529daf1577892b212c566d5b cc-mode-1_58
+c325532f7d0bbf9c4cae63da83d12abf2033c6b5 cc-mode-1_59
diff -r ea4257fccf9b3cbe323b3b04323c083096dabd70 -r
2b353db0dc37b60febfd99f3fbb796f2fd4e24f6 ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-12-28 Norbert Koch <viteno(a)xemacs.org>
+
+ * Makefile (VERSION): XEmacs package 1.59 released.
+
2012-12-10 Norbert Koch <viteno(a)xemacs.org>
* Makefile (VERSION): XEmacs package 1.58 released.
diff -r ea4257fccf9b3cbe323b3b04323c083096dabd70 -r
2b353db0dc37b60febfd99f3fbb796f2fd4e24f6 Makefile
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
-VERSION = 1.58
+VERSION = 1.59
AUTHOR_VERSION = 5.32.2
MAINTAINER = Alan Mackenzie <bug-cc-mode(a)gnu.org>
PACKAGE = cc-mode
Repository URL:
https://bitbucket.org/xemacs/cc-mode/
--
This is a commit notification from
bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches