summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-08-02 06:36:39 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-08-02 06:36:39 -0700
commitf928e5ca648990aa63624828376f18462cae9eed (patch)
treebc8798649e23167b535ef694c3c4ed599c64008f
parent7247b05209f7669a8c9021675d411a3de8124606 (diff)
downloadtxr-f928e5ca648990aa63624828376f18462cae9eed.tar.gz
txr-f928e5ca648990aa63624828376f18462cae9eed.tar.bz2
txr-f928e5ca648990aa63624828376f18462cae9eed.zip
bugfix: spurious nils in pad function's output.
* eval.c (pad): Incoming sequence must be nullified, otherwise empty vectors and strings produce a spurious nil. This affects the weave function, which uses pad.
-rw-r--r--eval.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/eval.c b/eval.c
index fbef1b81..63968f35 100644
--- a/eval.c
+++ b/eval.c
@@ -5137,23 +5137,24 @@ static val pad_func(val env, val lcons)
return nil;
}
-static val pad(val list, val item_in, val count)
+static val pad(val seq_in, val item_in, val count)
{
val item = default_null_arg(item_in);
+ val seq = nullify(seq_in);
- switch (type(list)) {
+ switch (type(seq)) {
case NIL:
return repeat(cons(item, nil), count);
case CONS:
- return append2(list, repeat(cons(item, nil), count));
+ return append2(seq, repeat(cons(item, nil), count));
case LCONS:
case VEC:
case LIT:
case STR:
case LSTR:
- return make_lazy_cons(func_f1(cons(list, cons(item, count)), pad_func));
+ return make_lazy_cons(func_f1(cons(seq, cons(item, count)), pad_func));
default:
- uw_throwf(error_s, lit("pad: cannot pad ~s, only sequences"), list, nao);
+ uw_throwf(error_s, lit("pad: cannot pad ~s, only sequences"), seq, nao);
}
}