]>
git.cameronkatri.com Git - mandoc.git/blob - tree.c
1 /* $Id: tree.c,v 1.19 2010/01/01 17:14:31 kristaps Exp $ */
3 * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
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.
30 static void print_mdoc(const struct mdoc_node
*, int);
31 static void print_man(const struct man_node
*, int);
36 tree_mdoc(void *arg
, const struct mdoc
*mdoc
)
39 print_mdoc(mdoc_node(mdoc
), 0);
45 tree_man(void *arg
, const struct man
*man
)
48 print_man(man_node(man
), 0);
53 print_mdoc(const struct mdoc_node
*n
, int indent
)
59 struct mdoc_argv
*argv
;
97 p
= mdoc_macronames
[n
->tok
];
100 p
= mdoc_macronames
[n
->tok
];
103 p
= mdoc_macronames
[n
->tok
];
106 p
= mdoc_macronames
[n
->tok
];
108 argv
= n
->args
->argv
;
109 argc
= n
->args
->argc
;
113 p
= mdoc_macronames
[n
->tok
];
115 argv
= n
->args
->argv
;
116 argc
= n
->args
->argc
;
127 for (i
= 0; i
< indent
; i
++)
129 (void)printf("%s (%s)", p
, t
);
131 for (i
= 0; i
< (int)argc
; i
++) {
132 (void)printf(" -%s", mdoc_argnames
[argv
[i
].arg
]);
135 for (j
= 0; j
< (int)argv
[i
].sz
; j
++)
136 (void)printf(" [%s]", argv
[i
].value
[j
]);
141 for (i
= 0; i
< (int)sz
; i
++)
142 (void)printf(" [%s]", params
[i
]);
144 (void)printf(" %d:%d\n", n
->line
, n
->pos
);
147 print_mdoc(n
->child
, indent
+ 1);
149 print_mdoc(n
->next
, indent
);
154 print_man(const struct man_node
*n
, int indent
)
194 p
= man_macronames
[n
->tok
];
204 for (i
= 0; i
< indent
; i
++)
206 (void)printf("%s (%s) %d:%d\n", p
, t
, n
->line
, n
->pos
);
209 print_man(n
->child
, indent
+ 1);
211 print_man(n
->next
, indent
);