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  <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
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 <unistd.h>
 #endif
+#ifdef HAVE_STRING_H
+# include <string.h>
+#else
+# include <strings.h>
+#endif
 
 #include <openssl/bio.h>
 #include <openssl/crypto.h>
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 <config.h>
 
 #include <stdio.h>
+#ifdef HAVE_STRING_H
+# include <string.h>
+#else
+# include <strings.h>
+#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.  */