summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-12-16 06:02:47 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-12-16 06:02:47 -0800
commit2bc41c8920513856daa73018e6b9f9c54f456fe2 (patch)
tree7fa96ec4b7f9cb26f9220cb2f06cd2876967bedc /lib.c
parent21f9fb76746b1513e483a5a18b2e38e835b367a3 (diff)
downloadtxr-2bc41c8920513856daa73018e6b9f9c54f456fe2.tar.gz
txr-2bc41c8920513856daa73018e6b9f9c54f456fe2.tar.bz2
txr-2bc41c8920513856daa73018e6b9f9c54f456fe2.zip
bugfix: nil from in replace wrongly treated as 0.
* lib.c (replace_list, replace_str, replace_vec): The from argument must be checked to be a list using listp not consp. The legacy convention that nil is treated as missing does not work in this function as it does in sub.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib.c b/lib.c
index e3d17386..14a2b65a 100644
--- a/lib.c
+++ b/lib.c
@@ -1099,7 +1099,7 @@ val replace_list(val list, val items, val from, val to)
if (!list)
return items;
- if (consp(from)) {
+ if (listp(from)) {
val where = from;
val seq = list;
val idx = zero;
@@ -1143,7 +1143,7 @@ val replace_list(val list, val items, val from, val to)
}
return list;
- } else if (null_or_missing_p(from)) {
+ } else if (missingp(from)) {
from = zero;
} else if (from == t) {
from = nil;
@@ -3235,7 +3235,7 @@ val replace_str(val str_in, val items, val from, val to)
str_in, typeof(str_in), nao);
}
- if (consp(from)) {
+ if (listp(from)) {
val where = from;
val len = length_str(str_in);
@@ -3271,7 +3271,7 @@ val replace_str(val str_in, val items, val from, val to)
}
return str_in;
- } else if (null_or_missing_p(from)) {
+ } else if (missingp(from)) {
from = zero;
} else if (from == t) {
from = len;
@@ -5820,7 +5820,7 @@ val replace_vec(val vec_in, val items, val from, val to)
val it_seq = toseq(items);
val len = length_vec(vec_in);
- if (consp(from)) {
+ if (listp(from)) {
val where = from;
val len = length_vec(vec_in);
@@ -5856,7 +5856,7 @@ val replace_vec(val vec_in, val items, val from, val to)
}
return vec_in;
- } else if (null_or_missing_p(from)) {
+ } else if (missingp(from)) {
from = zero;
} else if (from == t) {
from = len;