summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib.c24
-rw-r--r--txr.112
2 files changed, 29 insertions, 7 deletions
diff --git a/lib.c b/lib.c
index e3f63386..de78d8a9 100644
--- a/lib.c
+++ b/lib.c
@@ -3845,7 +3845,18 @@ val cat_str(val list, val sep)
cnum total = 0;
val iter;
wchar_t *str, *ptr;
- cnum len_sep = (!null_or_missing_p(sep)) ? c_num(length_str(sep)) : 0;
+ wchar_t onech[] = wini(" ");
+ cnum len_sep;
+
+ if (null_or_missing_p(sep)) {
+ len_sep = 0;
+ } else if (chrp(sep)) {
+ onech[0] = c_chr(sep);
+ len_sep = 1;
+ sep = auto_str(coerce(const wchli_t *, wref(onech)));
+ } else {
+ len_sep = c_num(length_str(sep));
+ }
for (iter = list; iter != nil; iter = cdr(iter)) {
val item = car(iter);
@@ -4018,7 +4029,16 @@ val split_str_keep(val str, val sep, val keep_sep)
return out;
} else {
- size_t len_sep = c_num(length_str(sep));
+ size_t len_sep;
+ wchar_t onech[] = wini(" ");
+
+ if (chrp(sep)) {
+ onech[0] = c_chr(sep);
+ len_sep = 1;
+ sep = auto_str(coerce(const wchli_t *, wref(onech)));
+ } else {
+ len_sep = c_num(length_str(sep));
+ }
if (len_sep == 0) {
if (opt_compat && opt_compat <= 100) {
diff --git a/txr.1 b/txr.1
index ad3b2ee7..51c0f39f 100644
--- a/txr.1
+++ b/txr.1
@@ -22030,7 +22030,7 @@ function.
.coNP Function @ cat-str
.synb
-.mets (cat-str < string-list <> [ sep-string ])
+.mets (cat-str < string-list <> [ sep ])
.syne
.desc
The
@@ -22039,9 +22039,10 @@ function catenates a list of strings given by
.meta string-list
into a
single string. The optional
-.meta sep-string
-argument specifies a separator string
+.meta sep
+argument specifies a separator
which is interposed between the catenated strings.
+It must be either a character or a string.
.coNP Function @ split-str
.synb
@@ -22055,8 +22056,9 @@ function breaks the
into pieces, returning a list
thereof. The
.meta sep
-argument must be either a string or a regular expression.
-It specifies the separator character sequence within
+argument must be one of three types: a string, a character
+or a regular expression. It determines the separator character
+sequences within
.metn string .
All non-overlapping matches for