* 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