summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-05-12 06:21:58 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-05-12 06:21:58 -0700
commit722a6ca9a69cdd0a463d48af5380af19fd9779fc (patch)
treea09d91f42a23473111faea7773735bc172c9fb98 /lib.c
parent151e5d5dd38015b1be948477d62bf6e8b908352e (diff)
downloadtxr-722a6ca9a69cdd0a463d48af5380af19fd9779fc.tar.gz
txr-722a6ca9a69cdd0a463d48af5380af19fd9779fc.tar.bz2
txr-722a6ca9a69cdd0a463d48af5380af19fd9779fc.zip
tree: let tree-iter be iterable via generic iteration.
* lib.c (seq_iter_init_with_info): Recognize tree_iter object, and treat using tree iterator function. * tests/010/tree.tl: test case for tree subrange iteration with collect-each. * txr.1: Updated.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 45ec1417..3f2a9616 100644
--- a/lib.c
+++ b/lib.c
@@ -857,6 +857,16 @@ void seq_iter_init_with_info(val self, seq_iter_t *it,
}
}
}
+ if (it->inf.obj->co.cls == tree_iter_s)
+ {
+ it->ui.iter = if3(support_rewind,
+ copy_tree_iter(it->inf.obj),
+ it->inf.obj);
+ it->ul.len = 0;
+ it->get = seq_iter_get_tree;
+ it->peek = seq_iter_peek_tree;
+ break;
+ }
/* fallthrough */
default:
switch (it->inf.kind) {