GNU bug report logs - #11749
24.1; C-mode indentation gives wrong-type-argument error.

Previous Next

Packages: cc-mode, emacs;

Reported by: storm <at> cua.dk (Kim F. Storm)

Date: Tue, 19 Jun 2012 20:50:02 UTC

Severity: normal

Merged with 9957, 13385

Found in versions 24.0.90, 24.1

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


Message #128 received at 11749 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Michael Welsh Duggan <mwd <at> md5i.com>
Cc: "11749 <at> debbugs.gnu.org" <11749 <at> debbugs.gnu.org>,
	Michael Welsh Duggan <mwd <at> cert.org>, Kim Storm <storm <at> cua.dk>
Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives
	wrong-type-argument error.)
Date: Mon, 7 Jan 2013 12:09:52 +0000
Happy New Year, Michael!

On Sun, Dec 09, 2012 at 10:35:42PM -0500, Michael Welsh Duggan wrote:
> Here's another case.  

> emacs -Q rwrec.h
> M-x c-toggle-parse-state-debug
> C-v {about 24-27 times}

> This is with current bzr.  
> 111170 rgm <at> gnu.org-20121210020042-arkhaf5eej6ujgtn

> rwrec.h is attached.

Thanks.  I think the following patch should have sorted out this one.  It
is based on the cc-engine.el in the emacs-24 branch in savannah.  Could
you try it out as usual, please.



=== modified file 'lisp/progmodes/cc-engine.el'
*** lisp/progmodes/cc-engine.el	2012-12-11 19:06:57 +0000
--- lisp/progmodes/cc-engine.el	2013-01-06 21:52:00 +0000
***************
*** 2464,2471 ****
--- 2464,2475 ----
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; Variables which keep track of preprocessor constructs.
+ (defvar c-state-old-cpp-beg-marker)
+ (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)
+ (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
***************
*** 2653,2665 ****
    ;; 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))))
  	(or upper-lim (setq upper-lim from))
  
  	;; If we're essentially repeating a fruitless search, just give up.
--- 2657,2678 ----
    ;; reduce the time wasted in repeated fruitless searches in brace deserts.
    (save-excursion
      (save-restriction
! 
!       (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.
***************
*** 2899,2905 ****
--- 2912,2920 ----
  		  (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.
***************
*** 3324,3329 ****
--- 3339,3351 ----
       (c-with-cpps-commented-out
        (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.
***************
*** 3350,3358 ****
  	      (c-parse-state-1))
  	   (c-with-cpps-commented-out
  	    (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)))
!       )))
  
  ;; Debug tool to catch cache inconsistencies.  This is called from
  ;; 000tests.el.
--- 3372,3381 ----
  	      (c-parse-state-1))
  	   (c-with-cpps-commented-out
  	    (c-parse-state-1))))
!       (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.



> -- 
> Michael Welsh Duggan
> (md5i <at> md5i.com)

-- 
Alan Mackenzie (Nuremberg, Germany).




This bug report was last modified 12 years and 107 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.