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]
Other format: [Raw text]

PATCH handle null cpplib buffer


I checked the attched patch into the trunk.  It fixes a regression
I introduced with my 08-21 patch.  I'm not too happy with this patch,
as it adds some extra tests in frequently-executed code.  I tried
moving the need_line field to cpp_reader (instead of cpp_buffer),
which would actually be more efficient than the code it replaces,
but restoring it on a pop_buffer is tricky.  I'm going to see if I
can get that idea to work over the weekend (while I'll be off-line).
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


2003-08-28  Per Bothner  <per@bothner.com>

	Fix (hopefully temporary) for breakage caused by my 08-21 patch.
	* cpplex.c (_cpp_get_fresh_line):  Check for null buffer.
	(_cpp_lex_buffer):  Likewise.
	* cpptrad.c (_cpp_read_logical_line_trad):  Likewise.

Index: cpplex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplex.c,v
retrieving revision 1.246
diff -u -p -r1.246 cpplex.c
--- cpplex.c	21 Aug 2003 15:57:50 -0000	1.246
+++ cpplex.c	29 Aug 2003 01:02:29 -0000
@@ -694,6 +694,9 @@ _cpp_get_fresh_line (cpp_reader *pfile)
     {
       cpp_buffer *buffer = pfile->buffer;
 
+      if (buffer == NULL)
+	return false;
+
       if (!buffer->need_line)
 	return true;
 
@@ -759,7 +762,8 @@ _cpp_lex_direct (cpp_reader *pfile)
 
  fresh_line:
   result->flags = 0;
-  if (pfile->buffer->need_line)
+  buffer = pfile->buffer;
+  if (buffer == NULL || buffer->need_line)
     {
       if (!_cpp_get_fresh_line (pfile))
 	{
@@ -781,8 +785,8 @@ _cpp_lex_direct (cpp_reader *pfile)
       result->flags = BOL;
       if (pfile->state.parsing_args == 2)
 	result->flags |= PREV_WHITE;
+      buffer = pfile->buffer;
     }
-  buffer = pfile->buffer;
  update_tokens_line:
   result->line = pfile->line;
 
Index: cpptrad.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpptrad.c,v
retrieving revision 1.35
diff -u -p -r1.35 cpptrad.c
--- cpptrad.c	19 Jul 2003 14:47:01 -0000	1.35
+++ cpptrad.c	29 Aug 2003 01:02:29 -0000
@@ -299,7 +299,8 @@ _cpp_read_logical_line_trad (cpp_reader 
 {
   do
     {
-      if (pfile->buffer->need_line && !_cpp_get_fresh_line (pfile))
+      if ((pfile->buffer == NULL || pfile->buffer->need_line)
+	  && !_cpp_get_fresh_line (pfile))
 	return false;
     }
   while (!_cpp_scan_out_logical_line (pfile, NULL) || pfile->state.skipping);

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