🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99333

Re: Bug in c-mode indentation

#99333
From: Joe Wells
Date: Fri, 28 Sep 1990 09:40
48 lines
2178 bytes
Michael> It occurs when you have a global variable initialized with a string
Michael> containing parentheses.  E.g.:

Michael> char * s1 = "global, in quotes (with parens)";
Michael>      char * s2 = "indented wrong";

Michael> Replications?  Explanations?  Fixes?

Explanation:  Emacs is guessing that the second line is the old-style
declaration of the argument of a function.

Fix:

*** /usr14/gnu/dist-18.55/lisp/c-mode.el	Fri May 27 21:28:12 1988
--- c-mode.el	Fri Sep 28 05:33:41 1990
***************
*** 375,386 ****
  			(re-search-backward "^[^ \^L\t\n#]" nil 'move)
  			(if (and (looking-at "\\sw\\|\\s_")
! 				 (looking-at ".*(")
! 				 (progn
! 				   (goto-char (1- (match-end 0)))
! 				   (forward-sexp 1)
! 				   (and (< (point) indent-point)
! 					(not (memq (following-char)
! 						   '(?\, ?\;))))))
! 			    c-argdecl-indent 0))))
  		 ;; Now add a little if this is a continuation line.
  		 (+ basic-indent (if (or (bobp)
--- 375,384 ----
  			(re-search-backward "^[^ \^L\t\n#]" nil 'move)
  			(if (and (looking-at "\\sw\\|\\s_")
! 				 (parse-partial-sexp (point) parse-start 0)
! 				 (eq ?\) (preceding-char))
! 				 (or (skip-chars-forward " \t\f\n") t)
! 				 (not (memq (following-char) '(?\, ?\;))))
! 			    c-argdecl-indent
! 			  0))))
  		 ;; Now add a little if this is a continuation line.
  		 (+ basic-indent (if (or (bobp)

The fix is not perfect, but most mistakes it might make are also made by
the current version, so it's an improvement.

Enjoy,

-- 
Joe Wells <jbw@bu.edu>
Technical Details
Message-ID: <9009280940.AA15887@bucsf.bu.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!BUCSF.BU.EDU!jbw
References: <15156@csli.Stanford.EDU>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,74946f2e1acce628
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-09-28 12:37:39 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!BUCSF.BU.EDU!jbw
From: jbw@BUCSF.BU.EDU (Joe Wells)
Newsgroups: gnu.emacs.bug
Subject: Re: Bug in c-mode indentation
Message-ID: <9009280940.AA15887@bucsf.bu.edu>
Date: 28 Sep 90 09:40:19 GMT
References: <15156@csli.Stanford.EDU>
Sender: marty-m@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 48
Posted: Fri Sep 28 10:40:19 1990