From: hniksic Date: Mon, 10 Dec 2001 02:12:17 +0000 (-0800) Subject: [svn] Minor fix for path_simplify. X-Git-Tag: v1.13~1912 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=997a87548c84008744f503c987ba4a3ef10351af [svn] Minor fix for path_simplify. Submitted in . --- diff --git a/src/ChangeLog b/src/ChangeLog index 6be54d17..9227af03 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-12-10 Hrvoje Niksic + + * utils.c (path_simplify): Correctly handle the unlikely case that + b starts out as path + 1. + 2001-12-10 Hrvoje Niksic * utils.c (path_simplify): Rewrite, with better comments, and diff --git a/src/utils.c b/src/utils.c index fd283710..a245b5c2 100644 --- a/src/utils.c +++ b/src/utils.c @@ -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--) ; }