diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-08-29 07:36:13 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-08-29 07:36:13 -0700 |
commit | 75528b512fe6cf45a8bb20c2d4c171701da034f2 (patch) | |
tree | cddff56a05f259b66bf29e167fcfe2d77153dd39 | |
parent | de6ed1ed8039be7e05ae09aee8e286111dd41638 (diff) | |
download | txr-75528b512fe6cf45a8bb20c2d4c171701da034f2.tar.gz txr-75528b512fe6cf45a8bb20c2d4c171701da034f2.tar.bz2 txr-75528b512fe6cf45a8bb20c2d4c171701da034f2.zip |
seq_iter: allow mixed fixnum/bignum ranges.
* lib.c (seq_iter_init_with_info): The to value in a range
could be a bignum, which we should treat as a bignum range,
rather than blowing up due to calling c_num on that value.
-rw-r--r-- | lib.c | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -943,9 +943,15 @@ void seq_iter_init_with_info(val self, seq_iter_t *it, if (less(rf, rt)) switch (type(rf)) { case NUM: - it->ui.cn = c_num(rf, self); - it->ul.cbound = c_num(rt, self); - it->ops = &si_range_cnum_ops; + if (bignump(rt) && !mp_in_intptr_range(mp(rt))) { + it->ui.vn = rf; + it->ul.vbound = rt; + it->ops = &si_range_bignum_ops; + } else { + it->ui.cn = c_num(rf, self); + it->ul.cbound = c_num(rt, self); + it->ops = &si_range_cnum_ops; + } break; case CHR: it->ui.cn = c_chr(rf); @@ -970,9 +976,15 @@ void seq_iter_init_with_info(val self, seq_iter_t *it, unsup_obj(self, it->inf.obj); } else if (!equal(rf, rt)) switch (type(rf)) { case NUM: - it->ui.cn = c_num(rf, self); - it->ul.cbound = c_num(rt, self); - it->ops = &si_rev_range_cnum_ops; + if (bignump(rt) && !mp_in_intptr_range(mp(rt))) { + it->ui.vn = rf; + it->ul.vbound = rt; + it->ops = &si_rev_range_bignum_ops; + } else { + it->ui.cn = c_num(rf, self); + it->ul.cbound = c_num(rt, self); + it->ops = &si_rev_range_cnum_ops; + } break; case CHR: it->ui.cn = c_chr(rf); |