]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
prefix.c (update_path): Don't strip single `.' path components unless stripping a...
authorAlan Modra <amodra@bigpond.net.au>
Sun, 28 Jul 2002 09:01:09 +0000 (09:01 +0000)
committerAlan Modra <amodra@gcc.gnu.org>
Sun, 28 Jul 2002 09:01:09 +0000 (18:31 +0930)
* prefix.c (update_path): Don't strip single `.' path components
unless stripping a later `..' component.  Exit loop as soon as
a valid path is found.

From-SVN: r55814

gcc/ChangeLog
gcc/prefix.c

index 22d5237c12511235e920d67588a44e1eae874155..8ab4daf1090dc53c31a671016b0105b74ba1ffe7 100644 (file)
@@ -1,3 +1,9 @@
+2002-07-28  Alan Modra  <amodra@bigpond.net.au>
+
+       * prefix.c (update_path): Don't strip single `.' path components
+       unless stripping a later `..' component.  Exit loop as soon as
+       a valid path is found.
+
 2002-07-27  Roger Sayle  <roger@eyesopen.com>
 
        * builtins.def [DEF_GCC_BUILTIN]: Require an explicit ATTRS
index 18f79987a34e8284b1e87f4ee5a1d03cbe4b1449..06930fee2ab1bfdc35c3f2aa4bf815758020e524 100644 (file)
@@ -284,49 +284,39 @@ update_path (path, key)
       p = strchr (p, '.');
       if (p == NULL)
        break;
-      /* Get rid of a leading `./' and replace `/./' with `/', when
-        such components are followed with another `.'.  */
-      if (IS_DIR_SEPARATOR (p[1])
-         && (p == result || IS_DIR_SEPARATOR (p[-1])))
-       {
-         src = p + 2;
-         /* Be careful about .//foo  */
-         while (IS_DIR_SEPARATOR (*src))
-           ++src;
-         if (*src == '.')
-           {
-             dest = p;
-             while ((*dest++ = *src++) != 0)
-               ;
-           }
-         else
-           ++p;
-       }
       /* Look for `/../'  */
-      else if (p[1] == '.'
-              && IS_DIR_SEPARATOR (p[2])
-              && (p != result && IS_DIR_SEPARATOR (p[-1])))
+      if (p[1] == '.'
+         && IS_DIR_SEPARATOR (p[2])
+         && (p != result && IS_DIR_SEPARATOR (p[-1])))
        {
          *p = 0;
          if (!ALWAYS_STRIP_DOTDOT && access (result, X_OK) == 0)
            {
              *p = '.';
-             p += 3;
+             break;
            }
          else
            {
              /* We can't access the dir, so we won't be able to
-                access dir/.. either.  Strip out dir/..  We know dir
-                isn't `.' because we've rid ourselves of `.' path
-                components above.  */
-             dest = p - 1;
-             while (dest != result && IS_DIR_SEPARATOR (*dest))
-               --dest;
-             while (dest != result && !IS_DIR_SEPARATOR (dest[-1]))
-               --dest;
-             /* Don't strip leading `/'.  */
-             while (IS_DIR_SEPARATOR (*dest))
-               ++dest;
+                access dir/.. either.  Strip out `dir/../'.  If `dir'
+                turns out to be `.', strip one more path component.  */
+             dest = p;
+             do
+               {
+                 --dest;
+                 while (dest != result && IS_DIR_SEPARATOR (*dest))
+                   --dest;
+                 while (dest != result && !IS_DIR_SEPARATOR (dest[-1]))
+                   --dest;
+               }
+             while (dest != result && *dest == '.');
+             /* If we have something like `./..' or `/..', don't
+                strip anything more.  */
+             if (*dest == '.' || IS_DIR_SEPARATOR (*dest))
+               {
+                 *p = '.';
+                 break;
+               }
              src = p + 3;
              while (IS_DIR_SEPARATOR (*src))
                ++src;