This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
cpplib: Don't store \n in C++ comment
- To: gcc-patches at gcc dot gnu dot org
- Subject: cpplib: Don't store \n in C++ comment
- From: Neil Booth <NeilB at earthling dot net>
- Date: Sun, 29 Oct 2000 09:50:40 +0000
- Cc: Jamie Lokier <egcs at tantalophile dot demon dot co dot uk>
This fixes a bug recently pointed out by Jamie Lokier.
Neil.
* cpplex.c (save_comment): Don't store new lines in C++ comments.
Index: cpplex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpplex.c,v
retrieving revision 1.107
diff -u -p -r1.107 cpplex.c
--- cpplex.c 2000/10/28 17:59:05 1.107
+++ cpplex.c 2000/10/29 09:48:38
@@ -724,6 +724,10 @@ save_comment (pfile, token, from)
unsigned int len;
len = pfile->buffer->cur - from + 1; /* + 1 for the initial '/'. */
+ /* C++ comments probably (not definitely) have moved past a new
+ line, which we don't want to save in the comment. */
+ if (pfile->buffer->read_ahead != EOF)
+ len--;
buffer = _cpp_pool_alloc (pfile->string_pool, len);
token->type = CPP_COMMENT;