summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-12-15 22:37:17 -0800
committerKaz Kylheku <kaz@kylheku.com>2024-12-15 22:37:17 -0800
commita3532279d5d16f1f69bff1bae06f477cdbc53b0f (patch)
treeb24324d40af254e2178024e309bf5edba6dbe621 /lib.c
parenta2f6a5744045f75f5c5b991cea7fe0df64e2cba4 (diff)
downloadtxr-a3532279d5d16f1f69bff1bae06f477cdbc53b0f.tar.gz
txr-a3532279d5d16f1f69bff1bae06f477cdbc53b0f.tar.bz2
txr-a3532279d5d16f1f69bff1bae06f477cdbc53b0f.zip
string ranges: bug: ranges of length 1.
* lib.c (seq_iter_init_with_info): String ranges are inclusive. We must not assume at a range whose endpoints are the same is empty; we must check that case for the endpoints being strings. * tests/012/seq.tl: New tests.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index b4971191..11cf3340 100644
--- a/lib.c
+++ b/lib.c
@@ -1060,7 +1060,17 @@ void seq_iter_init_with_info(val self, seq_iter_t *it, seq_info_t si)
/* fallthrough */
default:
unsup_obj(self, it->inf.obj);
- } else {
+ } else switch (type(rf)) {
+ case LIT:
+ case STR:
+ case LSTR:
+ it->ui.vn = copy_str(rf);
+ it->ul.vbound = rt;
+ it->ops = &si_range_str_ops;
+ if (eql(length_str(rf), length_str(rt)))
+ break;
+ unsup_obj(self, it->inf.obj);
+ default:
seq_iter_init_with_info(self, it, seq_info(nil));
break;
}