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 | 6668d036e80755afb1edd6a8e9bfdbf02b9411f6 (patch) | |
tree | e82df6693575f055b2017643aa8494766f3777a0 /ffi.c | |
parent | 740ece8a507d3a61b048b7bf8aa4dd3e94cdb665 (diff) | |
download | txr-6668d036e80755afb1edd6a8e9bfdbf02b9411f6.tar.gz txr-6668d036e80755afb1edd6a8e9bfdbf02b9411f6.tar.bz2 txr-6668d036e80755afb1edd6a8e9bfdbf02b9411f6.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.
Diffstat (limited to 'ffi.c')
-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; |