From 997a87548c84008744f503c987ba4a3ef10351af Mon Sep 17 00:00:00 2001 From: hniksic Date: Sun, 9 Dec 2001 18:12:17 -0800 Subject: [PATCH] [svn] Minor fix for path_simplify. Submitted in . --- src/ChangeLog | 5 +++++ src/utils.c | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) 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--) ; } -- 2.39.2