summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--lib.c15
2 files changed, 14 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 69d7c98d..932dc26c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
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 {