unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: Fwd: C mode bug
       [not found] <200607010020.22226.pogonyshev@gmx.net>
@ 2006-07-02 10:41 ` Alan Mackenzie
  2006-07-02 13:03   ` Paul Pogonyshev
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Mackenzie @ 2006-07-02 10:41 UTC (permalink / raw)
  Cc: bug-cc-mode, emacs-devel

Hi, Paul!

Thanks for reporting this bug.  Here's a fix.

Your 7 lines of code have become cc-mode/test/templates-18.cc in the CC
Mode project.  Thanks!

I now know what an "explicit specialization of a template class" is in
C++.  YUCK!  ;-)

On Sat, Jul 01, 2006 at 12:20:22AM +0300, Paul Pogonyshev wrote:
 
> In template specialization (C++) C mode gives incorrect indentation
> when function name is given on separate line:
 
>   template <>
>   struct test <int>
>   {
>     void
>     function ()
>     { }
>   };
 
> is indented as
 
>   template <>
>   struct test <int>
>   {
>     void
>       function ()
>     { }
>   };
 
> Paul

So, please try this patch out.  Let me know if it doesn't work properly.
Thanks!

Log Message:
cc-engine.el (c-looking-at-decl-block): tolerate empty angle brackets (as
seen in "explicit specialisations" of templates).

Index: cc-engine.el
===================================================================
RCS file: /cvsroot/cc-mode/cc-mode/cc-engine.el,v
retrieving revision 5.539.2.4
retrieving revision 5.539.2.5
diff -C2 -d -r5.539.2.4 -r5.539.2.5
*** cc-engine.el	29 Apr 2006 09:38:21 -0000	5.539.2.4
--- cc-engine.el	1 Jul 2006 21:22:05 -0000	5.539.2.5
***************
*** 4533,4571 ****
  	  nil)
  
!       (while (and
  	      (c-syntactic-skip-backward "^<;{}" limit t)
  
! 	      (if (eq (char-before) ?<)
! 		  t
! 		;; Stopped at bob or a char that isn't allowed in an
! 		;; arglist, so we've failed.
! 		(goto-char start)
! 		nil)
  
! 	      (if (> (point)
! 		     (progn (c-beginning-of-current-token)
! 			    (point)))
! 		  ;; If we moved then the "<" was part of some
! 		  ;; multicharacter token.
! 		  t
  
! 		(backward-char)
! 		(let ((beg-pos (point)))
! 		  (if (c-forward-<>-arglist all-types)
! 		      (cond ((= (point) start)
! 			     ;; Matched the arglist.  Break the while.
! 			     (goto-char beg-pos)
! 			     nil)
! 			    ((> (point) start)
! 			     ;; We started from a non-paren ">" inside an
! 			     ;; arglist.
! 			     (goto-char start)
! 			     nil)
! 			    (t
! 			     ;; Matched a shorter arglist.  Can be a nested
! 			     ;; one so continue looking.
! 			     (goto-char beg-pos)
! 			     t))
! 		    t)))))
  
        (/= (point) start))))
--- 4533,4572 ----
  	  nil)
  
!       (while (progn
  	      (c-syntactic-skip-backward "^<;{}" limit t)
  
! 	      (and
! 	       (if (eq (char-before) ?<)
! 		   t
! 		 ;; Stopped at bob or a char that isn't allowed in an
! 		 ;; arglist, so we've failed.
! 		 (goto-char start)
! 		 nil)
  
! 	       (if (> (point)
! 		      (progn (c-beginning-of-current-token)
! 			     (point)))
! 		   ;; If we moved then the "<" was part of some
! 		   ;; multicharacter token.
! 		   t
  
! 		 (backward-char)
! 		 (let ((beg-pos (point)))
! 		   (if (c-forward-<>-arglist all-types)
! 		       (cond ((= (point) start)
! 			      ;; Matched the arglist.  Break the while.
! 			      (goto-char beg-pos)
! 			      nil)
! 			     ((> (point) start)
! 			      ;; We started from a non-paren ">" inside an
! 			      ;; arglist.
! 			      (goto-char start)
! 			      nil)
! 			     (t
! 			      ;; Matched a shorter arglist.  Can be a nested
! 			      ;; one so continue looking.
! 			      (goto-char beg-pos)
! 			      t))
! 		     t))))))
  
        (/= (point) start))))


-- 
Alan Mackenzie (Munich, Germany)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Fwd: C mode bug
  2006-07-02 10:41 ` Fwd: C mode bug Alan Mackenzie
@ 2006-07-02 13:03   ` Paul Pogonyshev
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Pogonyshev @ 2006-07-02 13:03 UTC (permalink / raw)
  Cc: bug-cc-mode, Alan Mackenzie

Alan Mackenzie wrote:
> Thanks for reporting this bug.  Here's a fix.
> 
> [...]
> 
> So, please try this patch out.  Let me know if it doesn't work properly.

Thanks, it works just fine.

Paul

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-07-02 13:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200607010020.22226.pogonyshev@gmx.net>
2006-07-02 10:41 ` Fwd: C mode bug Alan Mackenzie
2006-07-02 13:03   ` Paul Pogonyshev

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).