]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/22133 (In MinGW trailing slash forward not allowed in include path)
authorDanny Smith <dannysmith@users.sourceforge.net>
Mon, 7 May 2007 17:41:35 +0000 (17:41 +0000)
committerNathan Froyd <froydnj@gcc.gnu.org>
Mon, 7 May 2007 17:41:35 +0000 (17:41 +0000)
PR 22133
* c-incpath.c (add_path): Strip trailing path separators.

From-SVN: r124504

gcc/ChangeLog
gcc/c-incpath.c

index ee9e51a10f6566cf1b9b637af951908bf6d16f5b..df4aa2f550861d266ef6fe8c0513bbc92c28aff4 100644 (file)
@@ -1,3 +1,9 @@
+2007-05-07  Danny Smith  <dannysmith@users.sourceforge.net>
+           Nathan Froyd  <froydnj@codesourcery.com
+
+       PR 22133
+       * c-incpath.c (add_path): Strip trailing path separators.
+
 2007-05-07  Eric Botcazou  <ebotcazou@adacore.com>
 
        * tree-ssa-dom.c (tree_ssa_dominator_optimize): Reset cfg_altered.
index 3e819cec8380f8d8490436d649b9f3b51d13dac1..8b6512c8e0f082ef70e9b70faf760af0939674a3 100644 (file)
@@ -389,13 +389,18 @@ add_path (char *path, int chain, int cxx_aware, bool user_supplied_p)
   cpp_dir *p;
 
 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
-  /* Convert all backslashes to slashes.  The native CRT stat()
-     function does not recognize a directory that ends in a backslash
-     (unless it is a drive root dir, such "c:\").  Forward slashes,
-     trailing or otherwise, cause no problems for stat().  */
-  char* c;
-  for (c = path; *c; c++)
-    if (*c == '\\') *c = '/';
+  /* Remove unnecessary trailing slashes.  On some versions of MS
+     Windows, trailing  _forward_ slashes cause no problems for stat().
+     On newer versions, stat() does not recognise a directory that ends
+     in a '\\' or '/', unless it is a drive root dir, such as "c:/",
+     where it is obligatory.  */
+  int pathlen = strlen (path);
+  char* end = path + pathlen - 1;
+  /* Preserve the lead '/' or lead "c:/".  */
+  char* start = path + (pathlen > 2 && path[1] == ':' ? 3 : 1);
+  
+  for (; end > start && IS_DIR_SEPARATOR (*end); end--)
+    *end = 0;
 #endif
 
   p = XNEW (cpp_dir);