summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-11-24 20:14:13 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-11-24 20:14:13 -0800
commiteaa457213d49600c5e1fd34dcbeb17d4716aea41 (patch)
treea72e8ea4b6e6cb456e91078c65f947eaf3fee2e8
parente9ac435a6c1904ce8f000b13087ebc179f3e430e (diff)
downloadtxr-eaa457213d49600c5e1fd34dcbeb17d4716aea41.tar.gz
txr-eaa457213d49600c5e1fd34dcbeb17d4716aea41.tar.bz2
txr-eaa457213d49600c5e1fd34dcbeb17d4716aea41.zip
Bugfix: split and partition functions.
When the index argument is a function and it returns an empty list, the functions behave incorrectly. * lib.c (partition_split_common): Exchange order of two operations. The handling of an empty indices list must be done after testing for and calling the function which can potentially produce that value.
-rw-r--r--lib.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib.c b/lib.c
index 30636c66..751d8a3b 100644
--- a/lib.c
+++ b/lib.c
@@ -1936,12 +1936,12 @@ static val partition_split_common(val seq, val indices, val partition_p)
if (!seq)
return nil;
- if (!indices)
- return cons(seq, nil);
-
if (functionp(indices))
indices = funcall1(indices, seq);
+ if (!indices)
+ return cons(seq, nil);
+
if (atom(indices))
indices = cons(indices, nil);