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]

[cs] patch cppfiles.c


I checked this into the compile-server branch.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/

2003-12-10  Per Bothner  <pbothner@apple.com>

	* cppfiles.c (open_file):  Tweak previous patch.  Only do extra
	path lookup if file->data not set yet and not using global search dir.

	* cppfiles.c: Fix 12-01 patch so we can re-compile same file.
	(_cpp_pop_file_buffer):  Check buffer_valid flag to determine wether
	to free the buffer and its fragments.
	(_cpp_stack_file):  If we want to free the main file's buffer do
	it here, by clearing buffer_valid.  But we probably don't.

Index: cppfiles.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppfiles.c,v
retrieving revision 1.177.2.14
diff -u -p -r1.177.2.14 cppfiles.c
--- cppfiles.c	10 Dec 2003 01:21:12 -0000	1.177.2.14
+++ cppfiles.c	11 Dec 2003 00:02:21 -0000
@@ -220,19 +220,23 @@ open_file (cpp_reader *pfile, _cpp_file 
     }
   else
     {
-      struct file_hash_entry *entry
-	= htab_find_with_hash (pfile->file_hash, path,
-			       htab_hash_string (path));
-
-      entry = search_cache (entry, &pfile->no_search_path);
-      if (entry && entry->u.file->data != NULL)
+      if (file->data == NULL && file->dir != &pfile->no_search_path)
 	{
-	  file->data = entry->u.file->data;
-	  file->err_no = 0;
-	  return true;
+	  struct file_hash_entry *entry
+	    = htab_find_with_hash (pfile->file_hash, path,
+				   htab_hash_string (path));
+
+	  entry = search_cache (entry, &pfile->no_search_path);
+	  if (entry && entry->u.file->data != NULL)
+	    {
+	      file->data = entry->u.file->data;
+	      if (file->data->fd > -1)
+		return true;
+	    }
 	}
 
-      fd = open (file->path, O_RDONLY | O_NOCTTY | O_BINARY, 0666);
+      fd = open (path, O_RDONLY | O_NOCTTY | O_BINARY, 0666);
+      file->err_no = 0;
     }
 
   if (fd != -1)
@@ -799,9 +803,12 @@ _cpp_stack_file (cpp_reader *pfile, _cpp
 	deps_add_dep (pfile->deps, file->path);
     }
 
+#if 0
   /* Clear buffer_valid since _cpp_clean_line messes it up.  */
+#endif
 #if 0
-  file->buffer_valid = false;
+  if (pfile->buffer == NULL)
+    file->data->buffer_valid = false;
 #endif
   file->stack_count++;
 
@@ -1219,6 +1226,8 @@ cpp_push_include (cpp_reader *pfile, con
 void
 _cpp_pop_file_buffer (cpp_reader *pfile, _cpp_file *file)
 {
+  _cpp_file_data *data = file->data;
+
   /* Record the inclusion-preventing macro, which could be NULL
      meaning no controlling macro.  */
   if (pfile->mi_valid && file->cmacro == NULL)
@@ -1227,9 +1236,8 @@ _cpp_pop_file_buffer (cpp_reader *pfile,
   /* Invalidate control macros in the #including file.  */
   pfile->mi_valid = false;
 
-  if (pfile->buffer == NULL && file->data)
+  if (data && !data->buffer_valid)
     {
-      _cpp_file_data *data = file->data;
       if (data->buffer)
 	{
 	  free ((void *) data->buffer);

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