 index 000000000..c66df924b
 --- /dev/null
 +++ b/lib/pathtools.c
-@@ -0,0 +1,539 @@
+@@ -0,0 +1,533 @@
 +/*
 +      .Some useful path tools.
 +        .ASCII only for now.

+  size_t in_size = strlen (path);
+  int it_ended_with_a_slash = (path[in_size - 1] == '/') ? 1 : 0;
+  char * result = path;
+  char * result_p;
+  char const ** toks;
+  if (path[0] == '/' && path[1] == '/') {
+    /* preserve UNC path */
+    path++;
+    in_size--;
+    result++;
+  }
+  sanitise_path(result);
+  char * result_p = result;
+

+    *path_p = '/';
+  }
+  /* Replace any '//' with '/' */
+  path_p = path;
+  while ((path_p = strstr (path_p, "//")) != NULL)
+  {
+    memmove (path_p, path_p + 1, path_size--);
