Re: Doubling keywords
Lynn Kerby <[email protected]>
| Newsgroups | gmane.comp.gnu.indent.bugs |
|---|---|
| Message-ID | <[email protected]> |
On Sep 1, 2006, at 12:24 PM, Trevor Blackwell wrote:
>
> I _know_ that indent isn't supported for C++, but the following bug in
> formating C++ code seems like it might represent a more general latent
> bug:
>
> $ echo 'int foo::test() const { return 7; }' | gindent
>
> int
> foo::test() const const
> {
> return 7;
> }
>
> Note that the 'const' token gets output twice. It only does it with
> 'const' and not with other tokens:
>
> $ echo 'int foo::test() _const { return 7; }' | gindent
> int
> foo::test()
> _const
> {
> return 7;
> }
>
> $ echo 'int foo::test() volatile { return 7; }' | gindent
> int
> foo::test()
> volatile {
> return 7;
> }
>
> I can't get it to happen without any C++isms
>
> $ echo 'int foo_test() const { return 7; }' | gindent
> int
> foo_test()
> const {
> return 7;
> }
>
> but it seems like it shouldn't duplicate tokens under any
> circumstances.
>
> If there's a line break in the right place it will concatenate the
> tokens:
>
> $ (echo 'int foo::test()' ; echo 'const { return 7; }' ) | gindent
> int
> foo::test()
> constconst
> {
> return 7;
> }
>
> Version info:
>
> $ gindent --version
> GNU indent 2.2.9
>
> --
> Trevor Blackwell 650 776 7870 [email protected]
>
>
>
> _______________________________________________
> bug-indent mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/bug-indent
Hello Trevor,
A similar bug (at least for the const part) was reported a couple of
months ago on the list. That report included a patch that was specific
to the const token and it appeared to work, but IMO was incorrect as it
seemed to just ignore the const token as part of a C++ function decl.
I'm not much of a C++ programmer, but it sure seemed to me like it was
more of a latent bug in indent than something specific to the const
token.
I'll submit the following patch which seems to work for all your sample
cases:
I've also fixed the whitespace concatenation issue that you saw in the
last case (also a different latent bug) but you won't see it with the
patch above. Hopefully we'll be getting an update to indent soon.
Lynn Kerby
_______________________________________________
bug-indent mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-indent