]> sjero.net Git - wget/commitdiff
[svn] Doc fix.
authorhniksic <devnull@localhost>
Tue, 4 Dec 2001 23:42:18 +0000 (15:42 -0800)
committerhniksic <devnull@localhost>
Tue, 4 Dec 2001 23:42:18 +0000 (15:42 -0800)
src/ChangeLog
src/gen_sslfunc.c
src/rbuf.c
src/utils.c

index 8e6ec091c17aae27950b1019e8231cea423196f6..6b8d465cf7b3fb34f0bdf98a901f4819ad5e1ab2 100644 (file)
@@ -1,3 +1,13 @@
+2001-12-05  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * utils.c (path_simplify): Document with test cases.
+
+2001-12-04  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * gen_sslfunc.c: Ditto.
+
+       * rbuf.c: Include <string.h>.
+
 2001-12-04  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * recur.c (retrieve_tree): Check whether the URL was already
index f32e7d80ca7b1a1d67a59ff170b1c9e919bd781d..4a9ebd1717c3e78ab625b3cba380b45d71bf672f 100644 (file)
@@ -27,6 +27,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
+#ifdef HAVE_STRING_H
+# include <string.h>
+#else
+# include <strings.h>
+#endif
 
 #include <openssl/bio.h>
 #include <openssl/crypto.h>
index 9931998c917adf9c0ee5bc11cac217eb86c92bda..43d636e3532d19c5840d0c3d140cd03d6dee400d 100644 (file)
@@ -22,6 +22,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <config.h>
 
 #include <stdio.h>
+#ifdef HAVE_STRING_H
+# include <string.h>
+#else
+# include <strings.h>
+#endif
 
 #include "wget.h"
 #include "rbuf.h"
index b98ca9bdbe8f9df80abefdf67ca26bd5b2ba00d9..3c13e67f5a03bf2c63da7deb7dc2b27b8327837a 100644 (file)
@@ -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"
+*/
 \f
 /* "Touch" FILE, i.e. make its atime and mtime equal to the time
    specified with TM.  */