diff options
author | Paul A. Patience <paul@apatience.com> | 2022-01-10 02:22:30 -0500 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-01-12 07:29:35 -0800 |
commit | 0d7318e4113e2f6ec8ad4f79c5d4ca418286a370 (patch) | |
tree | e82df6693575f055b2017643aa8494766f3777a0 | |
parent | 096371573bf714a2800a083f39af1278d8def4e5 (diff) | |
download | txr-0d7318e4113e2f6ec8ad4f79c5d4ca418286a370.tar.gz txr-0d7318e4113e2f6ec8ad4f79c5d4ca418286a370.tar.bz2 txr-0d7318e4113e2f6ec8ad4f79c5d4ca418286a370.zip |
carray: allow t and floating 0 in sub and replace.
* ffi.c (carray_sub, carray_replace): Allow t as from or to value, and
also implement the zero's end-of-range floating behavior.
-rw-r--r-- | ffi.c | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -5732,23 +5732,24 @@ val carray_sub(val carray, val from, val to) if (null_or_missing_p(from)) from = zero; - - if (null_or_missing_p(to)) { + else if (from == t) + from = len; + else if (minusp(from)) { if (ln < 0) goto nolen; - to = len; + from = plus(from, len); + if (to == zero) + to = len; } - if (minusp(to)) { + if (null_or_missing_p(to) || to == t) { if (ln < 0) goto nolen; - to = plus(to, len); - } - - if (minusp(from)) { + to = len; + } else if (minusp(to)) { if (ln < 0) goto nolen; - from = plus(from, len); + to = plus(to, len); } { @@ -5786,6 +5787,8 @@ val carray_replace(val carray, val values, val from, val to) if (null_or_missing_p(from)) { from = zero; + } else if (from == t) { + from = len; } else if (!integerp(from)) { seq_iter_t wh_iter, item_iter; val wh, item; @@ -5810,9 +5813,11 @@ val carray_replace(val carray, val values, val from, val to) if (ln < 0) goto nolen; from = plus(from, len); + if (to == zero) + to = len; } - if (null_or_missing_p(to)) { + if (null_or_missing_p(to) || to == t) { if (ln < 0) goto nolen; to = len; |