summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-11-21 07:31:10 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-11-21 07:31:10 -0800
commitc36bd9667e8905aeef9c01660c2adb74782ce3ce (patch)
treeb4e586ace00001720fcc1f1fa86ffcf21a3adaff /lib.c
parent8b237b2dcd460efb9f15494595bc0b429a76a438 (diff)
downloadtxr-c36bd9667e8905aeef9c01660c2adb74782ce3ce.tar.gz
txr-c36bd9667e8905aeef9c01660c2adb74782ce3ce.tar.bz2
txr-c36bd9667e8905aeef9c01660c2adb74782ce3ce.zip
* 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.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c15
1 files changed, 7 insertions, 8 deletions
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 {