aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-09-10 17:16:46 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-09-11 19:58:54 +0200
commit72361e8c3aa8a33e1ea71e2fe081362670940fb7 (patch)
treefe1ec530fdbc37b594e050384941c4683c0c3733
parentSplit test/util.scm into groups. (diff)
downloadcalp-72361e8c3aa8a33e1ea71e2fe081362670940fb7.tar.gz
calp-72361e8c3aa8a33e1ea71e2fe081362670940fb7.tar.xz
Require component for path append.
Changed the signature of `path-append` to require at least one argument. The alternative would have been that no components expands into '.'.
-rw-r--r--doc/ref/guile/util-path.texi2
-rw-r--r--module/hnh/util/path.scm10
-rw-r--r--tests/test/util.scm2
3 files changed, 5 insertions, 9 deletions
diff --git a/doc/ref/guile/util-path.texi b/doc/ref/guile/util-path.texi
index cf99a170..384915ef 100644
--- a/doc/ref/guile/util-path.texi
+++ b/doc/ref/guile/util-path.texi
@@ -8,7 +8,7 @@ Provided by the module @code{(hnh util path)}.
Alias of @code{absolute-file-name?} from Guile.
@end defun
-@defun path-append strings ...
+@defun path-append path paths ...
Joins all strings into a path, squeezing duplicated delimiters, but
ensuring that all delimiters that are needed are there.
diff --git a/module/hnh/util/path.scm b/module/hnh/util/path.scm
index d22e8242..b92de8cd 100644
--- a/module/hnh/util/path.scm
+++ b/module/hnh/util/path.scm
@@ -18,7 +18,7 @@
;; TODO remove intermidiate period components
;; e.x. /a/../b => /b
-(define (path-append . strings)
+(define (path-append path . paths)
(fold (lambda (s done)
(string-append
done
@@ -34,11 +34,9 @@
;; the path absolute. This isn't exactly correct if we have
;; drive letters, but on those system the user should make
;; sure that the first component of the path is non-empty.
- (let ((s (car strings)))
- (if (string-null? s)
- // s))
- (cdr strings)
- ))
+ (if (string-null? path)
+ // path)
+ paths))
(define (path-join lst) (apply path-append lst))
diff --git a/tests/test/util.scm b/tests/test/util.scm
index 81bebdb5..75d59801 100644
--- a/tests/test/util.scm
+++ b/tests/test/util.scm
@@ -280,8 +280,6 @@
(test-equal "root" "/" (path-append ""))
- (test-equal "No components" "" (path-append))
-
(test-equal
'("usr" "lib" "test")
(path-split "usr/lib/test"))