Commit 55485cd9 by Zack Weinberg Committed by Zack Weinberg

cppfiles.c (open_file): If we've opened a directory by mistake, close it.

	* cppfiles.c (open_file): If we've opened a directory by
	mistake, close it.
	(find_include_file): Avoid turning / into // or // into ///.

From-SVN: r47722
parent e04546dc
2001-12-06 Zack Weinberg <zack@codesourcery.com>
* cppfiles.c (open_file): If we've opened a directory by
mistake, close it.
(find_include_file): Avoid turning / into // or // into ///.
2001-12-06 Nick Clifton <nickc@cambridge.redhat.com> 2001-12-06 Nick Clifton <nickc@cambridge.redhat.com>
* config/arm/arm.h (STRUCT_VALUE): Suppress definition. * config/arm/arm.h (STRUCT_VALUE): Suppress definition.
......
...@@ -259,10 +259,13 @@ open_file (pfile, filename) ...@@ -259,10 +259,13 @@ open_file (pfile, filename)
{ {
if (!S_ISDIR (file->st.st_mode)) if (!S_ISDIR (file->st.st_mode))
return file; return file;
/* If it's a directory, we return null and continue the search /* If it's a directory, we return null and continue the search
as the file we're looking for may appear elsewhere in the as the file we're looking for may appear elsewhere in the
search path. */ search path. */
errno = ENOENT; errno = ENOENT;
close (file->fd);
file->fd = -1;
} }
file->err_no = errno; file->err_no = errno;
...@@ -556,9 +559,14 @@ find_include_file (pfile, header, type) ...@@ -556,9 +559,14 @@ find_include_file (pfile, header, type)
name = (char *) alloca (strlen (fname) + pfile->max_include_len + 2); name = (char *) alloca (strlen (fname) + pfile->max_include_len + 2);
for (; path; path = path->next) for (; path; path = path->next)
{ {
memcpy (name, path->name, path->len); int len = path->len;
name[path->len] = '/'; memcpy (name, path->name, len);
strcpy (&name[path->len + 1], fname); /* 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)) if (CPP_OPTION (pfile, remap))
n = remap_filename (pfile, name, path); n = remap_filename (pfile, name, path);
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment