Fwd: Doubling keywords
Lynn Kerby <[email protected]>
| Newsgroups | gmane.comp.gnu.indent.bugs |
|---|---|
| Message-ID | <[email protected]> |
Looks like the mailing list doesn't allow attachments.... Patch inline below. Begin forwarded message: > From: Lynn Kerby <[email protected]> > Date: September 2, 2006 1:15:44 PM PDT > To: Trevor Blackwell <[email protected]> > Cc: [email protected] > Subject: Re: Doubling keywords > > > 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 --- indent.c.orig Tue Jan 31 18:00:29 2006 +++ indent.c Sat Sep 2 12:48:07 2006 @@ -1439,6 +1439,7 @@ { char * t_ptr; set_buf_break (bb_const_qualifier, paren_target); +#if 0 /* fix doubling of C++ tokens */ *e_code++ = ' '; for (t_ptr = token; t_ptr < token_end; ++t_ptr) @@ -1448,6 +1449,7 @@ } *e_code = '\0'; /* null terminate code sect */ +#endif /* fix doubling of C++ tokens */ } else {