Permit consecutive slashes in Unix namestrings.
authorTaylor R Campbell <campbell@mumble.net>
Mon, 9 May 2011 04:05:50 +0000 (04:05 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Mon, 9 May 2011 04:05:50 +0000 (04:05 +0000)
POSIX sez it's kosher:

<http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_266>

I don't know any Unix that treats two leading slashes differently, so
I won't reject that case.  However, maybe the pathname abstraction
needs to handle it differently if there are such Unices.

src/runtime/unxpth.scm

index e5d806494efb6c1ca1940627e1a2f60e40d61ae5..6e3a55147712676ebdd10495f0365ba1aadb34fb 100644 (file)
@@ -78,15 +78,8 @@ USA.
   (let ((string (car components))
        (replace-head
         (lambda (string)
-          ;; If STRING has a trailing slash, and it's followed by a
-          ;; slash, drop the trailing slash to avoid doubling.
-          (let ((head (string-components string #\/)))
-            (append (if (and (pair? (cdr components))
-                             (pair? (cdr head))
-                             (string-null? (car (last-pair head))))
-                        (except-last-pair head)
-                        head)
-                    (cdr components))))))
+          (append (string-components string #\/)
+                  (cdr components)))))
     (let ((end (string-length string)))
       (if (or (= 0 end)
              (not *expand-directory-prefixes?*))
@@ -118,9 +111,8 @@ USA.
       directory))
 
 (define (parse-directory-components components)
-  (if (there-exists? components string-null?)
-      (error "Directory contains null component:" components))
-  (map parse-directory-component components))
+  (map parse-directory-component
+       (delete-matching-items components string-null?)))
 
 (define (parse-directory-component component)
   (if (string=? ".." component)