]> sjero.net Git - wget/commitdiff
[svn] Minor fix for path_simplify.
authorhniksic <devnull@localhost>
Mon, 10 Dec 2001 02:12:17 +0000 (18:12 -0800)
committerhniksic <devnull@localhost>
Mon, 10 Dec 2001 02:12:17 +0000 (18:12 -0800)
Submitted in <sxsheqzx1qv.fsf@florida.arsdigita.de>.

src/ChangeLog
src/utils.c

index 6be54d17844671baa9540a3b0a521404d04686e7..9227af030d47e77ac0021709b9f6d38bbc065658 100644 (file)
@@ -1,3 +1,8 @@
+2001-12-10  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * utils.c (path_simplify): Correctly handle the unlikely case that
+       b starts out as path + 1.
+
 2001-12-10  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * utils.c (path_simplify): Rewrite, with better comments, and
index fd283710796a1003baa75e2067d0cd174ca3e8ad..a245b5c2fc7ee8dc326e4cead1b99c0adceeb02f 100644 (file)
@@ -528,7 +528,7 @@ path_simplify (char *path)
        {
          /* Handle "../foo" by moving "foo" one path element to the
             left.  */
-         char *b = p;
+         char *b = p;          /* not p-1 because P can equal PATH */
 
          /* Backtrack by one path element, but not past the beginning
             of PATH. */
@@ -537,10 +537,10 @@ path_simplify (char *path)
          /*         ^ p    */
          /*     ^ b        */
 
-         if (b > path + 1)
+         if (b > path)
            {
-             /* Find the character preceded by slash or by the
-                beginning of path. */
+             /* Move backwards until B hits the beginning of the
+                previous path element or the beginning of path. */
              for (--b; b > path && *(b - 1) != '/'; b--)
                ;
            }