fix argument handling bug in fl_map1
need to pop after _applyn; functions might rewrite the stack to contain non-values.
This commit is contained in:
parent
a0707331b8
commit
3293630c84
7
flisp.c
7
flisp.c
|
@ -2185,6 +2185,7 @@ value_t fl_map1(value_t *args, u_int32_t nargs)
|
|||
Stack[argSP+i] = cdr_(Stack[argSP+i]);
|
||||
}
|
||||
v = _applyn(nargs-1);
|
||||
POPN(nargs);
|
||||
PUSH(v);
|
||||
v = mk_cons();
|
||||
car_(v) = POP(); cdr_(v) = NIL;
|
||||
|
@ -2192,19 +2193,19 @@ value_t fl_map1(value_t *args, u_int32_t nargs)
|
|||
fl_gc_handle(&first);
|
||||
fl_gc_handle(&last);
|
||||
while (iscons(Stack[argSP+1])) {
|
||||
Stack[SP-nargs] = Stack[argSP];
|
||||
PUSH(Stack[argSP]);
|
||||
for(i=1; i < nargs; i++) {
|
||||
Stack[SP-nargs+i] = car(Stack[argSP+i]);
|
||||
PUSH(car(Stack[argSP+i]));
|
||||
Stack[argSP+i] = cdr_(Stack[argSP+i]);
|
||||
}
|
||||
v = _applyn(nargs-1);
|
||||
POPN(nargs);
|
||||
PUSH(v);
|
||||
v = mk_cons();
|
||||
car_(v) = POP(); cdr_(v) = NIL;
|
||||
cdr_(last) = v;
|
||||
last = v;
|
||||
}
|
||||
POPN(nargs);
|
||||
fl_free_gc_handles(2);
|
||||
}
|
||||
return first;
|
||||
|
|
Loading…
Reference in New Issue