From: Alan Mackenzie <acm@muc.de>
Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org
Subject: Re: Fwd: C mode bug
Date: Sun, 2 Jul 2006 11:41:37 +0100 [thread overview]
Message-ID: <20060702104137.GB1263@muc.de> (raw)
In-Reply-To: <200607010020.22226.pogonyshev@gmx.net>
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)
next parent reply other threads:[~2006-07-02 10:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200607010020.22226.pogonyshev@gmx.net>
2006-07-02 10:41 ` Alan Mackenzie [this message]
2006-07-02 13:03 ` Fwd: C mode bug Paul Pogonyshev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060702104137.GB1263@muc.de \
--to=acm@muc.de \
--cc=bug-cc-mode@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).