cppfiles.c (open_file): If already read, then don't reopen.
authorNathan Sidwell <nathan@codesourcery.com>
Fri, 3 Nov 2000 16:03:37 +0000 (16:03 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Fri, 3 Nov 2000 16:03:37 +0000 (16:03 +0000)
* cppfiles.c (open_file): If already read, then don't reopen.
Immediately close an empty file.

From-SVN: r37227

gcc/ChangeLog
gcc/cppfiles.c

index d2414dcb317d32c7799975fd3e08d75fffac4998..0ad0e517bce075328af8cc5546c9e86eb90e8b96 100644 (file)
@@ -1,3 +1,8 @@
+2000-11-03  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * cppfiles.c (open_file): If already read, then don't reopen.
+       Immediately close an empty file.
+
 2000-11-01  Bernd Schmidt  <bernds@redhat.co.uk>
 
        * expr.h (fold_builtin): Move declaration...
index 1009fa784a1f7c1f7bef2415caad6a6c8a391b62..47bf43f211fbc0499e4d6dcc4d053e4c293fc07b 100644 (file)
@@ -145,9 +145,13 @@ open_file (pfile, filename)
       if (file->fd == -2)
        return 0;
 
-      /* -1 indicates a file we've opened previously, and since closed.  */
-      if (file->fd != -1)
-       return file;
+      /* Don't reopen an idempotent file. */
+      if (DO_NOT_REREAD (file))
+        return file;
+      
+      /* Don't reopen one which is already loaded. */
+      if (file->buffer != NULL)
+        return file;
     }
   else
     {
@@ -181,7 +185,11 @@ open_file (pfile, filename)
     {
       /* Mark a regular, zero-length file never-reread now.  */
       if (S_ISREG (file->st.st_mode) && file->st.st_size == 0)
-       file->cmacro = NEVER_REREAD;
+        {
+         file->cmacro = NEVER_REREAD;
+         close (file->fd);
+         file->fd = -1;
+       }
 
       return file;
     }