summaryrefslogtreecommitdiffstats
path: root/stdlib
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-07-25 18:17:55 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-07-25 18:17:55 -0700
commit0f5fbbe6f79823161ca3d921255dd0f234868e02 (patch)
treeab3819b77aa6e7b1d7d5a4b434c34cc8e8530ddc /stdlib
parentd3484b08d309198ce1ed4181a81fa04057ecedbb (diff)
downloadtxr-0f5fbbe6f79823161ca3d921255dd0f234868e02.tar.gz
txr-0f5fbbe6f79823161ca3d921255dd0f234868e02.tar.bz2
txr-0f5fbbe6f79823161ca3d921255dd0f234868e02.zip
rel-path: treat empty paths as relative.
* stdlib/path-test.tl (path-volume): Don't return :abs for a path whose empty first component isn't followed by any more items. Otherwise we return :abs for a path formed by splitting the empty string, and then calls like (rel-path "" "a") complain about a mixture of absolute and relative. With this change, empty paths given to rel-path behave as if they were ".". * tests/018/rel-path.tl: New test cases.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/path-test.tl8
1 files changed, 4 insertions, 4 deletions
diff --git a/stdlib/path-test.tl b/stdlib/path-test.tl
index 491f63af..b7e75018 100644
--- a/stdlib/path-test.tl
+++ b/stdlib/path-test.tl
@@ -301,9 +301,9 @@
(let ((vol (car more)))
(cond
((nequal "" vol)
- (set (car comp) "")
- (set (cdr comp) (cdr more))
- vol)
+ (set (car comp) "")
+ (set (cdr comp) (cdr more))
+ vol)
(t :abs))))
((and (m^ #/[A-Za-z0-9]+:/ head) head)
(set (car comp) next)
@@ -311,7 +311,7 @@
(if (and (equal "" next) more)
^(:abs . ,head)
^(:rel . ,head)))))
- (if (equal head "") :abs))))
+ (if (and (equal head "") (cdr comp)) :abs))))
(defun rel-path (from to)
(let* ((fspl (path-split from))