From: hniksic Date: Tue, 4 Dec 2001 23:42:18 +0000 (-0800) Subject: [svn] Doc fix. X-Git-Tag: v1.13~1948 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=eef4527c2406eb009b4f0f79e32f429c9e07fbd8 [svn] Doc fix. --- diff --git a/src/ChangeLog b/src/ChangeLog index 8e6ec091..6b8d465c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2001-12-05 Hrvoje Niksic + + * utils.c (path_simplify): Document with test cases. + +2001-12-04 Hrvoje Niksic + + * gen_sslfunc.c: Ditto. + + * rbuf.c: Include . + 2001-12-04 Hrvoje Niksic * recur.c (retrieve_tree): Check whether the URL was already diff --git a/src/gen_sslfunc.c b/src/gen_sslfunc.c index f32e7d80..4a9ebd17 100644 --- a/src/gen_sslfunc.c +++ b/src/gen_sslfunc.c @@ -27,6 +27,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef HAVE_UNISTD_H # include #endif +#ifdef HAVE_STRING_H +# include +#else +# include +#endif #include #include diff --git a/src/rbuf.c b/src/rbuf.c index 9931998c..43d636e3 100644 --- a/src/rbuf.c +++ b/src/rbuf.c @@ -22,6 +22,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include +#ifdef HAVE_STRING_H +# include +#else +# include +#endif #include "wget.h" #include "rbuf.h" diff --git a/src/utils.c b/src/utils.c index b98ca9bd..3c13e67f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -487,15 +487,21 @@ ps (char *orig) Non-leading `../'s and trailing `..'s are handled by removing portions of the path. - E.g. "a/b/c/./../d/.." will yield "a/b". This function originates - from GNU Bash. + E.g. "a/b/c/./../d/.." will yield "a/b/". This function originates + from GNU Bash and has been mutilated to unrecognition for use in + Wget. Changes for Wget: Always use '/' as stub_char. Don't check for local things using canon_stat. Change the original string instead of strdup-ing. React correctly when beginning with `./' and `../'. - Don't zip out trailing slashes. */ + Don't zip out trailing slashes. + Return a value indicating whether any modifications took place. + + If you dare change this function, take a careful look at the test + cases below, and make sure that they pass. */ + int path_simplify (char *path) { @@ -600,6 +606,28 @@ path_simplify (char *path) return changes; } + +/* Test cases: + ps("") -> "" + ps("/") -> "/" + ps(".") -> "" + ps("..") -> "" + ps("/.") -> "/" + ps("/..") -> "/" + ps("foo") -> "foo" + ps("foo/bar") -> "foo/bar" + ps("foo//bar") -> "foo/bar" (possibly a bug) + ps("foo/../bar") -> "bar" + ps("foo/bar/..") -> "foo/" + ps("foo/bar/../x") -> "foo/x" + ps("foo/bar/../x/") -> "foo/x/" + ps("foo/..") -> "" + ps("/foo/..") -> "/" + ps("a/b/../../c") -> "c" + ps("/a/b/../../c") -> "/c" + ps("./a/../b") -> "b" + ps("/./a/../b") -> "/b" +*/ /* "Touch" FILE, i.e. make its atime and mtime equal to the time specified with TM. */