From caf4c45e16ed7294daf7f13582b789825e97a76a Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 3 May 2024 21:23:06 -0700 Subject: 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. --- eval.c | 9 +++++---- 1 file 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)) { -- cgit v1.2.3