diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-11-21 07:31:10 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-11-21 07:31:10 -0800 |
commit | c36bd9667e8905aeef9c01660c2adb74782ce3ce (patch) | |
tree | b4e586ace00001720fcc1f1fa86ffcf21a3adaff /lib.c | |
parent | 8b237b2dcd460efb9f15494595bc0b429a76a438 (diff) | |
download | txr-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.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -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 { |