This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


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;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]