Bug Summary

File:src/usr.bin/mandoc/mdoc_html.c
Warning:line 545, column 3
Value stored to 't' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.4 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mdoc_html.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 1 -pic-is-pie -mframe-pointer=all -relaxed-aliasing -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/usr.bin/mandoc/obj -resource-dir /usr/local/llvm16/lib/clang/16 -internal-isystem /usr/local/llvm16/lib/clang/16/include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir=/usr/src/usr.bin/mandoc/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fcf-protection=branch -fno-jump-tables -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ben/Projects/scan/2024-01-11-140451-98009-1 -x c /usr/src/usr.bin/mandoc/mdoc_html.c
1/* $OpenBSD: mdoc_html.c,v 1.225 2022/07/06 16:02:52 schwarze Exp $ */
2/*
3 * Copyright (c) 2014-2022 Ingo Schwarze <schwarze@openbsd.org>
4 * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
5 * Copyright (c) 2022 Anna Vyalkova <cyber@sysrq.in>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 *
19 * HTML formatter for mdoc(7) used by mandoc(1).
20 */
21#include <sys/types.h>
22
23#include <assert.h>
24#include <ctype.h>
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <unistd.h>
29
30#include "mandoc_aux.h"
31#include "mandoc.h"
32#include "roff.h"
33#include "mdoc.h"
34#include "out.h"
35#include "html.h"
36#include "main.h"
37
38#define MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
const struct roff_meta *meta, \
39 struct roff_node *n, \
40 struct html *h
41
42#ifndef MIN
43#define MIN(a,b)(( (a)<(b))?(a):(b)) ((/*CONSTCOND*/(a)<(b))?(a):(b))
44#endif
45
46struct mdoc_html_act {
47 int (*pre)(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
48 void (*post)(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
49};
50
51static void print_mdoc_head(const struct roff_meta *,
52 struct html *);
53static void print_mdoc_node(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
54static void print_mdoc_nodelist(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
55static void synopsis_pre(struct html *, struct roff_node *);
56
57static void mdoc_root_post(const struct roff_meta *,
58 struct html *);
59static int mdoc_root_pre(const struct roff_meta *,
60 struct html *);
61
62static void mdoc__x_post(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
63static int mdoc__x_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
64static int mdoc_abort_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
65static int mdoc_ad_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
66static int mdoc_an_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
67static int mdoc_ap_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
68static int mdoc_ar_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
69static int mdoc_bd_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
70static int mdoc_bf_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
71static void mdoc_bk_post(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
72static int mdoc_bk_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
73static int mdoc_bl_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
74static int mdoc_cd_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
75static int mdoc_code_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
76static int mdoc_d1_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
77static int mdoc_fa_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
78static int mdoc_fd_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
79static int mdoc_fl_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
80static int mdoc_fn_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
81static int mdoc_ft_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
82static int mdoc_em_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
83static void mdoc_eo_post(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
84static int mdoc_eo_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
85static int mdoc_ex_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
86static void mdoc_fo_post(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
87static int mdoc_fo_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
88static int mdoc_igndelim_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
89static int mdoc_in_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
90static int mdoc_it_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
91static int mdoc_lb_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
92static int mdoc_lk_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
93static int mdoc_mt_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
94static int mdoc_nd_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
95static int mdoc_nm_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
96static int mdoc_no_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
97static int mdoc_ns_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
98static int mdoc_pa_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
99static void mdoc_pf_post(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
100static int mdoc_pp_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
101static void mdoc_quote_post(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
102static int mdoc_quote_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
103static int mdoc_rs_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
104static int mdoc_sh_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
105static int mdoc_skip_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
106static int mdoc_sm_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
107static int mdoc_ss_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
108static int mdoc_st_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
109static int mdoc_sx_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
110static int mdoc_sy_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
111static int mdoc_tg_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
112static int mdoc_va_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
113static int mdoc_vt_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
114static int mdoc_xr_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
115static int mdoc_xx_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
);
116
117static const struct mdoc_html_act mdoc_html_acts[MDOC_MAX - MDOC_Dd] = {
118 {NULL((void *)0), NULL((void *)0)}, /* Dd */
119 {NULL((void *)0), NULL((void *)0)}, /* Dt */
120 {NULL((void *)0), NULL((void *)0)}, /* Os */
121 {mdoc_sh_pre, NULL((void *)0) }, /* Sh */
122 {mdoc_ss_pre, NULL((void *)0) }, /* Ss */
123 {mdoc_pp_pre, NULL((void *)0)}, /* Pp */
124 {mdoc_d1_pre, NULL((void *)0)}, /* D1 */
125 {mdoc_d1_pre, NULL((void *)0)}, /* Dl */
126 {mdoc_bd_pre, NULL((void *)0)}, /* Bd */
127 {NULL((void *)0), NULL((void *)0)}, /* Ed */
128 {mdoc_bl_pre, NULL((void *)0)}, /* Bl */
129 {NULL((void *)0), NULL((void *)0)}, /* El */
130 {mdoc_it_pre, NULL((void *)0)}, /* It */
131 {mdoc_ad_pre, NULL((void *)0)}, /* Ad */
132 {mdoc_an_pre, NULL((void *)0)}, /* An */
133 {mdoc_ap_pre, NULL((void *)0)}, /* Ap */
134 {mdoc_ar_pre, NULL((void *)0)}, /* Ar */
135 {mdoc_cd_pre, NULL((void *)0)}, /* Cd */
136 {mdoc_code_pre, NULL((void *)0)}, /* Cm */
137 {mdoc_code_pre, NULL((void *)0)}, /* Dv */
138 {mdoc_code_pre, NULL((void *)0)}, /* Er */
139 {mdoc_code_pre, NULL((void *)0)}, /* Ev */
140 {mdoc_ex_pre, NULL((void *)0)}, /* Ex */
141 {mdoc_fa_pre, NULL((void *)0)}, /* Fa */
142 {mdoc_fd_pre, NULL((void *)0)}, /* Fd */
143 {mdoc_fl_pre, NULL((void *)0)}, /* Fl */
144 {mdoc_fn_pre, NULL((void *)0)}, /* Fn */
145 {mdoc_ft_pre, NULL((void *)0)}, /* Ft */
146 {mdoc_code_pre, NULL((void *)0)}, /* Ic */
147 {mdoc_in_pre, NULL((void *)0)}, /* In */
148 {mdoc_code_pre, NULL((void *)0)}, /* Li */
149 {mdoc_nd_pre, NULL((void *)0)}, /* Nd */
150 {mdoc_nm_pre, NULL((void *)0)}, /* Nm */
151 {mdoc_quote_pre, mdoc_quote_post}, /* Op */
152 {mdoc_abort_pre, NULL((void *)0)}, /* Ot */
153 {mdoc_pa_pre, NULL((void *)0)}, /* Pa */
154 {mdoc_ex_pre, NULL((void *)0)}, /* Rv */
155 {mdoc_st_pre, NULL((void *)0)}, /* St */
156 {mdoc_va_pre, NULL((void *)0)}, /* Va */
157 {mdoc_vt_pre, NULL((void *)0)}, /* Vt */
158 {mdoc_xr_pre, NULL((void *)0)}, /* Xr */
159 {mdoc__x_pre, mdoc__x_post}, /* %A */
160 {mdoc__x_pre, mdoc__x_post}, /* %B */
161 {mdoc__x_pre, mdoc__x_post}, /* %D */
162 {mdoc__x_pre, mdoc__x_post}, /* %I */
163 {mdoc__x_pre, mdoc__x_post}, /* %J */
164 {mdoc__x_pre, mdoc__x_post}, /* %N */
165 {mdoc__x_pre, mdoc__x_post}, /* %O */
166 {mdoc__x_pre, mdoc__x_post}, /* %P */
167 {mdoc__x_pre, mdoc__x_post}, /* %R */
168 {mdoc__x_pre, mdoc__x_post}, /* %T */
169 {mdoc__x_pre, mdoc__x_post}, /* %V */
170 {NULL((void *)0), NULL((void *)0)}, /* Ac */
171 {mdoc_quote_pre, mdoc_quote_post}, /* Ao */
172 {mdoc_quote_pre, mdoc_quote_post}, /* Aq */
173 {mdoc_xx_pre, NULL((void *)0)}, /* At */
174 {NULL((void *)0), NULL((void *)0)}, /* Bc */
175 {mdoc_bf_pre, NULL((void *)0)}, /* Bf */
176 {mdoc_quote_pre, mdoc_quote_post}, /* Bo */
177 {mdoc_quote_pre, mdoc_quote_post}, /* Bq */
178 {mdoc_xx_pre, NULL((void *)0)}, /* Bsx */
179 {mdoc_xx_pre, NULL((void *)0)}, /* Bx */
180 {mdoc_skip_pre, NULL((void *)0)}, /* Db */
181 {NULL((void *)0), NULL((void *)0)}, /* Dc */
182 {mdoc_quote_pre, mdoc_quote_post}, /* Do */
183 {mdoc_quote_pre, mdoc_quote_post}, /* Dq */
184 {NULL((void *)0), NULL((void *)0)}, /* Ec */ /* FIXME: no space */
185 {NULL((void *)0), NULL((void *)0)}, /* Ef */
186 {mdoc_em_pre, NULL((void *)0)}, /* Em */
187 {mdoc_eo_pre, mdoc_eo_post}, /* Eo */
188 {mdoc_xx_pre, NULL((void *)0)}, /* Fx */
189 {mdoc_no_pre, NULL((void *)0)}, /* Ms */
190 {mdoc_no_pre, NULL((void *)0)}, /* No */
191 {mdoc_ns_pre, NULL((void *)0)}, /* Ns */
192 {mdoc_xx_pre, NULL((void *)0)}, /* Nx */
193 {mdoc_xx_pre, NULL((void *)0)}, /* Ox */
194 {NULL((void *)0), NULL((void *)0)}, /* Pc */
195 {mdoc_igndelim_pre, mdoc_pf_post}, /* Pf */
196 {mdoc_quote_pre, mdoc_quote_post}, /* Po */
197 {mdoc_quote_pre, mdoc_quote_post}, /* Pq */
198 {NULL((void *)0), NULL((void *)0)}, /* Qc */
199 {mdoc_quote_pre, mdoc_quote_post}, /* Ql */
200 {mdoc_quote_pre, mdoc_quote_post}, /* Qo */
201 {mdoc_quote_pre, mdoc_quote_post}, /* Qq */
202 {NULL((void *)0), NULL((void *)0)}, /* Re */
203 {mdoc_rs_pre, NULL((void *)0)}, /* Rs */
204 {NULL((void *)0), NULL((void *)0)}, /* Sc */
205 {mdoc_quote_pre, mdoc_quote_post}, /* So */
206 {mdoc_quote_pre, mdoc_quote_post}, /* Sq */
207 {mdoc_sm_pre, NULL((void *)0)}, /* Sm */
208 {mdoc_sx_pre, NULL((void *)0)}, /* Sx */
209 {mdoc_sy_pre, NULL((void *)0)}, /* Sy */
210 {NULL((void *)0), NULL((void *)0)}, /* Tn */
211 {mdoc_xx_pre, NULL((void *)0)}, /* Ux */
212 {NULL((void *)0), NULL((void *)0)}, /* Xc */
213 {NULL((void *)0), NULL((void *)0)}, /* Xo */
214 {mdoc_fo_pre, mdoc_fo_post}, /* Fo */
215 {NULL((void *)0), NULL((void *)0)}, /* Fc */
216 {mdoc_quote_pre, mdoc_quote_post}, /* Oo */
217 {NULL((void *)0), NULL((void *)0)}, /* Oc */
218 {mdoc_bk_pre, mdoc_bk_post}, /* Bk */
219 {NULL((void *)0), NULL((void *)0)}, /* Ek */
220 {NULL((void *)0), NULL((void *)0)}, /* Bt */
221 {NULL((void *)0), NULL((void *)0)}, /* Hf */
222 {mdoc_em_pre, NULL((void *)0)}, /* Fr */
223 {NULL((void *)0), NULL((void *)0)}, /* Ud */
224 {mdoc_lb_pre, NULL((void *)0)}, /* Lb */
225 {mdoc_abort_pre, NULL((void *)0)}, /* Lp */
226 {mdoc_lk_pre, NULL((void *)0)}, /* Lk */
227 {mdoc_mt_pre, NULL((void *)0)}, /* Mt */
228 {mdoc_quote_pre, mdoc_quote_post}, /* Brq */
229 {mdoc_quote_pre, mdoc_quote_post}, /* Bro */
230 {NULL((void *)0), NULL((void *)0)}, /* Brc */
231 {mdoc__x_pre, mdoc__x_post}, /* %C */
232 {mdoc_skip_pre, NULL((void *)0)}, /* Es */
233 {mdoc_quote_pre, mdoc_quote_post}, /* En */
234 {mdoc_xx_pre, NULL((void *)0)}, /* Dx */
235 {mdoc__x_pre, mdoc__x_post}, /* %Q */
236 {mdoc__x_pre, mdoc__x_post}, /* %U */
237 {NULL((void *)0), NULL((void *)0)}, /* Ta */
238 {mdoc_tg_pre, NULL((void *)0)}, /* Tg */
239};
240
241
242/*
243 * See the same function in mdoc_term.c for documentation.
244 */
245static void
246synopsis_pre(struct html *h, struct roff_node *n)
247{
248 struct roff_node *np;
249
250 if ((n->flags & NODE_SYNPRETTY(1 << 7)) == 0 ||
251 (np = roff_node_prev(n)) == NULL((void *)0))
252 return;
253
254 if (np->tok == n->tok &&
255 MDOC_Fo != n->tok &&
256 MDOC_Ft != n->tok &&
257 MDOC_Fn != n->tok) {
258 print_otag(h, TAG_BR, "");
259 return;
260 }
261
262 switch (np->tok) {
263 case MDOC_Fd:
264 case MDOC_Fn:
265 case MDOC_Fo:
266 case MDOC_In:
267 case MDOC_Vt:
268 break;
269 case MDOC_Ft:
270 if (n->tok != MDOC_Fn && n->tok != MDOC_Fo)
271 break;
272 /* FALLTHROUGH */
273 default:
274 print_otag(h, TAG_BR, "");
275 return;
276 }
277 html_close_paragraph(h);
278 print_otag(h, TAG_P, "c", "Pp");
279}
280
281void
282html_mdoc(void *arg, const struct roff_meta *mdoc)
283{
284 struct html *h;
285 struct roff_node *n;
286 struct tag *t;
287
288 h = (struct html *)arg;
289 n = mdoc->first->child;
290
291 if ((h->oflags & HTML_FRAGMENT(1 << 0)) == 0) {
292 print_gen_decls(h);
293 print_otag(h, TAG_HTML, "");
294 t = print_otag(h, TAG_HEAD, "");
295 print_mdoc_head(mdoc, h);
296 print_tagq(h, t);
297 if (n != NULL((void *)0) && n->type == ROFFT_COMMENT)
298 print_gen_comment(h, n);
299 print_otag(h, TAG_BODY, "");
300 }
301
302 mdoc_root_pre(mdoc, h);
303 t = print_otag(h, TAG_MAIN, "c", "manual-text");
304 print_mdoc_nodelist(mdoc, n, h);
305 print_tagq(h, t);
306 mdoc_root_post(mdoc, h);
307 print_tagq(h, NULL((void *)0));
308}
309
310static void
311print_mdoc_head(const struct roff_meta *meta, struct html *h)
312{
313 char *cp;
314
315 print_gen_head(h);
316
317 if (meta->arch != NULL((void *)0) && meta->msec != NULL((void *)0))
318 mandoc_asprintf(&cp, "%s(%s) (%s)", meta->title,
319 meta->msec, meta->arch);
320 else if (meta->msec != NULL((void *)0))
321 mandoc_asprintf(&cp, "%s(%s)", meta->title, meta->msec);
322 else if (meta->arch != NULL((void *)0))
323 mandoc_asprintf(&cp, "%s (%s)", meta->title, meta->arch);
324 else
325 cp = mandoc_strdup(meta->title);
326
327 print_otag(h, TAG_TITLE, "");
328 print_text(h, cp);
329 free(cp);
330}
331
332static void
333print_mdoc_nodelist(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
334{
335
336 while (n != NULL((void *)0)) {
337 print_mdoc_node(meta, n, h);
338 n = n->next;
339 }
340}
341
342static void
343print_mdoc_node(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
344{
345 struct tag *t;
346 int child;
347
348 if (n->type == ROFFT_COMMENT || n->flags & NODE_NOPRT(1 << 10))
349 return;
350
351 if ((n->flags & NODE_NOFILL(1 << 8)) == 0)
352 html_fillmode(h, ROFF_fi);
353 else if (html_fillmode(h, ROFF_nf) == ROFF_nf &&
354 n->tok != ROFF_fi && n->flags & NODE_LINE(1 << 3))
355 print_endline(h);
356
357 child = 1;
358 n->flags &= ~NODE_ENDED(1 << 1);
359 switch (n->type) {
360 case ROFFT_TEXT:
361 if (n->flags & NODE_LINE(1 << 3)) {
362 switch (*n->string) {
363 case '\0':
364 h->col = 1;
365 print_endline(h);
366 return;
367 case ' ':
368 if ((h->flags & HTML_NONEWLINE(1 << 9)) == 0 &&
369 (n->flags & NODE_NOFILL(1 << 8)) == 0)
370 print_otag(h, TAG_BR, "");
371 break;
372 default:
373 break;
374 }
375 }
376 t = h->tag;
377 t->refcnt++;
378 if (n->flags & NODE_DELIMC(1 << 5))
379 h->flags |= HTML_NOSPACE(1 << 0);
380 if (n->flags & NODE_HREF(1 << 12))
381 print_tagged_text(h, n->string, n);
382 else
383 print_text(h, n->string);
384 if (n->flags & NODE_DELIMO(1 << 4))
385 h->flags |= HTML_NOSPACE(1 << 0);
386 break;
387 case ROFFT_EQN:
388 t = h->tag;
389 t->refcnt++;
390 print_eqn(h, n->eqn);
391 break;
392 case ROFFT_TBL:
393 /*
394 * This will take care of initialising all of the table
395 * state data for the first table, then tearing it down
396 * for the last one.
397 */
398 print_tbl(h, n->span);
399 return;
400 default:
401 /*
402 * Close out the current table, if it's open, and unset
403 * the "meta" table state. This will be reopened on the
404 * next table element.
405 */
406 if (h->tblt != NULL((void *)0))
407 print_tblclose(h);
408 assert(h->tblt == NULL)((h->tblt == ((void *)0)) ? (void)0 : __assert2("/usr/src/usr.bin/mandoc/mdoc_html.c"
, 408, __func__, "h->tblt == NULL"))
;
409 t = h->tag;
410 t->refcnt++;
411 if (n->tok < ROFF_MAX) {
412 roff_html_pre(h, n);
413 t->refcnt--;
414 print_stagq(h, t);
415 return;
416 }
417 assert(n->tok >= MDOC_Dd && n->tok < MDOC_MAX)((n->tok >= MDOC_Dd && n->tok < MDOC_MAX)
? (void)0 : __assert2("/usr/src/usr.bin/mandoc/mdoc_html.c",
417, __func__, "n->tok >= MDOC_Dd && n->tok < MDOC_MAX"
))
;
418 if (mdoc_html_acts[n->tok - MDOC_Dd].pre != NULL((void *)0) &&
419 (n->end == ENDBODY_NOT || n->child != NULL((void *)0)))
420 child = (*mdoc_html_acts[n->tok - MDOC_Dd].pre)(meta,
421 n, h);
422 break;
423 }
424
425 if (h->flags & HTML_KEEP(1 << 2) && n->flags & NODE_LINE(1 << 3)) {
426 h->flags &= ~HTML_KEEP(1 << 2);
427 h->flags |= HTML_PREKEEP(1 << 3);
428 }
429
430 if (child && n->child != NULL((void *)0))
431 print_mdoc_nodelist(meta, n->child, h);
432
433 t->refcnt--;
434 print_stagq(h, t);
435
436 switch (n->type) {
437 case ROFFT_TEXT:
438 case ROFFT_EQN:
439 break;
440 default:
441 if (mdoc_html_acts[n->tok - MDOC_Dd].post == NULL((void *)0) ||
442 n->flags & NODE_ENDED(1 << 1))
443 break;
444 (*mdoc_html_acts[n->tok - MDOC_Dd].post)(meta, n, h);
445 if (n->end != ENDBODY_NOT)
446 n->body->flags |= NODE_ENDED(1 << 1);
447 break;
448 }
449}
450
451static void
452mdoc_root_post(const struct roff_meta *meta, struct html *h)
453{
454 struct tag *t;
455
456 t = print_otag(h, TAG_DIV, "cr?", "foot", "doc-pagefooter",
457 "aria-label", "Manual footer line");
458
459 print_otag(h, TAG_SPAN, "c", "foot-left");
460 print_stagq(h, t);
461
462 print_otag(h, TAG_SPAN, "c", "foot-date");
463 print_text(h, meta->date);
464 print_stagq(h, t);
465
466 print_otag(h, TAG_SPAN, "c", "foot-os");
467 print_text(h, meta->os);
468 print_tagq(h, t);
469}
470
471static int
472mdoc_root_pre(const struct roff_meta *meta, struct html *h)
473{
474 struct tag *t;
475 char *volume, *title;
476
477 if (NULL((void *)0) == meta->arch)
478 volume = mandoc_strdup(meta->vol);
479 else
480 mandoc_asprintf(&volume, "%s (%s)",
481 meta->vol, meta->arch);
482
483 if (NULL((void *)0) == meta->msec)
484 title = mandoc_strdup(meta->title);
485 else
486 mandoc_asprintf(&title, "%s(%s)",
487 meta->title, meta->msec);
488
489 t = print_otag(h, TAG_DIV, "cr?", "head", "doc-pageheader",
490 "aria-label", "Manual header line");
491
492 print_otag(h, TAG_SPAN, "c", "head-ltitle");
493 print_text(h, title);
494 print_stagq(h, t);
495
496 print_otag(h, TAG_SPAN, "c", "head-vol");
497 print_text(h, volume);
498 print_stagq(h, t);
499
500 print_otag(h, TAG_SPAN, "c", "head-rtitle");
501 print_text(h, title);
502 print_tagq(h, t);
503
504 free(title);
505 free(volume);
506 return 1;
507}
508
509static int
510mdoc_code_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
511{
512 print_otag_id(h, TAG_CODE, roff_name[n->tok], n);
513 return 1;
514}
515
516static int
517mdoc_sh_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
518{
519 struct roff_node *sn, *subn;
520 struct tag *t, *tnav, *tsec, *tsub;
521 char *id;
522 int sc;
523
524 switch (n->type) {
525 case ROFFT_BLOCK:
526 html_close_paragraph(h);
527 if ((h->oflags & HTML_TOC(1 << 1)) == 0 ||
528 h->flags & HTML_TOCDONE(1 << 11) ||
529 n->sec <= SEC_SYNOPSIS) {
530 print_otag(h, TAG_SECTION, "c", "Sh");
531 break;
532 }
533 h->flags |= HTML_TOCDONE(1 << 11);
534 sc = 0;
535 for (sn = n->next; sn != NULL((void *)0); sn = sn->next)
536 if (sn->sec == SEC_CUSTOM)
537 if (++sc == 2)
538 break;
539 if (sc < 2)
540 break;
541 tnav = print_otag(h, TAG_NAV, "r", "doc-toc");
542 t = print_otag(h, TAG_H2, "c", "Sh");
543 print_text(h, "TABLE OF CONTENTS");
544 print_tagq(h, t);
545 t = print_otag(h, TAG_UL, "c", "Bl-compact");
Value stored to 't' is never read
546 for (sn = n; sn != NULL((void *)0); sn = sn->next) {
547 tsec = print_otag(h, TAG_LI, "");
548 id = html_make_id(sn->head, 0);
549 tsub = print_otag(h, TAG_A, "hR", id);
550 free(id);
551 print_mdoc_nodelist(meta, sn->head->child, h);
552 print_tagq(h, tsub);
553 tsub = NULL((void *)0);
554 for (subn = sn->body->child; subn != NULL((void *)0);
555 subn = subn->next) {
556 if (subn->tok != MDOC_Ss)
557 continue;
558 id = html_make_id(subn->head, 0);
559 if (id == NULL((void *)0))
560 continue;
561 if (tsub == NULL((void *)0))
562 print_otag(h, TAG_UL,
563 "c", "Bl-compact");
564 tsub = print_otag(h, TAG_LI, "");
565 print_otag(h, TAG_A, "hR", id);
566 free(id);
567 print_mdoc_nodelist(meta,
568 subn->head->child, h);
569 print_tagq(h, tsub);
570 }
571 print_tagq(h, tsec);
572 }
573 print_tagq(h, tnav);
574 print_otag(h, TAG_SECTION, "c", "Sh");
575 break;
576 case ROFFT_HEAD:
577 print_otag_id(h, TAG_H2, "Sh", n);
578 break;
579 case ROFFT_BODY:
580 if (n->sec == SEC_AUTHORS)
581 h->flags &= ~(HTML_SPLIT(1 << 8)|HTML_NOSPLIT(1 << 7));
582 break;
583 default:
584 break;
585 }
586 return 1;
587}
588
589static int
590mdoc_ss_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
591{
592 switch (n->type) {
593 case ROFFT_BLOCK:
594 html_close_paragraph(h);
595 print_otag(h, TAG_SECTION, "c", "Ss");
596 break;
597 case ROFFT_HEAD:
598 print_otag_id(h, TAG_H3, "Ss", n);
599 break;
600 case ROFFT_BODY:
601 break;
602 default:
603 abort();
604 }
605 return 1;
606}
607
608static int
609mdoc_fl_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
610{
611 struct roff_node *nn;
612
613 print_otag_id(h, TAG_CODE, "Fl", n);
614 print_text(h, "\\-");
615 if (n->child != NULL((void *)0) ||
616 ((nn = roff_node_next(n)) != NULL((void *)0) &&
617 nn->type != ROFFT_TEXT &&
618 (nn->flags & NODE_LINE(1 << 3)) == 0))
619 h->flags |= HTML_NOSPACE(1 << 0);
620
621 return 1;
622}
623
624static int
625mdoc_nd_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
626{
627 switch (n->type) {
628 case ROFFT_BLOCK:
629 return 1;
630 case ROFFT_HEAD:
631 return 0;
632 case ROFFT_BODY:
633 break;
634 default:
635 abort();
636 }
637 print_text(h, "\\(em");
638 print_otag(h, TAG_SPAN, "cr", "Nd", "doc-subtitle");
639 return 1;
640}
641
642static int
643mdoc_nm_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
644{
645 switch (n->type) {
646 case ROFFT_BLOCK:
647 break;
648 case ROFFT_HEAD:
649 print_otag(h, TAG_TD, "");
650 /* FALLTHROUGH */
651 case ROFFT_ELEM:
652 print_otag(h, TAG_CODE, "c", "Nm");
653 return 1;
654 case ROFFT_BODY:
655 print_otag(h, TAG_TD, "");
656 return 1;
657 default:
658 abort();
659 }
660 html_close_paragraph(h);
661 synopsis_pre(h, n);
662 print_otag(h, TAG_TABLE, "c", "Nm");
663 print_otag(h, TAG_TR, "");
664 return 1;
665}
666
667static int
668mdoc_xr_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
669{
670 char *name, *section, *label;
671
672 if (n->child == NULL((void *)0))
673 return 0;
674
675 name = n->child->string;
676 if (n->child->next != NULL((void *)0)) {
677 section = n->child->next->string;
678 mandoc_asprintf(&label, "%s, section %s", name, section);
679 } else
680 section = label = NULL((void *)0);
681
682 if (h->base_man1)
683 print_otag(h, TAG_A, "chM?", "Xr",
684 name, section, "aria-label", label);
685 else
686 print_otag(h, TAG_A, "c?", "Xr", "aria-label", label);
687
688 free(label);
689 print_text(h, name);
690
691 if (section == NULL((void *)0))
692 return 0;
693
694 h->flags |= HTML_NOSPACE(1 << 0);
695 print_text(h, "(");
696 h->flags |= HTML_NOSPACE(1 << 0);
697 print_text(h, section);
698 h->flags |= HTML_NOSPACE(1 << 0);
699 print_text(h, ")");
700 return 0;
701}
702
703static int
704mdoc_tg_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
705{
706 char *id;
707
708 if ((id = html_make_id(n, 1)) != NULL((void *)0)) {
709 print_tagq(h, print_otag(h, TAG_MARK, "i", id));
710 free(id);
711 }
712 return 0;
713}
714
715static int
716mdoc_ns_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
717{
718
719 if ( ! (NODE_LINE(1 << 3) & n->flags))
720 h->flags |= HTML_NOSPACE(1 << 0);
721 return 1;
722}
723
724static int
725mdoc_ar_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
726{
727 print_otag(h, TAG_VAR, "c", "Ar");
728 return 1;
729}
730
731static int
732mdoc_xx_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
733{
734 print_otag(h, TAG_SPAN, "c", "Ux");
735 return 1;
736}
737
738static int
739mdoc_it_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
740{
741 const struct roff_node *bl;
742 enum mdoc_list type;
743
744 bl = n->parent;
745 while (bl->tok != MDOC_Bl)
746 bl = bl->parent;
747 type = bl->norm->Bl.type;
748
749 switch (type) {
750 case LIST_bullet:
751 case LIST_dash:
752 case LIST_hyphen:
753 case LIST_item:
754 case LIST_enum:
755 switch (n->type) {
756 case ROFFT_HEAD:
757 return 0;
758 case ROFFT_BODY:
759 print_otag_id(h, TAG_LI, NULL((void *)0), n);
760 break;
761 default:
762 break;
763 }
764 break;
765 case LIST_diag:
766 case LIST_hang:
767 case LIST_inset:
768 case LIST_ohang:
769 switch (n->type) {
770 case ROFFT_HEAD:
771 print_otag_id(h, TAG_DT, NULL((void *)0), n);
772 break;
773 case ROFFT_BODY:
774 print_otag(h, TAG_DD, "");
775 break;
776 default:
777 break;
778 }
779 break;
780 case LIST_tag:
781 switch (n->type) {
782 case ROFFT_HEAD:
783 print_otag_id(h, TAG_DT, NULL((void *)0), n);
784 break;
785 case ROFFT_BODY:
786 if (n->child == NULL((void *)0)) {
787 print_otag(h, TAG_DD, "s", "width", "auto");
788 print_text(h, "\\ ");
789 } else
790 print_otag(h, TAG_DD, "");
791 break;
792 default:
793 break;
794 }
795 break;
796 case LIST_column:
797 switch (n->type) {
798 case ROFFT_HEAD:
799 break;
800 case ROFFT_BODY:
801 print_otag(h, TAG_TD, "");
802 break;
803 default:
804 print_otag_id(h, TAG_TR, NULL((void *)0), n);
805 }
806 default:
807 break;
808 }
809
810 return 1;
811}
812
813static int
814mdoc_bl_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
815{
816 char cattr[32];
817 struct mdoc_bl *bl;
818 enum htmltag elemtype;
819
820 switch (n->type) {
821 case ROFFT_BLOCK:
822 html_close_paragraph(h);
823 break;
824 case ROFFT_HEAD:
825 return 0;
826 case ROFFT_BODY:
827 return 1;
828 default:
829 abort();
830 }
831
832 bl = &n->norm->Bl;
833 switch (bl->type) {
834 case LIST_bullet:
835 elemtype = TAG_UL;
836 (void)strlcpy(cattr, "Bl-bullet", sizeof(cattr));
837 break;
838 case LIST_dash:
839 case LIST_hyphen:
840 elemtype = TAG_UL;
841 (void)strlcpy(cattr, "Bl-dash", sizeof(cattr));
842 break;
843 case LIST_item:
844 elemtype = TAG_UL;
845 (void)strlcpy(cattr, "Bl-item", sizeof(cattr));
846 break;
847 case LIST_enum:
848 elemtype = TAG_OL;
849 (void)strlcpy(cattr, "Bl-enum", sizeof(cattr));
850 break;
851 case LIST_diag:
852 elemtype = TAG_DL;
853 (void)strlcpy(cattr, "Bl-diag", sizeof(cattr));
854 break;
855 case LIST_hang:
856 elemtype = TAG_DL;
857 (void)strlcpy(cattr, "Bl-hang", sizeof(cattr));
858 break;
859 case LIST_inset:
860 elemtype = TAG_DL;
861 (void)strlcpy(cattr, "Bl-inset", sizeof(cattr));
862 break;
863 case LIST_ohang:
864 elemtype = TAG_DL;
865 (void)strlcpy(cattr, "Bl-ohang", sizeof(cattr));
866 break;
867 case LIST_tag:
868 if (bl->offs)
869 print_otag(h, TAG_DIV, "c", "Bd-indent");
870 print_otag_id(h, TAG_DL,
871 bl->comp ? "Bl-tag Bl-compact" : "Bl-tag", n->body);
872 return 1;
873 case LIST_column:
874 elemtype = TAG_TABLE;
875 (void)strlcpy(cattr, "Bl-column", sizeof(cattr));
876 break;
877 default:
878 abort();
879 }
880 if (bl->offs != NULL((void *)0))
881 (void)strlcat(cattr, " Bd-indent", sizeof(cattr));
882 if (bl->comp)
883 (void)strlcat(cattr, " Bl-compact", sizeof(cattr));
884 print_otag_id(h, elemtype, cattr, n->body);
885 return 1;
886}
887
888static int
889mdoc_ex_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
890{
891 if (roff_node_prev(n) != NULL((void *)0))
892 print_otag(h, TAG_BR, "");
893 return 1;
894}
895
896static int
897mdoc_st_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
898{
899 print_otag(h, TAG_SPAN, "c", "St");
900 return 1;
901}
902
903static int
904mdoc_em_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
905{
906 print_otag_id(h, TAG_I, "Em", n);
907 return 1;
908}
909
910static int
911mdoc_d1_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
912{
913 switch (n->type) {
914 case ROFFT_BLOCK:
915 html_close_paragraph(h);
916 return 1;
917 case ROFFT_HEAD:
918 return 0;
919 case ROFFT_BODY:
920 break;
921 default:
922 abort();
923 }
924 print_otag_id(h, TAG_DIV, "Bd Bd-indent", n);
925 if (n->tok == MDOC_Dl)
926 print_otag(h, TAG_CODE, "c", "Li");
927 return 1;
928}
929
930static int
931mdoc_sx_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
932{
933 char *id;
934
935 id = html_make_id(n, 0);
936 print_otag(h, TAG_A, "chR", "Sx", id);
937 free(id);
938 return 1;
939}
940
941static int
942mdoc_bd_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
943{
944 char buf[20];
945 struct roff_node *nn;
946 int comp;
947
948 switch (n->type) {
949 case ROFFT_BLOCK:
950 html_close_paragraph(h);
951 return 1;
952 case ROFFT_HEAD:
953 return 0;
954 case ROFFT_BODY:
955 break;
956 default:
957 abort();
958 }
959
960 /* Handle preceding whitespace. */
961
962 comp = n->norm->Bd.comp;
963 for (nn = n; nn != NULL((void *)0) && comp == 0; nn = nn->parent) {
964 if (nn->type != ROFFT_BLOCK)
965 continue;
966 if (nn->tok == MDOC_Sh || nn->tok == MDOC_Ss)
967 comp = 1;
968 if (roff_node_prev(nn) != NULL((void *)0))
969 break;
970 }
971 (void)strlcpy(buf, "Bd", sizeof(buf));
972 if (comp == 0)
973 (void)strlcat(buf, " Pp", sizeof(buf));
974
975 /* Handle the -offset argument. */
976
977 if (n->norm->Bd.offs != NULL((void *)0) &&
978 strcmp(n->norm->Bd.offs, "left") != 0)
979 (void)strlcat(buf, " Bd-indent", sizeof(buf));
980
981 if (n->norm->Bd.type == DISP_literal)
982 (void)strlcat(buf, " Li", sizeof(buf));
983
984 print_otag_id(h, TAG_DIV, buf, n);
985 return 1;
986}
987
988static int
989mdoc_pa_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
990{
991 print_otag(h, TAG_SPAN, "c", "Pa");
992 return 1;
993}
994
995static int
996mdoc_ad_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
997{
998 print_otag(h, TAG_SPAN, "c", "Ad");
999 return 1;
1000}
1001
1002static int
1003mdoc_an_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1004{
1005 if (n->norm->An.auth == AUTH_split) {
1006 h->flags &= ~HTML_NOSPLIT(1 << 7);
1007 h->flags |= HTML_SPLIT(1 << 8);
1008 return 0;
1009 }
1010 if (n->norm->An.auth == AUTH_nosplit) {
1011 h->flags &= ~HTML_SPLIT(1 << 8);
1012 h->flags |= HTML_NOSPLIT(1 << 7);
1013 return 0;
1014 }
1015
1016 if (h->flags & HTML_SPLIT(1 << 8))
1017 print_otag(h, TAG_BR, "");
1018
1019 if (n->sec == SEC_AUTHORS && ! (h->flags & HTML_NOSPLIT(1 << 7)))
1020 h->flags |= HTML_SPLIT(1 << 8);
1021
1022 print_otag(h, TAG_SPAN, "c", "An");
1023 return 1;
1024}
1025
1026static int
1027mdoc_cd_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1028{
1029 synopsis_pre(h, n);
1030 print_otag(h, TAG_CODE, "c", "Cd");
1031 return 1;
1032}
1033
1034static int
1035mdoc_fa_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1036{
1037 const struct roff_node *nn;
1038 struct tag *t;
1039
1040 if (n->parent->tok != MDOC_Fo) {
1041 print_otag(h, TAG_VAR, "c", "Fa");
1042 return 1;
1043 }
1044 for (nn = n->child; nn != NULL((void *)0); nn = nn->next) {
1045 t = print_otag(h, TAG_VAR, "c", "Fa");
1046 print_text(h, nn->string);
1047 print_tagq(h, t);
1048 if (nn->next != NULL((void *)0)) {
1049 h->flags |= HTML_NOSPACE(1 << 0);
1050 print_text(h, ",");
1051 }
1052 }
1053 if (n->child != NULL((void *)0) &&
1054 (nn = roff_node_next(n)) != NULL((void *)0) &&
1055 nn->tok == MDOC_Fa) {
1056 h->flags |= HTML_NOSPACE(1 << 0);
1057 print_text(h, ",");
1058 }
1059 return 0;
1060}
1061
1062static int
1063mdoc_fd_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1064{
1065 struct tag *t;
1066 char *buf, *cp;
1067
1068 synopsis_pre(h, n);
1069
1070 if (NULL((void *)0) == (n = n->child))
1071 return 0;
1072
1073 assert(n->type == ROFFT_TEXT)((n->type == ROFFT_TEXT) ? (void)0 : __assert2("/usr/src/usr.bin/mandoc/mdoc_html.c"
, 1073, __func__, "n->type == ROFFT_TEXT"))
;
1074
1075 if (strcmp(n->string, "#include")) {
1076 print_otag(h, TAG_CODE, "c", "Fd");
1077 return 1;
1078 }
1079
1080 print_otag(h, TAG_CODE, "c", "In");
1081 print_text(h, n->string);
1082
1083 if (NULL((void *)0) != (n = n->next)) {
1084 assert(n->type == ROFFT_TEXT)((n->type == ROFFT_TEXT) ? (void)0 : __assert2("/usr/src/usr.bin/mandoc/mdoc_html.c"
, 1084, __func__, "n->type == ROFFT_TEXT"))
;
1085
1086 if (h->base_includes) {
1087 cp = n->string;
1088 if (*cp == '<' || *cp == '"')
1089 cp++;
1090 buf = mandoc_strdup(cp);
1091 cp = strchr(buf, '\0') - 1;
1092 if (cp >= buf && (*cp == '>' || *cp == '"'))
1093 *cp = '\0';
1094 t = print_otag(h, TAG_A, "chI", "In", buf);
1095 free(buf);
1096 } else
1097 t = print_otag(h, TAG_A, "c", "In");
1098
1099 print_text(h, n->string);
1100 print_tagq(h, t);
1101
1102 n = n->next;
1103 }
1104
1105 for ( ; n; n = n->next) {
1106 assert(n->type == ROFFT_TEXT)((n->type == ROFFT_TEXT) ? (void)0 : __assert2("/usr/src/usr.bin/mandoc/mdoc_html.c"
, 1106, __func__, "n->type == ROFFT_TEXT"))
;
1107 print_text(h, n->string);
1108 }
1109
1110 return 0;
1111}
1112
1113static int
1114mdoc_vt_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1115{
1116 if (n->type == ROFFT_BLOCK) {
1117 synopsis_pre(h, n);
1118 return 1;
1119 } else if (n->type == ROFFT_ELEM) {
1120 synopsis_pre(h, n);
1121 } else if (n->type == ROFFT_HEAD)
1122 return 0;
1123
1124 print_otag(h, TAG_VAR, "c", "Vt");
1125 return 1;
1126}
1127
1128static int
1129mdoc_ft_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1130{
1131 synopsis_pre(h, n);
1132 print_otag(h, TAG_VAR, "c", "Ft");
1133 return 1;
1134}
1135
1136static int
1137mdoc_fn_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1138{
1139 struct tag *t;
1140 char nbuf[BUFSIZ1024];
1141 const char *sp, *ep;
1142 int sz, pretty;
1143
1144 pretty = NODE_SYNPRETTY(1 << 7) & n->flags;
1145 synopsis_pre(h, n);
1146
1147 /* Split apart into type and name. */
1148 assert(n->child->string)((n->child->string) ? (void)0 : __assert2("/usr/src/usr.bin/mandoc/mdoc_html.c"
, 1148, __func__, "n->child->string"))
;
1149 sp = n->child->string;
1150
1151 ep = strchr(sp, ' ');
1152 if (NULL((void *)0) != ep) {
1153 t = print_otag(h, TAG_VAR, "c", "Ft");
1154
1155 while (ep) {
1156 sz = MIN((int)(ep - sp), BUFSIZ - 1)(( ((int)(ep - sp))<(1024 - 1))?((int)(ep - sp)):(1024 - 1
))
;
1157 (void)memcpy(nbuf, sp, (size_t)sz);
1158 nbuf[sz] = '\0';
1159 print_text(h, nbuf);
1160 sp = ++ep;
1161 ep = strchr(sp, ' ');
1162 }
1163 print_tagq(h, t);
1164 }
1165
1166 t = print_otag_id(h, TAG_CODE, "Fn", n);
1167
1168 if (sp)
1169 print_text(h, sp);
1170
1171 print_tagq(h, t);
1172
1173 h->flags |= HTML_NOSPACE(1 << 0);
1174 print_text(h, "(");
1175 h->flags |= HTML_NOSPACE(1 << 0);
1176
1177 for (n = n->child->next; n; n = n->next) {
1178 if (NODE_SYNPRETTY(1 << 7) & n->flags)
1179 t = print_otag(h, TAG_VAR, "cs", "Fa",
1180 "white-space", "nowrap");
1181 else
1182 t = print_otag(h, TAG_VAR, "c", "Fa");
1183 print_text(h, n->string);
1184 print_tagq(h, t);
1185 if (n->next) {
1186 h->flags |= HTML_NOSPACE(1 << 0);
1187 print_text(h, ",");
1188 }
1189 }
1190
1191 h->flags |= HTML_NOSPACE(1 << 0);
1192 print_text(h, ")");
1193
1194 if (pretty) {
1195 h->flags |= HTML_NOSPACE(1 << 0);
1196 print_text(h, ";");
1197 }
1198
1199 return 0;
1200}
1201
1202static int
1203mdoc_sm_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1204{
1205
1206 if (NULL((void *)0) == n->child)
1207 h->flags ^= HTML_NONOSPACE(1 << 4);
1208 else if (0 == strcmp("on", n->child->string))
1209 h->flags &= ~HTML_NONOSPACE(1 << 4);
1210 else
1211 h->flags |= HTML_NONOSPACE(1 << 4);
1212
1213 if ( ! (HTML_NONOSPACE(1 << 4) & h->flags))
1214 h->flags &= ~HTML_NOSPACE(1 << 0);
1215
1216 return 0;
1217}
1218
1219static int
1220mdoc_skip_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1221{
1222
1223 return 0;
1224}
1225
1226static int
1227mdoc_pp_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1228{
1229 char *id;
1230
1231 if (n->flags & NODE_NOFILL(1 << 8)) {
1232 print_endline(h);
1233 if (n->flags & NODE_ID(1 << 11))
1234 mdoc_tg_pre(meta, n, h);
1235 else {
1236 h->col = 1;
1237 print_endline(h);
1238 }
1239 } else {
1240 html_close_paragraph(h);
1241 id = n->flags & NODE_ID(1 << 11) ? html_make_id(n, 1) : NULL((void *)0);
1242 print_otag(h, TAG_P, "ci", "Pp", id);
1243 free(id);
1244 }
1245 return 0;
1246}
1247
1248static int
1249mdoc_lk_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1250{
1251 const struct roff_node *link, *descr, *punct;
1252 struct tag *t;
1253
1254 if ((link = n->child) == NULL((void *)0))
1255 return 0;
1256
1257 /* Find beginning of trailing punctuation. */
1258 punct = n->last;
1259 while (punct != link && punct->flags & NODE_DELIMC(1 << 5))
1260 punct = punct->prev;
1261 punct = punct->next;
1262
1263 /* Link target and link text. */
1264 descr = link->next;
1265 if (descr == punct)
1266 descr = link; /* no text */
1267 t = print_otag(h, TAG_A, "ch", "Lk", link->string);
1268 do {
1269 if (descr->flags & (NODE_DELIMC(1 << 5) | NODE_DELIMO(1 << 4)))
1270 h->flags |= HTML_NOSPACE(1 << 0);
1271 print_text(h, descr->string);
1272 descr = descr->next;
1273 } while (descr != punct);
1274 print_tagq(h, t);
1275
1276 /* Trailing punctuation. */
1277 while (punct != NULL((void *)0)) {
1278 h->flags |= HTML_NOSPACE(1 << 0);
1279 print_text(h, punct->string);
1280 punct = punct->next;
1281 }
1282 return 0;
1283}
1284
1285static int
1286mdoc_mt_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1287{
1288 struct tag *t;
1289 char *cp;
1290
1291 for (n = n->child; n; n = n->next) {
1292 assert(n->type == ROFFT_TEXT)((n->type == ROFFT_TEXT) ? (void)0 : __assert2("/usr/src/usr.bin/mandoc/mdoc_html.c"
, 1292, __func__, "n->type == ROFFT_TEXT"))
;
1293 mandoc_asprintf(&cp, "mailto:%s", n->string);
1294 t = print_otag(h, TAG_A, "ch", "Mt", cp);
1295 print_text(h, n->string);
1296 print_tagq(h, t);
1297 free(cp);
1298 }
1299 return 0;
1300}
1301
1302static int
1303mdoc_fo_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1304{
1305 struct tag *t;
1306
1307 switch (n->type) {
1308 case ROFFT_BLOCK:
1309 synopsis_pre(h, n);
1310 return 1;
1311 case ROFFT_HEAD:
1312 if (n->child != NULL((void *)0)) {
1313 t = print_otag_id(h, TAG_CODE, "Fn", n);
1314 print_text(h, n->child->string);
1315 print_tagq(h, t);
1316 }
1317 return 0;
1318 case ROFFT_BODY:
1319 h->flags |= HTML_NOSPACE(1 << 0);
1320 print_text(h, "(");
1321 h->flags |= HTML_NOSPACE(1 << 0);
1322 return 1;
1323 default:
1324 abort();
1325 }
1326}
1327
1328static void
1329mdoc_fo_post(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1330{
1331 if (n->type != ROFFT_BODY)
1332 return;
1333 h->flags |= HTML_NOSPACE(1 << 0);
1334 print_text(h, ")");
1335 h->flags |= HTML_NOSPACE(1 << 0);
1336 print_text(h, ";");
1337}
1338
1339static int
1340mdoc_in_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1341{
1342 struct tag *t;
1343
1344 synopsis_pre(h, n);
1345 print_otag(h, TAG_CODE, "c", "In");
1346
1347 /*
1348 * The first argument of the `In' gets special treatment as
1349 * being a linked value. Subsequent values are printed
1350 * afterward. groff does similarly. This also handles the case
1351 * of no children.
1352 */
1353
1354 if (NODE_SYNPRETTY(1 << 7) & n->flags && NODE_LINE(1 << 3) & n->flags)
1355 print_text(h, "#include");
1356
1357 print_text(h, "<");
1358 h->flags |= HTML_NOSPACE(1 << 0);
1359
1360 if (NULL((void *)0) != (n = n->child)) {
1361 assert(n->type == ROFFT_TEXT)((n->type == ROFFT_TEXT) ? (void)0 : __assert2("/usr/src/usr.bin/mandoc/mdoc_html.c"
, 1361, __func__, "n->type == ROFFT_TEXT"))
;
1362
1363 if (h->base_includes)
1364 t = print_otag(h, TAG_A, "chI", "In", n->string);
1365 else
1366 t = print_otag(h, TAG_A, "c", "In");
1367 print_text(h, n->string);
1368 print_tagq(h, t);
1369
1370 n = n->next;
1371 }
1372
1373 h->flags |= HTML_NOSPACE(1 << 0);
1374 print_text(h, ">");
1375
1376 for ( ; n; n = n->next) {
1377 assert(n->type == ROFFT_TEXT)((n->type == ROFFT_TEXT) ? (void)0 : __assert2("/usr/src/usr.bin/mandoc/mdoc_html.c"
, 1377, __func__, "n->type == ROFFT_TEXT"))
;
1378 print_text(h, n->string);
1379 }
1380 return 0;
1381}
1382
1383static int
1384mdoc_va_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1385{
1386 print_otag(h, TAG_VAR, "c", "Va");
1387 return 1;
1388}
1389
1390static int
1391mdoc_ap_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1392{
1393 h->flags |= HTML_NOSPACE(1 << 0);
1394 print_text(h, "\\(aq");
1395 h->flags |= HTML_NOSPACE(1 << 0);
1396 return 1;
1397}
1398
1399static int
1400mdoc_bf_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1401{
1402 const char *cattr;
1403
1404 switch (n->type) {
1405 case ROFFT_BLOCK:
1406 html_close_paragraph(h);
1407 return 1;
1408 case ROFFT_HEAD:
1409 return 0;
1410 case ROFFT_BODY:
1411 break;
1412 default:
1413 abort();
1414 }
1415
1416 if (FONT_Em == n->norm->Bf.font)
1417 cattr = "Bf Em";
1418 else if (FONT_Sy == n->norm->Bf.font)
1419 cattr = "Bf Sy";
1420 else if (FONT_Li == n->norm->Bf.font)
1421 cattr = "Bf Li";
1422 else
1423 cattr = "Bf No";
1424
1425 /* Cannot use TAG_SPAN because it may contain blocks. */
1426 print_otag(h, TAG_DIV, "c", cattr);
1427 return 1;
1428}
1429
1430static int
1431mdoc_igndelim_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1432{
1433 h->flags |= HTML_IGNDELIM(1 << 1);
1434 return 1;
1435}
1436
1437static void
1438mdoc_pf_post(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1439{
1440 if ( ! (n->next == NULL((void *)0) || n->next->flags & NODE_LINE(1 << 3)))
1441 h->flags |= HTML_NOSPACE(1 << 0);
1442}
1443
1444static int
1445mdoc_rs_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1446{
1447 switch (n->type) {
1448 case ROFFT_BLOCK:
1449 if (n->sec == SEC_SEE_ALSO)
1450 html_close_paragraph(h);
1451 break;
1452 case ROFFT_HEAD:
1453 return 0;
1454 case ROFFT_BODY:
1455 if (n->sec == SEC_SEE_ALSO)
1456 print_otag(h, TAG_P, "c", "Pp");
1457 print_otag(h, TAG_CITE, "c", "Rs");
1458 break;
1459 default:
1460 abort();
1461 }
1462 return 1;
1463}
1464
1465static int
1466mdoc_no_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1467{
1468 print_otag_id(h, TAG_SPAN, roff_name[n->tok], n);
1469 return 1;
1470}
1471
1472static int
1473mdoc_sy_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1474{
1475 print_otag_id(h, TAG_B, "Sy", n);
1476 return 1;
1477}
1478
1479static int
1480mdoc_lb_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1481{
1482 if (n->sec == SEC_LIBRARY &&
1483 n->flags & NODE_LINE(1 << 3) &&
1484 roff_node_prev(n) != NULL((void *)0))
1485 print_otag(h, TAG_BR, "");
1486
1487 print_otag(h, TAG_SPAN, "c", "Lb");
1488 return 1;
1489}
1490
1491static int
1492mdoc__x_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1493{
1494 struct roff_node *nn;
1495 const char *cattr;
1496 enum htmltag t;
1497
1498 t = TAG_SPAN;
1499
1500 switch (n->tok) {
1501 case MDOC__A:
1502 cattr = "RsA";
1503 if ((nn = roff_node_prev(n)) != NULL((void *)0) && nn->tok == MDOC__A &&
1504 ((nn = roff_node_next(n)) == NULL((void *)0) || nn->tok != MDOC__A))
1505 print_text(h, "and");
1506 break;
1507 case MDOC__B:
1508 t = TAG_I;
1509 cattr = "RsB";
1510 break;
1511 case MDOC__C:
1512 cattr = "RsC";
1513 break;
1514 case MDOC__D:
1515 cattr = "RsD";
1516 break;
1517 case MDOC__I:
1518 t = TAG_I;
1519 cattr = "RsI";
1520 break;
1521 case MDOC__J:
1522 t = TAG_I;
1523 cattr = "RsJ";
1524 break;
1525 case MDOC__N:
1526 cattr = "RsN";
1527 break;
1528 case MDOC__O:
1529 cattr = "RsO";
1530 break;
1531 case MDOC__P:
1532 cattr = "RsP";
1533 break;
1534 case MDOC__Q:
1535 cattr = "RsQ";
1536 break;
1537 case MDOC__R:
1538 cattr = "RsR";
1539 break;
1540 case MDOC__T:
1541 cattr = "RsT";
1542 break;
1543 case MDOC__U:
1544 print_otag(h, TAG_A, "ch", "RsU", n->child->string);
1545 return 1;
1546 case MDOC__V:
1547 cattr = "RsV";
1548 break;
1549 default:
1550 abort();
1551 }
1552
1553 print_otag(h, t, "c", cattr);
1554 return 1;
1555}
1556
1557static void
1558mdoc__x_post(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1559{
1560 struct roff_node *nn;
1561
1562 if (n->tok == MDOC__A &&
1563 (nn = roff_node_next(n)) != NULL((void *)0) && nn->tok == MDOC__A &&
1564 ((nn = roff_node_next(nn)) == NULL((void *)0) || nn->tok != MDOC__A) &&
1565 ((nn = roff_node_prev(n)) == NULL((void *)0) || nn->tok != MDOC__A))
1566 return;
1567
1568 /* TODO: %U */
1569
1570 if (n->parent == NULL((void *)0) || n->parent->tok != MDOC_Rs)
1571 return;
1572
1573 h->flags |= HTML_NOSPACE(1 << 0);
1574 print_text(h, roff_node_next(n) ? "," : ".");
1575}
1576
1577static int
1578mdoc_bk_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1579{
1580
1581 switch (n->type) {
1582 case ROFFT_BLOCK:
1583 break;
1584 case ROFFT_HEAD:
1585 return 0;
1586 case ROFFT_BODY:
1587 if (n->parent->args != NULL((void *)0) || n->prev->child == NULL((void *)0))
1588 h->flags |= HTML_PREKEEP(1 << 3);
1589 break;
1590 default:
1591 abort();
1592 }
1593
1594 return 1;
1595}
1596
1597static void
1598mdoc_bk_post(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1599{
1600
1601 if (n->type == ROFFT_BODY)
1602 h->flags &= ~(HTML_KEEP(1 << 2) | HTML_PREKEEP(1 << 3));
1603}
1604
1605static int
1606mdoc_quote_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1607{
1608 if (n->type != ROFFT_BODY)
1609 return 1;
1610
1611 switch (n->tok) {
1612 case MDOC_Ao:
1613 case MDOC_Aq:
1614 print_text(h, n->child != NULL((void *)0) && n->child->next == NULL((void *)0) &&
1615 n->child->tok == MDOC_Mt ? "<" : "\\(la");
1616 break;
1617 case MDOC_Bro:
1618 case MDOC_Brq:
1619 print_text(h, "\\(lC");
1620 break;
1621 case MDOC_Bo:
1622 case MDOC_Bq:
1623 print_text(h, "\\(lB");
1624 break;
1625 case MDOC_Oo:
1626 case MDOC_Op:
1627 print_text(h, "\\(lB");
1628 /*
1629 * Give up on semantic markup for now.
1630 * We cannot use TAG_SPAN because .Oo may contain blocks.
1631 * We cannot use TAG_DIV because we might be in a
1632 * phrasing context (like .Dl or .Pp); we cannot
1633 * close out a .Pp at this point either because
1634 * that would break the line.
1635 */
1636 /* XXX print_otag(h, TAG_???, "c", "Op"); */
1637 break;
1638 case MDOC_En:
1639 if (NULL((void *)0) == n->norm->Es ||
1640 NULL((void *)0) == n->norm->Es->child)
1641 return 1;
1642 print_text(h, n->norm->Es->child->string);
1643 break;
1644 case MDOC_Do:
1645 case MDOC_Dq:
1646 print_text(h, "\\(lq");
1647 break;
1648 case MDOC_Qo:
1649 case MDOC_Qq:
1650 print_text(h, "\"");
1651 break;
1652 case MDOC_Po:
1653 case MDOC_Pq:
1654 print_text(h, "(");
1655 break;
1656 case MDOC_Ql:
1657 print_text(h, "\\(oq");
1658 h->flags |= HTML_NOSPACE(1 << 0);
1659 print_otag(h, TAG_CODE, "c", "Li");
1660 break;
1661 case MDOC_So:
1662 case MDOC_Sq:
1663 print_text(h, "\\(oq");
1664 break;
1665 default:
1666 abort();
1667 }
1668
1669 h->flags |= HTML_NOSPACE(1 << 0);
1670 return 1;
1671}
1672
1673static void
1674mdoc_quote_post(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1675{
1676
1677 if (n->type != ROFFT_BODY && n->type != ROFFT_ELEM)
1678 return;
1679
1680 h->flags |= HTML_NOSPACE(1 << 0);
1681
1682 switch (n->tok) {
1683 case MDOC_Ao:
1684 case MDOC_Aq:
1685 print_text(h, n->child != NULL((void *)0) && n->child->next == NULL((void *)0) &&
1686 n->child->tok == MDOC_Mt ? ">" : "\\(ra");
1687 break;
1688 case MDOC_Bro:
1689 case MDOC_Brq:
1690 print_text(h, "\\(rC");
1691 break;
1692 case MDOC_Oo:
1693 case MDOC_Op:
1694 case MDOC_Bo:
1695 case MDOC_Bq:
1696 print_text(h, "\\(rB");
1697 break;
1698 case MDOC_En:
1699 if (n->norm->Es == NULL((void *)0) ||
1700 n->norm->Es->child == NULL((void *)0) ||
1701 n->norm->Es->child->next == NULL((void *)0))
1702 h->flags &= ~HTML_NOSPACE(1 << 0);
1703 else
1704 print_text(h, n->norm->Es->child->next->string);
1705 break;
1706 case MDOC_Do:
1707 case MDOC_Dq:
1708 print_text(h, "\\(rq");
1709 break;
1710 case MDOC_Qo:
1711 case MDOC_Qq:
1712 print_text(h, "\"");
1713 break;
1714 case MDOC_Po:
1715 case MDOC_Pq:
1716 print_text(h, ")");
1717 break;
1718 case MDOC_Ql:
1719 case MDOC_So:
1720 case MDOC_Sq:
1721 print_text(h, "\\(cq");
1722 break;
1723 default:
1724 abort();
1725 }
1726}
1727
1728static int
1729mdoc_eo_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1730{
1731
1732 if (n->type != ROFFT_BODY)
1733 return 1;
1734
1735 if (n->end == ENDBODY_NOT &&
1736 n->parent->head->child == NULL((void *)0) &&
1737 n->child != NULL((void *)0) &&
1738 n->child->end != ENDBODY_NOT)
1739 print_text(h, "\\&");
1740 else if (n->end != ENDBODY_NOT ? n->child != NULL((void *)0) :
1741 n->parent->head->child != NULL((void *)0) && (n->child != NULL((void *)0) ||
1742 (n->parent->tail != NULL((void *)0) && n->parent->tail->child != NULL((void *)0))))
1743 h->flags |= HTML_NOSPACE(1 << 0);
1744 return 1;
1745}
1746
1747static void
1748mdoc_eo_post(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1749{
1750 int body, tail;
1751
1752 if (n->type != ROFFT_BODY)
1753 return;
1754
1755 if (n->end != ENDBODY_NOT) {
1756 h->flags &= ~HTML_NOSPACE(1 << 0);
1757 return;
1758 }
1759
1760 body = n->child != NULL((void *)0) || n->parent->head->child != NULL((void *)0);
1761 tail = n->parent->tail != NULL((void *)0) && n->parent->tail->child != NULL((void *)0);
1762
1763 if (body && tail)
1764 h->flags |= HTML_NOSPACE(1 << 0);
1765 else if ( ! tail)
1766 h->flags &= ~HTML_NOSPACE(1 << 0);
1767}
1768
1769static int
1770mdoc_abort_pre(MDOC_ARGSconst struct roff_meta *meta, struct roff_node *n, struct html
*h
)
1771{
1772 abort();
1773}