[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug#507173: indent: adds extra const keywords to C++ programs (fwd)
From: |
Santiago Vila |
Subject: |
Bug#507173: indent: adds extra const keywords to C++ programs (fwd) |
Date: |
Fri, 24 Jul 2009 20:17:50 +0200 (CEST) |
Hello.
I received this from the Debian bug system.
There is a proposed patch at the end.
---------- Forwarded message ----------
From: Timo Juhani Lindfors <address@hidden>
To: Debian Bug Tracking System <address@hidden>
Date: Fri, 28 Nov 2008 20:49:35 +0200
Subject: Bug#507173: indent: adds extra const keywords to C++ programs
Package: indent
Version: 2.2.10-1
Severity: normal
Steps to reproduce:
1) cat > svg.cc <<EOF
void Svg::write(std::ostream &st, const Graph &g) const { }
EOF
2) indent -o svg.cc.indent svg.cc
Expected results:
2) svg.cc.indent and svg.cc differ only in whitespace
Actual results:
2) svg.cc.indent has extra const keyword:
void
Svg::write (std::ostream & st, const Graph & g) const const
{
}
More info:
1) If I run indent again to the output file it adds yet another const
keyword. This means that indent is not idempotent and can not be used
to check whether a file already has correct indentation or not.
2) The bug also occurs with indent 2.2.9-7 in debian stable.
3) It seems that the first const is written by handle_token_decl() and
the second const is written by copy_id():
case decl:
/* we have a declaration type (int, register, etc.) */
handle_token_decl(dec_ind, file_exit_value,
pbreak_line);
copy_id(type_code, force_nl, file_exit_value, can_break);
Maybe this could be fixed by just not writing const from
handle_token_decl?
-----------------------------------------------------------
Later, Erwin Burgstaller <address@hidden> writes:
I've found this patch and it's working:
--- 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
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Bug#507173: indent: adds extra const keywords to C++ programs (fwd),
Santiago Vila <=