Annotation of docbook2mdoc/tree.c, Revision 1.2
1.2 ! schwarze 1: /* $Id: tree.c,v 1.1 2019/04/12 19:14:50 schwarze Exp $ */
1.1 schwarze 2: /*
3: * Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
4: *
5: * Permission to use, copy, modify, and distribute this software for any
6: * purpose with or without fee is hereby granted, provided that the above
7: * copyright notice and this permission notice appear in all copies.
8: *
9: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
10: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
12: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16: */
17: #include <stdio.h>
18:
19: #include "node.h"
20: #include "format.h"
21:
22: /*
23: * The implementation of the parse tree dumper.
24: */
25:
26: void
27: print_node(struct pnode *n, int indent)
28: {
29: struct pnode *nc;
30: struct pattr *a;
31:
32: printf("%*s%c%s", indent, "", n->spc ? ' ' : '-',
33: pnode_name(n->node));
1.2 ! schwarze 34: if (n->b != NULL) {
1.1 schwarze 35: putchar(' ');
36: fputs(n->b, stdout);
37: }
38: TAILQ_FOREACH(a, &n->attrq, child)
39: printf(" %s='%s'", attrkey_name(a->key), attr_getval(a));
40: putchar('\n');
41: TAILQ_FOREACH(nc, &n->childq, child)
42: print_node(nc, indent + 2);
43: }
44:
45: void
46: ptree_print_tree(struct ptree *tree)
47: {
48: print_node(tree->root, 0);
49: }
CVSweb