summaryrefslogtreecommitdiff
path: root/filter/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'filter/tree.c')
-rw-r--r--filter/tree.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/filter/tree.c b/filter/tree.c
index d27db18b..ee9f448a 100644
--- a/filter/tree.c
+++ b/filter/tree.c
@@ -137,3 +137,37 @@ same_tree(struct f_tree *t1, struct f_tree *t2)
return 0;
return 1;
}
+
+
+static void
+tree_node_format(struct f_tree *t, buffer *buf)
+{
+ if (t == NULL)
+ return;
+
+ tree_node_format(t->left, buf);
+
+ val_format(t->from, buf);
+ if (val_compare(t->from, t->to) != 0)
+ {
+ buffer_puts(buf, "..");
+ val_format(t->to, buf);
+ }
+ buffer_puts(buf, ", ");
+
+ tree_node_format(t->right, buf);
+}
+
+void
+tree_format(struct f_tree *t, buffer *buf)
+{
+ buffer_puts(buf, "[");
+
+ tree_node_format(t, buf);
+
+ /* Undo last separator */
+ if (buf->pos[-1] != '[')
+ buf->pos -= 2;
+
+ buffer_puts(buf, "]");
+}