From 2bc41c8920513856daa73018e6b9f9c54f456fe2 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 16 Dec 2015 06:02:47 -0800 Subject: 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. --- lib.c | 12 ++++++------ 1 file 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; -- cgit v1.2.3