]>
git.cameronkatri.com Git - mandoc.git/blob - tree.c
1 /* $Id: tree.c,v 1.24 2010/07/07 15:04:54 kristaps Exp $ */
3 * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
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.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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.
31 static void print_mdoc(const struct mdoc_node
*, int);
32 static void print_man(const struct man_node
*, int);
37 tree_mdoc(void *arg
, const struct mdoc
*mdoc
)
40 print_mdoc(mdoc_node(mdoc
), 0);
46 tree_man(void *arg
, const struct man
*man
)
49 print_man(man_node(man
), 0);
54 print_mdoc(const struct mdoc_node
*n
, int indent
)
60 struct mdoc_argv
*argv
;
101 p
= mdoc_macronames
[n
->tok
];
104 p
= mdoc_macronames
[n
->tok
];
107 p
= mdoc_macronames
[n
->tok
];
110 p
= mdoc_macronames
[n
->tok
];
112 argv
= n
->args
->argv
;
113 argc
= n
->args
->argc
;
117 p
= mdoc_macronames
[n
->tok
];
119 argv
= n
->args
->argv
;
120 argc
= n
->args
->argc
;
131 for (i
= 0; i
< indent
; i
++)
133 (void)printf("%s (%s)", p
, t
);
135 for (i
= 0; i
< (int)argc
; i
++) {
136 (void)printf(" -%s", mdoc_argnames
[argv
[i
].arg
]);
139 for (j
= 0; j
< (int)argv
[i
].sz
; j
++)
140 (void)printf(" [%s]", argv
[i
].value
[j
]);
145 for (i
= 0; i
< (int)sz
; i
++)
146 (void)printf(" [%s]", params
[i
]);
148 (void)printf(" %d:%d\n", n
->line
, n
->pos
);
151 print_mdoc(n
->child
, indent
+ 1);
153 print_mdoc(n
->next
, indent
);
158 print_man(const struct man_node
*n
, int indent
)
198 p
= man_macronames
[n
->tok
];
208 for (i
= 0; i
< indent
; i
++)
210 (void)printf("%s (%s) %d:%d\n", p
, t
, n
->line
, n
->pos
);
213 print_man(n
->child
, indent
+ 1);
215 print_man(n
->next
, indent
);