Submitted in <sxsheqzx1qv.fsf@florida.arsdigita.de>.
+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
{
/* 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. */
/* ^ 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--)
;
}