mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-08 13:37:35 +02:00
make-path should preserve a path containing just "/"
This commit is contained in:
parent
9651f7456c
commit
90dbe1fdd2
2 changed files with 11 additions and 2 deletions
|
@ -216,12 +216,15 @@
|
||||||
(substring-cursor s 0 (string-skip-right s #\/)))
|
(substring-cursor s 0 (string-skip-right s #\/)))
|
||||||
(if (null? args)
|
(if (null? args)
|
||||||
""
|
""
|
||||||
(let ((start (trim-trailing-slash (x->string (car args)))))
|
(let* ((args0 (x->string (car args)))
|
||||||
|
(start (trim-trailing-slash args0)))
|
||||||
(let lp ((ls (cdr args))
|
(let lp ((ls (cdr args))
|
||||||
(res (if (string=? "" start) '() (list start))))
|
(res (if (string=? "" start) '() (list start))))
|
||||||
(cond
|
(cond
|
||||||
((null? ls)
|
((null? ls)
|
||||||
(string-join (reverse res)))
|
(if (and (null? res) (not (string=? "" args0)))
|
||||||
|
"/"
|
||||||
|
(string-join (reverse res))))
|
||||||
((pair? (car ls))
|
((pair? (car ls))
|
||||||
(lp (append (car ls) (cdr ls)) res))
|
(lp (append (car ls) (cdr ls)) res))
|
||||||
(else
|
(else
|
||||||
|
|
|
@ -194,5 +194,11 @@
|
||||||
(test "a/b/./c" (make-path "a" "b" "." "c"))
|
(test "a/b/./c" (make-path "a" "b" "." "c"))
|
||||||
(test "a/b/../c" (make-path "a" "b" ".." "c"))
|
(test "a/b/../c" (make-path "a" "b" ".." "c"))
|
||||||
(test "a/b/c" (make-path "a" '("b" "c")))
|
(test "a/b/c" (make-path "a" '("b" "c")))
|
||||||
|
(test "/" (make-path "/" ""))
|
||||||
|
(test "/" (make-path "/" "/"))
|
||||||
|
(test "/." (make-path "/" "."))
|
||||||
|
(test "/a" (make-path "/a" ""))
|
||||||
|
(test "/a" (make-path "/a" "/"))
|
||||||
|
(test "/a/." (make-path "/a" "."))
|
||||||
|
|
||||||
(test-end)
|
(test-end)
|
||||||
|
|
Loading…
Add table
Reference in a new issue