diff options
author | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-12-06 16:41:18 +0000 |
---|---|---|
committer | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-12-06 16:41:18 +0000 |
commit | 774cb7b5eb253312ef28b947377cd38e0b0f96d2 (patch) | |
tree | 0d732847c41a7f64f41db7e360c701d3912d271a /gcc/cppfiles.c | |
parent | 7ac9f710dbe0ffb9cf23e984f403e25aca975010 (diff) | |
download | ppe42-gcc-774cb7b5eb253312ef28b947377cd38e0b0f96d2.tar.gz ppe42-gcc-774cb7b5eb253312ef28b947377cd38e0b0f96d2.zip |
* cppfiles.c (open_file): If we've opened a directory by
mistake, close it.
(find_include_file): Avoid turning / into // or // into ///.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@47722 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cppfiles.c')
-rw-r--r-- | gcc/cppfiles.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index 52c095f28fc..33801d610a6 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -259,10 +259,13 @@ open_file (pfile, filename) { if (!S_ISDIR (file->st.st_mode)) return file; + /* If it's a directory, we return null and continue the search as the file we're looking for may appear elsewhere in the search path. */ errno = ENOENT; + close (file->fd); + file->fd = -1; } file->err_no = errno; @@ -556,9 +559,14 @@ find_include_file (pfile, header, type) name = (char *) alloca (strlen (fname) + pfile->max_include_len + 2); for (; path; path = path->next) { - memcpy (name, path->name, path->len); - name[path->len] = '/'; - strcpy (&name[path->len + 1], fname); + int len = path->len; + memcpy (name, path->name, len); + /* Don't turn / into // or // into ///; // may be a namespace + escape. */ + if (name[len-1] == '/') + len--; + name[len] = '/'; + strcpy (&name[len + 1], fname); if (CPP_OPTION (pfile, remap)) n = remap_filename (pfile, name, path); else |