summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib.c3
-rw-r--r--tests/015/split.tl23
2 files changed, 25 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 95db82e4..7eb29a3e 100644
--- a/lib.c
+++ b/lib.c
@@ -5047,8 +5047,9 @@ val join_with(val sep, struct args *args)
val iter;
int more;
struct cat_str cs;
+ wchar_t onech[] = wini(" ");
- cat_str_init(&cs, sep, 0, self);
+ cat_str_init(&cs, sep, wref(onech), self);
for (index = 0, iter = args->list, more = args_more_nozap(args, index, iter);
more;)
diff --git a/tests/015/split.tl b/tests/015/split.tl
index ae77a642..e54092c5 100644
--- a/tests/015/split.tl
+++ b/tests/015/split.tl
@@ -194,3 +194,26 @@
(mtest
(tok-str "abcacabcac" #/ab?/) #"ab a ab a"
(tok-str "abcacabcac" #/ab?/ t) ("" "ab" "c" "a" "c" "ab" "c" "a" "c"))
+
+(mtest
+ (join) ""
+ (join "") ""
+ (join "" "") ""
+ (join #\a) "a"
+ (join "a") "a"
+ (join #\a "b") "ab"
+ (join "a" #\b) "ab"
+ (join #\a #\b) "ab"
+ (join "a" "b") "ab"
+ (join "a" "b" "cde") "abcde")
+
+(mtest
+ (join-with #\a) ""
+ (join-with #\a #\b) "b"
+ (join-with #\a "b") "b"
+ (join-with "a") ""
+ (join-with "a" #\b) "b"
+ (join-with "a" "b") "b"
+ (join-with "a" "b") "b"
+ (join-with "--" "b" "c" "d") "b--c--d"
+ (join-with #\- "b" "c" "d") "b-c-d")