diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | lib.c | 15 |
2 files changed, 14 insertions, 8 deletions
@@ -1,5 +1,12 @@ 2014-11-21 Kaz Kylheku <kaz@kylheku.com> + * 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. + +2014-11-21 Kaz Kylheku <kaz@kylheku.com> + * lib.c (partition_by_func): Rename one local variable for clarity. Remove unessential variable last, and move the next variable into loop scope. @@ -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 { |