Annotation of docbook2mdoc/tree.c, Revision 1.3
1.3 ! schwarze 1: /* $Id: tree.c,v 1.2 2019/04/21 14:48:12 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:
1.3 ! schwarze 32: printf("%*s%c%s", indent, "",
! 33: (n->flags & NFLAG_LINE) ? '*' :
! 34: (n->flags & NFLAG_SPC) ? ' ' : '-',
1.1 schwarze 35: pnode_name(n->node));
1.2 schwarze 36: if (n->b != NULL) {
1.1 schwarze 37: putchar(' ');
38: fputs(n->b, stdout);
39: }
40: TAILQ_FOREACH(a, &n->attrq, child)
41: printf(" %s='%s'", attrkey_name(a->key), attr_getval(a));
42: putchar('\n');
43: TAILQ_FOREACH(nc, &n->childq, child)
44: print_node(nc, indent + 2);
45: }
46:
47: void
48: ptree_print_tree(struct ptree *tree)
49: {
50: print_node(tree->root, 0);
51: }
CVSweb