One of my programs kinda relies on make-pathname returning "canonical"
paths.  I noticed that, on Chicken 2.3,

  (make-pathname "" "foo")

returns "/foo" instead of "foo", which was what I was expecting.  I
wasn't expecting (cut make-pathname "" <>) to return an absolute path.
That has forced me to add that check and write

  (make-pathname (and (not (string=? dir "")) dir) file)

instead of (make-pathname dir file).  Similarly,

  (make-pathname '("foo" "" "bar") "yes")

returns "foo//bar/yes" (notice the consecutive slashes).  Attached is
an untested patch (against 2.3) that changes this behaviour, only
appending a slash when it is really needed.

Alejo.
http://azul.freaks-unidos.net/
--- chicken-2.3/utils.scm       2006-02-17 12:54:04.000000000 -0500
+++ chicken-2.3-alejo/utils.scm 2006-06-10 12:10:56.000000000 -0500
@@ -109,9 +109,10 @@
   (define (conc-dirs dirs)
     (##sys#check-list dirs 'make-pathname)
     (let loop ([strs dirs])
-      (if (null? strs)
-         ""
-         (string-append (chop-pds (car strs)) pds (loop (cdr strs))) ) ) )
+      (cond
+       ((null? strs) "")
+       ((string=? (car strs) "") (loop (cdr strs)))
+       (else (string-append (chop-pds (car strs)) pds (loop (cdr strs)))) ) ) )
   (define (_make-pathname dir file . ext)
     (let ([dirs (cond [(or (not dir) (null? dir)) ""]
                      [(string? dir) (conc-dirs (list dir))]
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to