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]

cpplib: reusing cached include files


cpplib contains code to cache the contents of an include file.
However, this code is currently disasbled, presumably because
it is incompatble with _cpp_clean_line.  However, for the compile
server I really want to be able to re-used the cached buffer.
The following patch seems to more-or-less work.  It's not quite
right, because I haven't attempted to get the line numbers right.
However, it shouldn't be too difficult to fix that by replacing
some of the spaces I've added by newlines instead.

Neil, what do you think?  I'd really appreciate if we could
re-enable the cache.

Index: cppfiles.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppfiles.c,v
retrieving revision 1.170
diff -u -p -r1.170 cppfiles.c
--- cppfiles.c	16 May 2003 23:38:39 -0000	1.170
+++ cppfiles.c	21 May 2003 18:35:33 -0000
@@ -407,8 +413,18 @@ stack_include_file (pfile, inc)
       return false;
     }

+ if (inc->buffer)
+ {
+ if (0 /* FIXME: ! cached_version_is_current_according_to_stat (inc) */)
+ purge_cache (inc);
+ else
+ {
+ close (inc->fd);
+ inc->fd = -1;
+ }
+ }
/* Not in cache? */
- if (1 || ! inc->buffer)
+ if (! inc->buffer)
{
if (read_include_file (pfile, inc))
{
Index: cpplex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplex.c,v
retrieving revision 1.235
diff -u -p -r1.235 cpplex.c
--- cpplex.c 17 May 2003 20:29:31 -0000 1.235
+++ cpplex.c 21 May 2003 18:35:34 -0000
@@ -175,7 +175,12 @@ _cpp_clean_line (pfile)
s++;
}


-  *d = '\n';
+  /* In kludge to support the compile server, which otherwise get
+     confused if trying re-using a buffer, trying to clean a line
+     that has already been cleaned. */
+  while (d < s)
+    *d++ = ' ';
+  /* *d = '\n'; */
   /* A sentinel note that should never be processed.  */
   add_line_note (buffer, d + 1, '\n');
   buffer->next_line = s + 1;

--
	--Per Bothner
per@bothner.com   http://per.bothner.com/




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