diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-01-24 20:29:00 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-01-24 20:29:00 -0800 |
commit | ac38be959685701f4992f4e68e313120c6e82297 (patch) | |
tree | 7da004fef9266891ce069a65b7aa0e9835adad71 /lib.c | |
parent | af91e7e35cd8277c3a437d9dfddea4c5c313a656 (diff) | |
download | txr-ac38be959685701f4992f4e68e313120c6e82297.tar.gz txr-ac38be959685701f4992f4e68e313120c6e82297.tar.bz2 txr-ac38be959685701f4992f4e68e313120c6e82297.zip |
bugfix: take-while, take-until termination condition.
* lib.c (take_while_list_fun, take_until_list_fun):
We must terminate the output list when the output list
is empty, and not try to apply the predicate to
car(list) in that case.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -8449,7 +8449,7 @@ static val take_while_list_fun(val env, val lcons) rplaca(lcons, pop(&list)); - if (!funcall1(pred, funcall1(keyfun, car(list)))) + if (!list || !funcall1(pred, funcall1(keyfun, car(list)))) rplacd(lcons, nil); else rplacd(lcons, make_lazy_cons(lcons_fun(lcons))); @@ -8493,7 +8493,7 @@ static val take_until_list_fun(val env, val lcons) rplaca(lcons, item); - if (funcall1(pred, funcall1(keyfun, item))) + if (!list || funcall1(pred, funcall1(keyfun, item))) rplacd(lcons, nil); else rplacd(lcons, make_lazy_cons(lcons_fun(lcons))); |