diff options
author | Maria Matejka <mq@ucw.cz> | 2022-11-07 10:09:40 +0100 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2022-11-07 10:18:19 +0100 |
commit | 96d380405701bb01d792ff1c867a607d7fefa001 (patch) | |
tree | 08477327585a486667ade126b9bd51713e461608 /filter | |
parent | 34e803c6c32032cffeb9bd230d0f85861acd9222 (diff) | |
parent | 8478de8817c58af02f7aed1d621013891115a2dc (diff) |
Merge commit '8478de88' into thread-next
Diffstat (limited to 'filter')
-rw-r--r-- | filter/data.c | 6 | ||||
-rw-r--r-- | filter/data.h | 5 | ||||
-rw-r--r-- | filter/tree.c | 8 |
3 files changed, 16 insertions, 3 deletions
diff --git a/filter/data.c b/filter/data.c index d26b07f5..f104d2f8 100644 --- a/filter/data.c +++ b/filter/data.c @@ -327,7 +327,7 @@ clist_set_type(const struct f_tree *set, struct f_val *v) } } -static int +int clist_match_set(const struct adata *clist, const struct f_tree *set) { if (!clist) @@ -348,7 +348,7 @@ clist_match_set(const struct adata *clist, const struct f_tree *set) return 0; } -static int +int eclist_match_set(const struct adata *list, const struct f_tree *set) { if (!list) @@ -372,7 +372,7 @@ eclist_match_set(const struct adata *list, const struct f_tree *set) return 0; } -static int +int lclist_match_set(const struct adata *list, const struct f_tree *set) { if (!list) diff --git a/filter/data.h b/filter/data.h index c1e7c736..ad578208 100644 --- a/filter/data.h +++ b/filter/data.h @@ -119,6 +119,7 @@ struct f_tree *f_new_tree(void); struct f_tree *build_tree(struct f_tree *); const struct f_tree *find_tree(const struct f_tree *t, const struct f_val *val); int same_tree(const struct f_tree *t0, const struct f_tree *t2); +int tree_node_count(const struct f_tree *t); void tree_format(const struct f_tree *t, buffer *buf); void tree_walk(const struct f_tree *t, void (*hook)(const struct f_tree *, void *), void *data); @@ -215,6 +216,10 @@ static inline int lclist_set_type(const struct f_tree *set) static inline int path_set_type(const struct f_tree *set) { return !set || set->from.type == T_INT; } +int clist_match_set(const struct adata *clist, const struct f_tree *set); +int eclist_match_set(const struct adata *list, const struct f_tree *set); +int lclist_match_set(const struct adata *list, const struct f_tree *set); + const struct adata *clist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos); const struct adata *eclist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos); const struct adata *lclist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos); diff --git a/filter/tree.c b/filter/tree.c index 5da86b9d..97bf7dae 100644 --- a/filter/tree.c +++ b/filter/tree.c @@ -134,6 +134,14 @@ same_tree(const struct f_tree *t1, const struct f_tree *t2) return 1; } +int +tree_node_count(const struct f_tree *t) +{ + if (t == NULL) + return 0; + + return 1 + tree_node_count(t->left) + tree_node_count(t->right); +} static void tree_node_format(const struct f_tree *t, buffer *buf) |