From 982bc4b4bc71a80761ebb9b58e4db06bc1317bb6 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 2 Aug 2017 06:36:39 -0700 Subject: 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. --- eval.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'eval.c') 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); } } -- cgit v1.2.3