cpplib: Don't store \n in C++ comment

Neil Booth NeilB@earthling.net
Sun Oct 29 01:50:00 GMT 2000


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;


More information about the Gcc-patches mailing list