]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_man.c
1 /* $Id: mdoc_man.c,v 1.35 2012/07/12 08:55:48 schwarze Exp $ */
3 * Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
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 #define DECL_ARGS const struct mdoc_meta *m, \
32 const struct mdoc_node *n
35 int (*cond
)(DECL_ARGS
); /* DON'T run actions */
36 int (*pre
)(DECL_ARGS
); /* pre-node action */
37 void (*post
)(DECL_ARGS
); /* post-node action */
38 const char *prefix
; /* pre-node string constant */
39 const char *suffix
; /* post-node string constant */
42 static int cond_body(DECL_ARGS
);
43 static int cond_head(DECL_ARGS
);
44 static void font_push(char);
45 static void font_pop(void);
46 static void post__t(DECL_ARGS
);
47 static void post_bd(DECL_ARGS
);
48 static void post_bf(DECL_ARGS
);
49 static void post_bk(DECL_ARGS
);
50 static void post_bl(DECL_ARGS
);
51 static void post_dl(DECL_ARGS
);
52 static void post_enc(DECL_ARGS
);
53 static void post_eo(DECL_ARGS
);
54 static void post_fa(DECL_ARGS
);
55 static void post_fd(DECL_ARGS
);
56 static void post_fl(DECL_ARGS
);
57 static void post_fn(DECL_ARGS
);
58 static void post_fo(DECL_ARGS
);
59 static void post_font(DECL_ARGS
);
60 static void post_in(DECL_ARGS
);
61 static void post_it(DECL_ARGS
);
62 static void post_lb(DECL_ARGS
);
63 static void post_nm(DECL_ARGS
);
64 static void post_percent(DECL_ARGS
);
65 static void post_pf(DECL_ARGS
);
66 static void post_sect(DECL_ARGS
);
67 static void post_sp(DECL_ARGS
);
68 static void post_vt(DECL_ARGS
);
69 static int pre__t(DECL_ARGS
);
70 static int pre_an(DECL_ARGS
);
71 static int pre_ap(DECL_ARGS
);
72 static int pre_bd(DECL_ARGS
);
73 static int pre_bf(DECL_ARGS
);
74 static int pre_bk(DECL_ARGS
);
75 static int pre_bl(DECL_ARGS
);
76 static int pre_br(DECL_ARGS
);
77 static int pre_bx(DECL_ARGS
);
78 static int pre_dl(DECL_ARGS
);
79 static int pre_enc(DECL_ARGS
);
80 static int pre_em(DECL_ARGS
);
81 static int pre_fa(DECL_ARGS
);
82 static int pre_fd(DECL_ARGS
);
83 static int pre_fl(DECL_ARGS
);
84 static int pre_fn(DECL_ARGS
);
85 static int pre_fo(DECL_ARGS
);
86 static int pre_ft(DECL_ARGS
);
87 static int pre_in(DECL_ARGS
);
88 static int pre_it(DECL_ARGS
);
89 static int pre_lk(DECL_ARGS
);
90 static int pre_li(DECL_ARGS
);
91 static int pre_nm(DECL_ARGS
);
92 static int pre_no(DECL_ARGS
);
93 static int pre_ns(DECL_ARGS
);
94 static int pre_pp(DECL_ARGS
);
95 static int pre_rs(DECL_ARGS
);
96 static int pre_sm(DECL_ARGS
);
97 static int pre_sp(DECL_ARGS
);
98 static int pre_sect(DECL_ARGS
);
99 static int pre_sy(DECL_ARGS
);
100 static void pre_syn(const struct mdoc_node
*);
101 static int pre_vt(DECL_ARGS
);
102 static int pre_ux(DECL_ARGS
);
103 static int pre_xr(DECL_ARGS
);
104 static void print_word(const char *);
105 static void print_offs(const char *);
106 static void print_width(const char *,
107 const struct mdoc_node
*, size_t);
108 static void print_count(int *);
109 static void print_node(DECL_ARGS
);
111 static const struct manact manacts
[MDOC_MAX
+ 1] = {
112 { NULL
, pre_ap
, NULL
, NULL
, NULL
}, /* Ap */
113 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Dd */
114 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Dt */
115 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Os */
116 { NULL
, pre_sect
, post_sect
, ".SH", NULL
}, /* Sh */
117 { NULL
, pre_sect
, post_sect
, ".SS", NULL
}, /* Ss */
118 { NULL
, pre_pp
, NULL
, NULL
, NULL
}, /* Pp */
119 { cond_body
, pre_dl
, post_dl
, NULL
, NULL
}, /* D1 */
120 { cond_body
, pre_dl
, post_dl
, NULL
, NULL
}, /* Dl */
121 { cond_body
, pre_bd
, post_bd
, NULL
, NULL
}, /* Bd */
122 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Ed */
123 { cond_body
, pre_bl
, post_bl
, NULL
, NULL
}, /* Bl */
124 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* El */
125 { NULL
, pre_it
, post_it
, NULL
, NULL
}, /* It */
126 { NULL
, pre_em
, post_font
, NULL
, NULL
}, /* Ad */
127 { NULL
, pre_an
, NULL
, NULL
, NULL
}, /* An */
128 { NULL
, pre_em
, post_font
, NULL
, NULL
}, /* Ar */
129 { NULL
, pre_sy
, post_font
, NULL
, NULL
}, /* Cd */
130 { NULL
, pre_sy
, post_font
, NULL
, NULL
}, /* Cm */
131 { NULL
, pre_li
, post_font
, NULL
, NULL
}, /* Dv */
132 { NULL
, pre_li
, post_font
, NULL
, NULL
}, /* Er */
133 { NULL
, pre_li
, post_font
, NULL
, NULL
}, /* Ev */
134 { NULL
, pre_enc
, post_enc
, "The \\fB",
135 "\\fP\nutility exits 0 on success, and >0 if an error occurs."
137 { NULL
, pre_fa
, post_fa
, NULL
, NULL
}, /* Fa */
138 { NULL
, pre_fd
, post_fd
, NULL
, NULL
}, /* Fd */
139 { NULL
, pre_fl
, post_fl
, NULL
, NULL
}, /* Fl */
140 { NULL
, pre_fn
, post_fn
, NULL
, NULL
}, /* Fn */
141 { NULL
, pre_ft
, post_font
, NULL
, NULL
}, /* Ft */
142 { NULL
, pre_sy
, post_font
, NULL
, NULL
}, /* Ic */
143 { NULL
, pre_in
, post_in
, NULL
, NULL
}, /* In */
144 { NULL
, pre_li
, post_font
, NULL
, NULL
}, /* Li */
145 { cond_head
, pre_enc
, NULL
, "\\- ", NULL
}, /* Nd */
146 { NULL
, pre_nm
, post_nm
, NULL
, NULL
}, /* Nm */
147 { cond_body
, pre_enc
, post_enc
, "[", "]" }, /* Op */
148 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Ot */
149 { NULL
, pre_em
, post_font
, NULL
, NULL
}, /* Pa */
150 { NULL
, pre_enc
, post_enc
, "The \\fB",
151 "\\fP\nfunction returns the value 0 if successful;\n"
152 "otherwise the value -1 is returned and the global\n"
153 "variable \\fIerrno\\fP is set to indicate the error."
155 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* St */
156 { NULL
, pre_em
, post_font
, NULL
, NULL
}, /* Va */
157 { NULL
, pre_vt
, post_vt
, NULL
, NULL
}, /* Vt */
158 { NULL
, pre_xr
, NULL
, NULL
, NULL
}, /* Xr */
159 { NULL
, NULL
, post_percent
, NULL
, NULL
}, /* %A */
160 { NULL
, pre_em
, post_percent
, NULL
, NULL
}, /* %B */
161 { NULL
, NULL
, post_percent
, NULL
, NULL
}, /* %D */
162 { NULL
, pre_em
, post_percent
, NULL
, NULL
}, /* %I */
163 { NULL
, pre_em
, post_percent
, NULL
, NULL
}, /* %J */
164 { NULL
, NULL
, post_percent
, NULL
, NULL
}, /* %N */
165 { NULL
, NULL
, post_percent
, NULL
, NULL
}, /* %O */
166 { NULL
, NULL
, post_percent
, NULL
, NULL
}, /* %P */
167 { NULL
, NULL
, post_percent
, NULL
, NULL
}, /* %R */
168 { NULL
, pre__t
, post__t
, NULL
, NULL
}, /* %T */
169 { NULL
, NULL
, post_percent
, NULL
, NULL
}, /* %V */
170 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Ac */
171 { cond_body
, pre_enc
, post_enc
, "<", ">" }, /* Ao */
172 { cond_body
, pre_enc
, post_enc
, "<", ">" }, /* Aq */
173 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* At */
174 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Bc */
175 { NULL
, pre_bf
, post_bf
, NULL
, NULL
}, /* Bf */
176 { cond_body
, pre_enc
, post_enc
, "[", "]" }, /* Bo */
177 { cond_body
, pre_enc
, post_enc
, "[", "]" }, /* Bq */
178 { NULL
, pre_ux
, NULL
, "BSD/OS", NULL
}, /* Bsx */
179 { NULL
, pre_bx
, NULL
, NULL
, NULL
}, /* Bx */
180 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Db */
181 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Dc */
182 { cond_body
, pre_enc
, post_enc
, "``", "''" }, /* Do */
183 { cond_body
, pre_enc
, post_enc
, "``", "''" }, /* Dq */
184 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Ec */
185 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Ef */
186 { NULL
, pre_em
, post_font
, NULL
, NULL
}, /* Em */
187 { NULL
, NULL
, post_eo
, NULL
, NULL
}, /* Eo */
188 { NULL
, pre_ux
, NULL
, "FreeBSD", NULL
}, /* Fx */
189 { NULL
, pre_sy
, post_font
, NULL
, NULL
}, /* Ms */
190 { NULL
, pre_no
, NULL
, NULL
, NULL
}, /* No */
191 { NULL
, pre_ns
, NULL
, NULL
, NULL
}, /* Ns */
192 { NULL
, pre_ux
, NULL
, "NetBSD", NULL
}, /* Nx */
193 { NULL
, pre_ux
, NULL
, "OpenBSD", NULL
}, /* Ox */
194 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Pc */
195 { NULL
, NULL
, post_pf
, NULL
, NULL
}, /* Pf */
196 { cond_body
, pre_enc
, post_enc
, "(", ")" }, /* Po */
197 { cond_body
, pre_enc
, post_enc
, "(", ")" }, /* Pq */
198 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Qc */
199 { cond_body
, pre_enc
, post_enc
, "`", "'" }, /* Ql */
200 { cond_body
, pre_enc
, post_enc
, "\"", "\"" }, /* Qo */
201 { cond_body
, pre_enc
, post_enc
, "\"", "\"" }, /* Qq */
202 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Re */
203 { cond_body
, pre_rs
, NULL
, NULL
, NULL
}, /* Rs */
204 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Sc */
205 { cond_body
, pre_enc
, post_enc
, "`", "'" }, /* So */
206 { cond_body
, pre_enc
, post_enc
, "`", "'" }, /* Sq */
207 { NULL
, pre_sm
, NULL
, NULL
, NULL
}, /* Sm */
208 { NULL
, pre_em
, post_font
, NULL
, NULL
}, /* Sx */
209 { NULL
, pre_sy
, post_font
, NULL
, NULL
}, /* Sy */
210 { NULL
, pre_li
, post_font
, NULL
, NULL
}, /* Tn */
211 { NULL
, pre_ux
, NULL
, "UNIX", NULL
}, /* Ux */
212 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Xc */
213 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Xo */
214 { NULL
, pre_fo
, post_fo
, NULL
, NULL
}, /* Fo */
215 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Fc */
216 { cond_body
, pre_enc
, post_enc
, "[", "]" }, /* Oo */
217 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Oc */
218 { NULL
, pre_bk
, post_bk
, NULL
, NULL
}, /* Bk */
219 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Ek */
220 { NULL
, pre_ux
, NULL
, "is currently in beta test.", NULL
}, /* Bt */
221 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Hf */
222 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Fr */
223 { NULL
, pre_ux
, NULL
, "currently under development.", NULL
}, /* Ud */
224 { NULL
, NULL
, post_lb
, NULL
, NULL
}, /* Lb */
225 { NULL
, pre_pp
, NULL
, NULL
, NULL
}, /* Lp */
226 { NULL
, pre_lk
, NULL
, NULL
, NULL
}, /* Lk */
227 { NULL
, pre_em
, post_font
, NULL
, NULL
}, /* Mt */
228 { cond_body
, pre_enc
, post_enc
, "{", "}" }, /* Brq */
229 { cond_body
, pre_enc
, post_enc
, "{", "}" }, /* Bro */
230 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Brc */
231 { NULL
, NULL
, post_percent
, NULL
, NULL
}, /* %C */
232 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Es */
233 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* En */
234 { NULL
, pre_ux
, NULL
, "DragonFly", NULL
}, /* Dx */
235 { NULL
, NULL
, post_percent
, NULL
, NULL
}, /* %Q */
236 { NULL
, pre_br
, NULL
, NULL
, NULL
}, /* br */
237 { NULL
, pre_sp
, post_sp
, NULL
, NULL
}, /* sp */
238 { NULL
, NULL
, post_percent
, NULL
, NULL
}, /* %U */
239 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* Ta */
240 { NULL
, NULL
, NULL
, NULL
, NULL
}, /* ROOT */
244 #define MMAN_spc (1 << 0)
245 #define MMAN_spc_force (1 << 1)
246 #define MMAN_nl (1 << 2)
247 #define MMAN_br (1 << 3)
248 #define MMAN_sp (1 << 4)
249 #define MMAN_Sm (1 << 5)
250 #define MMAN_Bk (1 << 6)
251 #define MMAN_An_split (1 << 7)
252 #define MMAN_An_nosplit (1 << 8)
261 font_push(char newfont
)
264 if (fontqueue
.head
+ fontqueue
.size
<= ++fontqueue
.tail
) {
266 fontqueue
.head
= mandoc_realloc(fontqueue
.head
,
269 *fontqueue
.tail
= newfont
;
272 outflags
&= ~MMAN_spc
;
279 if (fontqueue
.tail
> fontqueue
.head
)
281 outflags
&= ~MMAN_spc
;
283 putchar(*fontqueue
.tail
);
287 print_word(const char *s
)
290 if ((MMAN_sp
| MMAN_br
| MMAN_nl
) & outflags
) {
292 * If we need a newline, print it now and start afresh.
294 if (MMAN_sp
& outflags
)
296 else if (MMAN_br
& outflags
)
298 else if (MMAN_nl
& outflags
)
300 outflags
&= ~(MMAN_sp
|MMAN_br
|MMAN_nl
|MMAN_spc
);
301 } else if (MMAN_spc
& outflags
&& '\0' != s
[0])
303 * If we need a space, only print it if
304 * (1) it is forced by `No' or
305 * (2) what follows is not terminating punctuation or
306 * (3) what follows is longer than one character.
308 if (MMAN_spc_force
& outflags
||
309 NULL
== strchr(".,:;)]?!", s
[0]) || '\0' != s
[1]) {
310 if (MMAN_Bk
& outflags
) {
318 * Reassign needing space if we're not following opening
321 if (MMAN_Sm
& outflags
&&
322 (('(' != s
[0] && '[' != s
[0]) || '\0' != s
[1]))
323 outflags
|= MMAN_spc
;
325 outflags
&= ~MMAN_spc
;
326 outflags
&= ~MMAN_spc_force
;
337 putchar((unsigned char)*s
);
344 print_offs(const char *v
)
350 if (NULL
== v
|| '\0' == *v
|| 0 == strcmp(v
, "left"))
352 else if (0 == strcmp(v
, "indent"))
354 else if (0 == strcmp(v
, "indent-two"))
356 else if (a2roffsu(v
, &su
, SCALE_MAX
)) {
362 snprintf(buf
, sizeof(buf
), "%ldn", sz
);
367 print_width(const char *v
, const struct mdoc_node
*child
, size_t defsz
)
373 /* XXX Rough estimation, might have multiple parts. */
374 chsz
= (NULL
!= child
&& MDOC_TEXT
== child
->type
) ?
375 strlen(child
->string
) : 0;
379 else if (a2roffsu(v
, &su
, SCALE_MAX
)) {
380 if (SCALE_EN
== su
.unit
)
397 snprintf(buf
, sizeof(buf
), "%ldn", sz
+ 2);
402 print_count(int *count
)
406 snprintf(buf
, sizeof(buf
), "%d.", ++*count
);
411 man_man(void *arg
, const struct man
*man
)
415 * Dump the keep buffer.
416 * We're guaranteed by now that this exists (is non-NULL).
417 * Flush stdout afterward, just in case.
419 fputs(mparse_getkeep(man_mparse(man
)), stdout
);
424 man_mdoc(void *arg
, const struct mdoc
*mdoc
)
426 const struct mdoc_meta
*m
;
427 const struct mdoc_node
*n
;
432 printf(".TH \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"",
433 m
->title
, m
->msec
, m
->date
, m
->os
, m
->vol
);
435 outflags
= MMAN_nl
| MMAN_Sm
;
436 if (0 == fontqueue
.size
) {
438 fontqueue
.head
= fontqueue
.tail
= mandoc_malloc(8);
439 *fontqueue
.tail
= 'R';
446 print_node(DECL_ARGS
)
448 const struct mdoc_node
*prev
, *sub
;
449 const struct manact
*act
;
453 * Break the line if we were parsed subsequent the current node.
454 * This makes the page structure be more consistent.
456 prev
= n
->prev
? n
->prev
: n
->parent
;
457 if (MMAN_spc
& outflags
&& prev
&& prev
->line
< n
->line
)
464 if (MDOC_TEXT
== n
->type
) {
466 * Make sure that we don't happen to start with a
467 * control character at the start of a line.
469 if (MMAN_nl
& outflags
&& ('.' == *n
->string
||
470 '\'' == *n
->string
)) {
472 outflags
&= ~MMAN_spc
;
474 print_word(n
->string
);
477 * Conditionally run the pre-node action handler for a
480 act
= manacts
+ n
->tok
;
481 cond
= NULL
== act
->cond
|| (*act
->cond
)(m
, n
);
482 if (cond
&& act
->pre
)
483 do_sub
= (*act
->pre
)(m
, n
);
487 * Conditionally run all child nodes.
488 * Note that this iterates over children instead of using
489 * recursion. This prevents unnecessary depth in the stack.
492 for (sub
= n
->child
; sub
; sub
= sub
->next
)
496 * Lastly, conditionally run the post-node handler.
498 if (cond
&& act
->post
)
506 return(MDOC_HEAD
== n
->type
);
513 return(MDOC_BODY
== n
->type
);
521 prefix
= manacts
[n
->tok
].prefix
;
525 outflags
&= ~MMAN_spc
;
534 suffix
= manacts
[n
->tok
].suffix
;
537 outflags
&= ~MMAN_spc
;
549 post_percent(DECL_ARGS
)
552 if (pre_em
== manacts
[n
->tok
].pre
)
556 if (n
->prev
&& n
->prev
->tok
== n
->tok
&&
557 n
->next
->tok
== n
->tok
)
569 if (n
->parent
&& MDOC_Rs
== n
->parent
->tok
&&
570 n
->parent
->norm
->Rs
.quote_T
) {
572 outflags
&= ~MMAN_spc
;
582 if (n
->parent
&& MDOC_Rs
== n
->parent
->tok
&&
583 n
->parent
->norm
->Rs
.quote_T
) {
584 outflags
&= ~MMAN_spc
;
592 * Print before a section header.
598 if (MDOC_HEAD
!= n
->type
)
601 print_word(manacts
[n
->tok
].prefix
);
603 outflags
&= ~MMAN_spc
;
608 * Print subsequent a section header.
614 if (MDOC_HEAD
!= n
->type
)
616 outflags
&= ~MMAN_spc
;
619 if (MDOC_Sh
== n
->tok
&& SEC_AUTHORS
== n
->sec
)
620 outflags
&= ~(MMAN_An_split
| MMAN_An_nosplit
);
623 /* See mdoc_term.c, synopsis_pre() for comments. */
625 pre_syn(const struct mdoc_node
*n
)
628 if (NULL
== n
->prev
|| ! (MDOC_SYNPRETTY
& n
->flags
))
631 if (n
->prev
->tok
== n
->tok
&&
639 switch (n
->prev
->tok
) {
652 if (MDOC_Fn
!= n
->tok
&& MDOC_Fo
!= n
->tok
) {
667 switch (n
->norm
->An
.auth
) {
669 outflags
&= ~MMAN_An_nosplit
;
670 outflags
|= MMAN_An_split
;
673 outflags
&= ~MMAN_An_split
;
674 outflags
|= MMAN_An_nosplit
;
677 if (MMAN_An_split
& outflags
)
679 else if (SEC_AUTHORS
== n
->sec
&&
680 ! (MMAN_An_nosplit
& outflags
))
681 outflags
|= MMAN_An_split
;
690 outflags
&= ~MMAN_spc
;
692 outflags
&= ~MMAN_spc
;
700 if (0 == n
->norm
->Bd
.comp
)
702 if (DISP_unfilled
== n
->norm
->Bd
.type
||
703 DISP_literal
== n
->norm
->Bd
.type
) {
709 print_offs(n
->norm
->Bd
.offs
);
720 if (DISP_unfilled
== n
->norm
->Bd
.type
||
721 DISP_literal
== n
->norm
->Bd
.type
) {
740 switch (n
->norm
->Bf
.font
) {
758 if (MDOC_BODY
== n
->type
)
781 if (MDOC_BODY
== n
->type
)
782 outflags
&= ~MMAN_Bk
;
790 switch (n
->norm
->Bl
.type
) {
792 n
->norm
->Bl
.count
= 0;
803 for (icol
= 0; icol
< n
->norm
->Bl
.ncols
; icol
++)
813 switch (n
->norm
->Bl
.type
) {
815 n
->norm
->Bl
.count
= 0;
841 print_word(n
->string
);
842 outflags
&= ~MMAN_spc
;
848 outflags
&= ~MMAN_spc
;
850 outflags
&= ~MMAN_spc
;
851 print_word(n
->string
);
860 print_word(".RS 6n");
886 if (MDOC_HEAD
== n
->type
|| MDOC_BODY
== n
->type
)
887 outflags
&= ~MMAN_spc
;
894 if (MDOC_Fa
== n
->tok
)
901 if (NULL
!= (n
= n
->next
))
911 if (NULL
!= n
->next
&& MDOC_Fa
== n
->next
->tok
)
938 outflags
&= ~MMAN_spc
;
947 if (0 == n
->nchild
&& NULL
!= n
->next
&&
948 n
->next
->line
== n
->line
)
949 outflags
&= ~MMAN_spc
;
965 outflags
&= ~MMAN_spc
;
967 outflags
&= ~MMAN_spc
;
980 if (MDOC_SYNPRETTY
& n
->flags
) {
998 outflags
&= ~MMAN_spc
;
1000 outflags
&= ~MMAN_spc
;
1037 if (MDOC_SYNPRETTY
& n
->flags
) {
1040 print_word("#include <");
1041 outflags
&= ~MMAN_spc
;
1044 outflags
&= ~MMAN_spc
;
1054 if (MDOC_SYNPRETTY
& n
->flags
) {
1055 outflags
&= ~MMAN_spc
;
1058 outflags
|= MMAN_br
;
1061 outflags
&= ~MMAN_spc
;
1069 const struct mdoc_node
*bln
;
1073 outflags
|= MMAN_nl
;
1074 bln
= n
->parent
->parent
;
1075 switch (bln
->norm
->Bl
.type
) {
1077 if (bln
->norm
->Bl
.comp
)
1078 outflags
|= MMAN_br
;
1080 outflags
|= MMAN_sp
;
1087 if (bln
->norm
->Bl
.comp
)
1088 outflags
|= MMAN_br
;
1090 outflags
|= MMAN_sp
;
1091 if (bln
->norm
->Bl
.type
== LIST_diag
)
1092 print_word(".B \"");
1094 print_word(".R \"");
1095 outflags
&= ~MMAN_spc
;
1102 print_width(bln
->norm
->Bl
.width
, NULL
, 0);
1103 outflags
|= MMAN_nl
;
1105 if (LIST_bullet
== bln
->norm
->Bl
.type
)
1112 print_width(bln
->norm
->Bl
.width
, NULL
, 0);
1113 outflags
|= MMAN_nl
;
1114 print_count(&bln
->norm
->Bl
.count
);
1117 print_width(bln
->norm
->Bl
.width
, n
->child
, 6);
1120 print_width(bln
->norm
->Bl
.width
, NULL
, 8);
1125 outflags
|= MMAN_nl
;
1135 const struct mdoc_node
*bln
;
1137 bln
= n
->parent
->parent
;
1141 switch (bln
->norm
->Bl
.type
) {
1143 outflags
&= ~MMAN_spc
;
1147 outflags
|= MMAN_br
;
1154 if (LIST_column
== bln
->norm
->Bl
.type
&&
1157 outflags
&= ~MMAN_spc
;
1169 if (SEC_LIBRARY
== n
->sec
)
1170 outflags
|= MMAN_br
;
1176 const struct mdoc_node
*link
, *descr
;
1178 if (NULL
== (link
= n
->child
))
1181 if (NULL
!= (descr
= link
->next
)) {
1183 while (NULL
!= descr
) {
1184 print_word(descr
->string
);
1185 descr
= descr
->next
;
1192 print_word(link
->string
);
1209 if (MDOC_BLOCK
== n
->type
)
1211 if (MDOC_ELEM
!= n
->type
&& MDOC_HEAD
!= n
->type
)
1213 if (NULL
== n
->child
&& NULL
== m
->name
)
1216 if (NULL
== n
->child
)
1217 print_word(m
->name
);
1225 if (MDOC_ELEM
!= n
->type
&& MDOC_HEAD
!= n
->type
)
1234 outflags
|= MMAN_spc_force
;
1242 outflags
&= ~MMAN_spc
;
1250 outflags
&= ~MMAN_spc
;
1257 outflags
|= MMAN_nl
;
1258 if (MDOC_It
== n
->parent
->tok
)
1262 outflags
|= MMAN_nl
;
1270 if (SEC_SEE_ALSO
== n
->sec
) {
1271 outflags
|= MMAN_nl
;
1273 outflags
|= MMAN_nl
;
1282 assert(n
->child
&& MDOC_TEXT
== n
->child
->type
);
1283 if (0 == strcmp("on", n
->child
->string
))
1284 outflags
|= MMAN_Sm
| MMAN_spc
;
1286 outflags
&= ~MMAN_Sm
;
1294 outflags
|= MMAN_nl
;
1303 outflags
|= MMAN_nl
;
1318 if (MDOC_SYNPRETTY
& n
->flags
) {
1337 if (MDOC_SYNPRETTY
& n
->flags
&& MDOC_BODY
!= n
->type
)
1353 outflags
&= ~MMAN_spc
;
1364 print_word(manacts
[n
->tok
].prefix
);
1365 if (NULL
== n
->child
)
1367 outflags
&= ~MMAN_spc
;
1369 outflags
&= ~MMAN_spc
;