summaryrefslogtreecommitdiffstats
path: root/tree.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-01-17 14:04:25 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-01-17 14:04:25 +0000
commit56f0b4a0fb2fb74f3bf1c6f8ed87ce2b716bcf52 (patch)
tree336c6f8871c8ab7b939a25b3e18e651fabbaf704 /tree.c
parent50c7e68a675c2b7d573e94e93564b37785d2cad6 (diff)
downloadmandoc-56f0b4a0fb2fb74f3bf1c6f8ed87ce2b716bcf52.tar.gz
Separating output filters.
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c46
1 files changed, 38 insertions, 8 deletions
diff --git a/tree.c b/tree.c
index 9fbdd245..4dec0f3c 100644
--- a/tree.c
+++ b/tree.c
@@ -17,14 +17,16 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdlib.h>
+#include <stdio.h>
#include "mdoc.h"
+#define xprintf (void)printf
+
+static void treeprint_r(const struct mdoc_node *, int);
-#if 0
-/* TODO: remove this to a print-tree output filter. */
static void
-print_node(const struct mdoc_node *n, int indent)
+treeprint_r(const struct mdoc_node *n, int indent)
{
const char *p, *t;
int i, j;
@@ -36,7 +38,32 @@ print_node(const struct mdoc_node *n, int indent)
argc = sz = 0;
params = NULL;
- t = mdoc_type2a(n->type);
+ switch (n->type) {
+ case (MDOC_ROOT):
+ t = "root";
+ break;
+ case (MDOC_BLOCK):
+ t = "block";
+ break;
+ case (MDOC_HEAD):
+ t = "block-head";
+ break;
+ case (MDOC_BODY):
+ t = "block-body";
+ break;
+ case (MDOC_TAIL):
+ t = "block-tail";
+ break;
+ case (MDOC_ELEM):
+ t = "elem";
+ break;
+ case (MDOC_TEXT):
+ t = "text";
+ break;
+ default:
+ abort();
+ /* NOTREACHED */
+ }
switch (n->type) {
case (MDOC_TEXT):
@@ -89,13 +116,16 @@ print_node(const struct mdoc_node *n, int indent)
xprintf(" %d:%d\n", n->line, n->pos);
if (n->child)
- print_node(n->child, indent + 1);
+ treeprint_r(n->child, indent + 1);
if (n->next)
- print_node(n->next, indent);
+ treeprint_r(n->next, indent);
}
-#endif
+
int
-treeprint(const struct mdoc_node *node, const char *out)
+treeprint(const struct mdoc_node *node)
{
+
+ treeprint_r(node, 0);
+ return(1);
}