From c36bd9667e8905aeef9c01660c2adb74782ce3ce Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 21 Nov 2014 07:31:10 -0800 Subject: * lib.c (partition_star_func): Bugfix: doing rplaca(env, seq) too early, before the loop which adjusts its value. Restructuring this slightly to avoid duplicated code, by moving the !first check later. --- lib.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index dea60eeb..53f645ef 100644 --- a/lib.c +++ b/lib.c @@ -1498,14 +1498,7 @@ static val partition_star_func(val env, val lcons) seq = nullify(sub(seq, plus(index_rebased, one), t)); - rplaca(env, seq); - rplaca(indices_base, indices); - rplacd(indices_base, base = plus(index, one)); - - if (!first) - continue; - - rplaca(lcons, first); + base = plus(index, one); while (seq && eql(car(indices), base)) { seq = nullify(cdr(seq)); @@ -1513,9 +1506,15 @@ static val partition_star_func(val env, val lcons) pop(&indices); } + rplaca(env, seq); rplaca(indices_base, indices); rplacd(indices_base, base); + if (!first) + continue; + + rplaca(lcons, first); + if (seq) rplacd(lcons, make_lazy_cons(lcons_fun(lcons))); } else { -- cgit v1.2.3