This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[cs] _cpp_clean_lines patch
- From: Per Bothner <per at bothner dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Aug 2003 15:23:51 -0700
- Subject: [cs] _cpp_clean_lines patch
I checked the attached patch into the compile-server branch.
My hope is with this patch the line-number info is correct,
making debugging (and error messages) much easier to deal with!
There is still the problem that if a fragment (or file) is
re-parsed, we don't get the line notes and associated error
messages. Neil, I'm afraid I don't quite see the purpose of
the line notes. Why don't we do the the error-checking in
_cpp_process_line_notes while we're in _cpp_clean_lines? Is
it a performance issue?
--
--Per Bothner
per@bothner.com http://per.bothner.com/
2003-08-21 Per Bothner <pbothner@apple.com>
* cpplex.c (_cpp_clean_line): Add extra '\n' into buffer,
in case it is re-used.
Index: cpplex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplex.c,v
retrieving revision 1.245.2.2
diff -u -p -r1.245.2.2 cpplex.c
--- cpplex.c 15 Aug 2003 01:47:40 -0000 1.245.2.2
+++ cpplex.c 21 Aug 2003 19:22:05 -0000
@@ -105,6 +105,7 @@ _cpp_clean_line (cpp_reader *pfile)
cpp_buffer *buffer;
const uchar *s;
uchar c, *d, *p;
+ int nlines = 0;
buffer = pfile->buffer;
buffer->cur_note = buffer->notes_used = 0;
@@ -139,6 +140,7 @@ _cpp_clean_line (cpp_reader *pfile)
add_line_note (buffer, p - 1, p != d ? ' ': '\\');
d = p - 2;
buffer->next_line = p - 1;
+ nlines++;
}
else if (c == '?' && s[1] == '?' && _cpp_trigraph_map[s[2]])
{
@@ -170,7 +172,8 @@ _cpp_clean_line (cpp_reader *pfile)
line numbers correctly! FIXME! */
while (d < s)
*d++ = ' ';
- /* *d = '\n'; */
+ for (; nlines >= 0; nlines--)
+ d[-nlines] = '\n';
/* A sentinel note that should never be processed. */
add_line_note (buffer, d + 1, '\n');
buffer->next_line = s + 1;