aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppfiles.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2000-11-03 16:03:37 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2000-11-03 16:03:37 +0000
commitdef3263a3364034c8cd6cd865975529f9fd80e69 (patch)
treeb3e2c442f061fc7379989b80f9d5ee2b7118618f /gcc/cppfiles.c
parent30235724a2cd237a613883e9c4149f979acb91ea (diff)
downloadgcc-def3263a3364034c8cd6cd865975529f9fd80e69.zip
gcc-def3263a3364034c8cd6cd865975529f9fd80e69.tar.gz
gcc-def3263a3364034c8cd6cd865975529f9fd80e69.tar.bz2
cppfiles.c (open_file): If already read, then don't reopen.
* cppfiles.c (open_file): If already read, then don't reopen. Immediately close an empty file. From-SVN: r37227
Diffstat (limited to 'gcc/cppfiles.c')
-rw-r--r--gcc/cppfiles.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c
index 1009fa7..47bf43f 100644
--- a/gcc/cppfiles.c
+++ b/gcc/cppfiles.c
@@ -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;
}