]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cppfiles.c (open_file): If we've opened a directory by mistake, close it.
authorZack Weinberg <zack@codesourcery.com>
Thu, 6 Dec 2001 16:41:18 +0000 (16:41 +0000)
committerZack Weinberg <zack@gcc.gnu.org>
Thu, 6 Dec 2001 16:41:18 +0000 (16:41 +0000)
* 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

gcc/ChangeLog
gcc/cppfiles.c

index 88235dfc38386f70919d1a16496153b40abd78a6..5b22f74531662082ceced8541645736591c721e0 100644 (file)
@@ -1,3 +1,9 @@
+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>
 
        * config/arm/arm.h (STRUCT_VALUE): Suppress definition.
index 52c095f28fcc846e21c55ac6e8aca9c734d75418..33801d610a64463b7ad835440c03dac85b9c29af 100644 (file)
@@ -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