summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-05-03 21:23:06 -0700
committerKaz Kylheku <kaz@kylheku.com>2024-05-03 21:23:06 -0700
commit5b3398c05bfdb7dcb448d66814256b509e45b7e5 (patch)
tree8910b9dba10250145c65f58916cc602d0e417801 /eval.c
parent5da9e32de83f6fb0f983fd5e893e6ba41e2f1446 (diff)
downloadtxr-5b3398c05bfdb7dcb448d66814256b509e45b7e5.tar.gz
txr-5b3398c05bfdb7dcb448d66814256b509e45b7e5.tar.bz2
txr-5b3398c05bfdb7dcb448d66814256b509e45b7e5.zip
quasilit: move separator defaulting to fmt_cat.
The motivation here is an upcoming change in which we will support the separator modifier for buffers and strings. Currently, it does nothing. If we write `@{a ":"}`, and a is a buffer or string, the separator is ignored. We don't fix that in this commit, but we fix the problem that some higher level formatting functions are defaulting the separator to " " (single space) and passing it down. We want to control the defaulting based on the type of the object in one place. * eval.c (fmt_cat): Do not assume here that sep has been defaulted; do the defaulting to space here. (format_field, fmt_flex): Initialize the separator to nil, not space. If no separator occurs among the modifiers, it gets passed down as nil through to fmt_cat. (fmt_simple): Don't default the sep argument to space; pass it through to do_format_field which will pass it down to fmt_cat.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/eval.c b/eval.c
index f4056e6f..eef6ba44 100644
--- a/eval.c
+++ b/eval.c
@@ -2990,7 +2990,8 @@ static val fmt_cat(val obj, val sep)
/* fallthrough */
default:
return if3(if3(opt_compat && opt_compat <= 174, listp(obj), seqp(obj)),
- cat_str(mapcar(func_n1(tostringp), obj), sep),
+ cat_str(mapcar(func_n1(tostringp), obj),
+ default_arg(sep, lit(" "))),
tostringp(obj));
}
}
@@ -3053,7 +3054,7 @@ static val do_format_field(val obj, val n, val sep,
val format_field(val obj, val modifier, val filter, val eval_fun)
{
- val n = zero, sep = lit(" ");
+ val n = zero, sep = nil;
val plist = nil;
val range_ix = nil;
@@ -3101,7 +3102,7 @@ static val fmt_simple(val obj, val n, val sep,
{
return do_format_field(fmt_tostring(obj),
default_arg(n, zero),
- default_arg(sep, lit(" ")),
+ sep,
default_null_arg(range_ix),
default_null_arg(plist),
nil);
@@ -3110,7 +3111,7 @@ static val fmt_simple(val obj, val n, val sep,
static val fmt_flex(val obj, val plist, varg args)
{
cnum ix = 0;
- val n = zero, sep = lit(" ");
+ val n = zero, sep = nil;
val range_ix = nil;
while (args_more(args, ix)) {