klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit d8e94727b331ab9b9d2e6929608409e077ad786e
parent ba49fca4de8361a3281e81938cb223408f5635e2
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Sun, 17 Apr 2011 23:05:53 -0300

Bugfix: in append!, in get_lss_endpoints, if last element is nil, nil should be added to the returned list to always make it even.

Diffstat:
Msrc/kgpair_mut.c | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/kgpair_mut.c b/src/kgpair_mut.c @@ -273,9 +273,15 @@ TValue appendB_get_lss_endpoints(klisp_State *K, TValue lss, int32_t apairs, TValue first = kcar(tail); tail = kcdr(tail); - /* skip over nils */ - if (ttisnil(first)) + /* skip over non final nils, but final nil + should be added as last pair to let the result + be even */ + if (ttisnil(first)) { + if (ttisnil(tail)) { + kset_cdr(last_pair, kcons(K, first, KNIL)); + } continue; + } TValue ftail = first; TValue flastp = first; @@ -313,6 +319,7 @@ TValue appendB_get_lss_endpoints(klisp_State *K, TValue lss, int32_t apairs, if (kis_immutable(flastp)) { appendB_clear_last_pairs(K, last_pairs); klispE_throw(K, "append!: immutable pair found"); + return KINERT; } /* add the last pair to the list of last pairs */ kset_mark(flastp, last_pairs);