summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-08-29 07:36:13 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-08-29 07:36:13 -0700
commitb293cebe662de083d0925f0238b7a81a35b9eb3c (patch)
treecddff56a05f259b66bf29e167fcfe2d77153dd39
parent13da0e5ed3d3d4be6d1f9cc9d786ff4e0f2edd68 (diff)
downloadtxr-b293cebe662de083d0925f0238b7a81a35b9eb3c.tar.gz
txr-b293cebe662de083d0925f0238b7a81a35b9eb3c.tar.bz2
txr-b293cebe662de083d0925f0238b7a81a35b9eb3c.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.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/lib.c b/lib.c
index af9a9703..796853ec 100644
--- a/lib.c
+++ b/lib.c
@@ -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);