From def3263a3364034c8cd6cd865975529f9fd80e69 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Fri, 3 Nov 2000 16:03:37 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 5 +++++ gcc/cppfiles.c | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d2414dcb317..0ad0e517bce 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2000-11-03 Nathan Sidwell + + * cppfiles.c (open_file): If already read, then don't reopen. + Immediately close an empty file. + 2000-11-01 Bernd Schmidt * expr.h (fold_builtin): Move declaration... diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index 1009fa784a1..47bf43f211f 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; }