Annotation of mandoc/mdoc_term.c, Revision 1.62
1.62 ! kristaps 1: /* $Id: mdoc_term.c,v 1.61 2009/07/24 12:47:35 kristaps Exp $ */
1.1 kristaps 2: /*
1.7 kristaps 3: * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
1.1 kristaps 4: *
5: * Permission to use, copy, modify, and distribute this software for any
1.6 kristaps 6: * purpose with or without fee is hereby granted, provided that the above
7: * copyright notice and this permission notice appear in all copies.
1.1 kristaps 8: *
1.6 kristaps 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.
1.1 kristaps 16: */
17: #include <sys/types.h>
18:
19: #include <assert.h>
20: #include <ctype.h>
21: #include <err.h>
22: #include <stdio.h>
23: #include <stdlib.h>
24: #include <string.h>
25:
26: #include "term.h"
27: #include "mdoc.h"
28:
29: /* FIXME: macro arguments can be escaped. */
30:
31: #define TTYPE_PROG 0
32: #define TTYPE_CMD_FLAG 1
33: #define TTYPE_CMD_ARG 2
34: #define TTYPE_SECTION 3
35: #define TTYPE_FUNC_DECL 4
36: #define TTYPE_VAR_DECL 5
37: #define TTYPE_FUNC_TYPE 6
38: #define TTYPE_FUNC_NAME 7
39: #define TTYPE_FUNC_ARG 8
40: #define TTYPE_LINK 9
41: #define TTYPE_SSECTION 10
42: #define TTYPE_FILE 11
43: #define TTYPE_EMPH 12
44: #define TTYPE_CONFIG 13
45: #define TTYPE_CMD 14
46: #define TTYPE_INCLUDE 15
47: #define TTYPE_SYMB 16
48: #define TTYPE_SYMBOL 17
49: #define TTYPE_DIAG 18
50: #define TTYPE_LINK_ANCHOR 19
51: #define TTYPE_LINK_TEXT 20
52: #define TTYPE_REF_JOURNAL 21
1.56 kristaps 53: #define TTYPE_REF_TITLE 22
54: #define TTYPE_LIST 23
55: #define TTYPE_NMAX 24
1.1 kristaps 56:
57: const int ttypes[TTYPE_NMAX] = {
58: TERMP_BOLD, /* TTYPE_PROG */
59: TERMP_BOLD, /* TTYPE_CMD_FLAG */
60: TERMP_UNDER, /* TTYPE_CMD_ARG */
61: TERMP_BOLD, /* TTYPE_SECTION */
62: TERMP_BOLD, /* TTYPE_FUNC_DECL */
63: TERMP_UNDER, /* TTYPE_VAR_DECL */
64: TERMP_UNDER, /* TTYPE_FUNC_TYPE */
65: TERMP_BOLD, /* TTYPE_FUNC_NAME */
66: TERMP_UNDER, /* TTYPE_FUNC_ARG */
67: TERMP_UNDER, /* TTYPE_LINK */
68: TERMP_BOLD, /* TTYPE_SSECTION */
1.57 kristaps 69: TERMP_UNDER, /* TTYPE_FILE */
1.1 kristaps 70: TERMP_UNDER, /* TTYPE_EMPH */
71: TERMP_BOLD, /* TTYPE_CONFIG */
72: TERMP_BOLD, /* TTYPE_CMD */
73: TERMP_BOLD, /* TTYPE_INCLUDE */
74: TERMP_BOLD, /* TTYPE_SYMB */
75: TERMP_BOLD, /* TTYPE_SYMBOL */
76: TERMP_BOLD, /* TTYPE_DIAG */
77: TERMP_UNDER, /* TTYPE_LINK_ANCHOR */
78: TERMP_BOLD, /* TTYPE_LINK_TEXT */
79: TERMP_UNDER, /* TTYPE_REF_JOURNAL */
1.56 kristaps 80: TERMP_UNDER, /* TTYPE_REF_TITLE */
1.1 kristaps 81: TERMP_BOLD /* TTYPE_LIST */
82: };
83:
84: struct termpair {
85: struct termpair *ppair;
1.31 kristaps 86: int flag;
87: int count;
1.1 kristaps 88: };
89:
1.31 kristaps 90: #define DECL_ARGS struct termp *p, \
91: struct termpair *pair, \
92: const struct mdoc_meta *meta, \
93: const struct mdoc_node *node
1.1 kristaps 94:
95: struct termact {
96: int (*pre)(DECL_ARGS);
97: void (*post)(DECL_ARGS);
98: };
99:
1.31 kristaps 100: static void termp____post(DECL_ARGS);
1.61 kristaps 101: static void termp_an_post(DECL_ARGS);
1.31 kristaps 102: static void termp_aq_post(DECL_ARGS);
103: static void termp_bd_post(DECL_ARGS);
104: static void termp_bl_post(DECL_ARGS);
105: static void termp_bq_post(DECL_ARGS);
106: static void termp_brq_post(DECL_ARGS);
107: static void termp_bx_post(DECL_ARGS);
108: static void termp_d1_post(DECL_ARGS);
109: static void termp_dq_post(DECL_ARGS);
110: static void termp_fd_post(DECL_ARGS);
111: static void termp_fn_post(DECL_ARGS);
112: static void termp_fo_post(DECL_ARGS);
113: static void termp_ft_post(DECL_ARGS);
114: static void termp_in_post(DECL_ARGS);
115: static void termp_it_post(DECL_ARGS);
116: static void termp_lb_post(DECL_ARGS);
117: static void termp_op_post(DECL_ARGS);
118: static void termp_pf_post(DECL_ARGS);
119: static void termp_pq_post(DECL_ARGS);
120: static void termp_qq_post(DECL_ARGS);
121: static void termp_sh_post(DECL_ARGS);
122: static void termp_sq_post(DECL_ARGS);
123: static void termp_ss_post(DECL_ARGS);
124: static void termp_vt_post(DECL_ARGS);
125:
126: static int termp__j_pre(DECL_ARGS);
127: static int termp__t_pre(DECL_ARGS);
1.61 kristaps 128: static int termp_an_pre(DECL_ARGS);
1.31 kristaps 129: static int termp_ap_pre(DECL_ARGS);
130: static int termp_aq_pre(DECL_ARGS);
131: static int termp_ar_pre(DECL_ARGS);
132: static int termp_bd_pre(DECL_ARGS);
133: static int termp_bf_pre(DECL_ARGS);
134: static int termp_bq_pre(DECL_ARGS);
1.44 kristaps 135: static int termp_br_pre(DECL_ARGS);
1.31 kristaps 136: static int termp_brq_pre(DECL_ARGS);
137: static int termp_bt_pre(DECL_ARGS);
138: static int termp_cd_pre(DECL_ARGS);
139: static int termp_cm_pre(DECL_ARGS);
140: static int termp_d1_pre(DECL_ARGS);
141: static int termp_dq_pre(DECL_ARGS);
142: static int termp_em_pre(DECL_ARGS);
143: static int termp_ex_pre(DECL_ARGS);
144: static int termp_fa_pre(DECL_ARGS);
145: static int termp_fd_pre(DECL_ARGS);
146: static int termp_fl_pre(DECL_ARGS);
147: static int termp_fn_pre(DECL_ARGS);
148: static int termp_fo_pre(DECL_ARGS);
149: static int termp_ft_pre(DECL_ARGS);
150: static int termp_ic_pre(DECL_ARGS);
151: static int termp_in_pre(DECL_ARGS);
152: static int termp_it_pre(DECL_ARGS);
153: static int termp_lk_pre(DECL_ARGS);
154: static int termp_ms_pre(DECL_ARGS);
155: static int termp_mt_pre(DECL_ARGS);
156: static int termp_nd_pre(DECL_ARGS);
157: static int termp_nm_pre(DECL_ARGS);
158: static int termp_ns_pre(DECL_ARGS);
159: static int termp_op_pre(DECL_ARGS);
1.57 kristaps 160: static int termp_pa_pre(DECL_ARGS);
1.31 kristaps 161: static int termp_pf_pre(DECL_ARGS);
162: static int termp_pp_pre(DECL_ARGS);
163: static int termp_pq_pre(DECL_ARGS);
164: static int termp_qq_pre(DECL_ARGS);
165: static int termp_rs_pre(DECL_ARGS);
166: static int termp_rv_pre(DECL_ARGS);
167: static int termp_sh_pre(DECL_ARGS);
168: static int termp_sm_pre(DECL_ARGS);
1.45 kristaps 169: static int termp_sp_pre(DECL_ARGS);
1.31 kristaps 170: static int termp_sq_pre(DECL_ARGS);
171: static int termp_ss_pre(DECL_ARGS);
172: static int termp_sx_pre(DECL_ARGS);
173: static int termp_sy_pre(DECL_ARGS);
174: static int termp_ud_pre(DECL_ARGS);
175: static int termp_va_pre(DECL_ARGS);
176: static int termp_vt_pre(DECL_ARGS);
177: static int termp_xr_pre(DECL_ARGS);
178: static int termp_xx_pre(DECL_ARGS);
179:
1.1 kristaps 180: static const struct termact termacts[MDOC_MAX] = {
1.14 kristaps 181: { termp_ap_pre, NULL }, /* Ap */
1.1 kristaps 182: { NULL, NULL }, /* Dd */
183: { NULL, NULL }, /* Dt */
184: { NULL, NULL }, /* Os */
185: { termp_sh_pre, termp_sh_post }, /* Sh */
186: { termp_ss_pre, termp_ss_post }, /* Ss */
187: { termp_pp_pre, NULL }, /* Pp */
188: { termp_d1_pre, termp_d1_post }, /* D1 */
189: { termp_d1_pre, termp_d1_post }, /* Dl */
190: { termp_bd_pre, termp_bd_post }, /* Bd */
191: { NULL, NULL }, /* Ed */
192: { NULL, termp_bl_post }, /* Bl */
193: { NULL, NULL }, /* El */
194: { termp_it_pre, termp_it_post }, /* It */
195: { NULL, NULL }, /* Ad */
1.61 kristaps 196: { termp_an_pre, termp_an_post }, /* An */
1.1 kristaps 197: { termp_ar_pre, NULL }, /* Ar */
198: { termp_cd_pre, NULL }, /* Cd */
199: { termp_cm_pre, NULL }, /* Cm */
200: { NULL, NULL }, /* Dv */
201: { NULL, NULL }, /* Er */
202: { NULL, NULL }, /* Ev */
203: { termp_ex_pre, NULL }, /* Ex */
204: { termp_fa_pre, NULL }, /* Fa */
205: { termp_fd_pre, termp_fd_post }, /* Fd */
206: { termp_fl_pre, NULL }, /* Fl */
207: { termp_fn_pre, termp_fn_post }, /* Fn */
208: { termp_ft_pre, termp_ft_post }, /* Ft */
209: { termp_ic_pre, NULL }, /* Ic */
210: { termp_in_pre, termp_in_post }, /* In */
211: { NULL, NULL }, /* Li */
212: { termp_nd_pre, NULL }, /* Nd */
213: { termp_nm_pre, NULL }, /* Nm */
214: { termp_op_pre, termp_op_post }, /* Op */
215: { NULL, NULL }, /* Ot */
1.57 kristaps 216: { termp_pa_pre, NULL }, /* Pa */
1.1 kristaps 217: { termp_rv_pre, NULL }, /* Rv */
1.36 kristaps 218: { NULL, NULL }, /* St */
1.1 kristaps 219: { termp_va_pre, NULL }, /* Va */
220: { termp_vt_pre, termp_vt_post }, /* Vt */
221: { termp_xr_pre, NULL }, /* Xr */
222: { NULL, termp____post }, /* %A */
223: { NULL, termp____post }, /* %B */
224: { NULL, termp____post }, /* %D */
225: { NULL, termp____post }, /* %I */
226: { termp__j_pre, termp____post }, /* %J */
227: { NULL, termp____post }, /* %N */
228: { NULL, termp____post }, /* %O */
229: { NULL, termp____post }, /* %P */
230: { NULL, termp____post }, /* %R */
1.56 kristaps 231: { termp__t_pre, termp____post }, /* %T */
1.1 kristaps 232: { NULL, termp____post }, /* %V */
233: { NULL, NULL }, /* Ac */
234: { termp_aq_pre, termp_aq_post }, /* Ao */
235: { termp_aq_pre, termp_aq_post }, /* Aq */
1.35 kristaps 236: { NULL, NULL }, /* At */
1.1 kristaps 237: { NULL, NULL }, /* Bc */
238: { termp_bf_pre, NULL }, /* Bf */
239: { termp_bq_pre, termp_bq_post }, /* Bo */
240: { termp_bq_pre, termp_bq_post }, /* Bq */
1.26 kristaps 241: { termp_xx_pre, NULL }, /* Bsx */
1.1 kristaps 242: { NULL, termp_bx_post }, /* Bx */
243: { NULL, NULL }, /* Db */
244: { NULL, NULL }, /* Dc */
245: { termp_dq_pre, termp_dq_post }, /* Do */
246: { termp_dq_pre, termp_dq_post }, /* Dq */
247: { NULL, NULL }, /* Ec */
248: { NULL, NULL }, /* Ef */
249: { termp_em_pre, NULL }, /* Em */
250: { NULL, NULL }, /* Eo */
1.26 kristaps 251: { termp_xx_pre, NULL }, /* Fx */
1.1 kristaps 252: { termp_ms_pre, NULL }, /* Ms */
253: { NULL, NULL }, /* No */
254: { termp_ns_pre, NULL }, /* Ns */
1.26 kristaps 255: { termp_xx_pre, NULL }, /* Nx */
256: { termp_xx_pre, NULL }, /* Ox */
1.1 kristaps 257: { NULL, NULL }, /* Pc */
258: { termp_pf_pre, termp_pf_post }, /* Pf */
259: { termp_pq_pre, termp_pq_post }, /* Po */
260: { termp_pq_pre, termp_pq_post }, /* Pq */
261: { NULL, NULL }, /* Qc */
262: { termp_sq_pre, termp_sq_post }, /* Ql */
263: { termp_qq_pre, termp_qq_post }, /* Qo */
264: { termp_qq_pre, termp_qq_post }, /* Qq */
265: { NULL, NULL }, /* Re */
266: { termp_rs_pre, NULL }, /* Rs */
267: { NULL, NULL }, /* Sc */
268: { termp_sq_pre, termp_sq_post }, /* So */
269: { termp_sq_pre, termp_sq_post }, /* Sq */
270: { termp_sm_pre, NULL }, /* Sm */
271: { termp_sx_pre, NULL }, /* Sx */
272: { termp_sy_pre, NULL }, /* Sy */
273: { NULL, NULL }, /* Tn */
1.26 kristaps 274: { termp_xx_pre, NULL }, /* Ux */
1.1 kristaps 275: { NULL, NULL }, /* Xc */
276: { NULL, NULL }, /* Xo */
277: { termp_fo_pre, termp_fo_post }, /* Fo */
278: { NULL, NULL }, /* Fc */
279: { termp_op_pre, termp_op_post }, /* Oo */
280: { NULL, NULL }, /* Oc */
281: { NULL, NULL }, /* Bk */
282: { NULL, NULL }, /* Ek */
283: { termp_bt_pre, NULL }, /* Bt */
284: { NULL, NULL }, /* Hf */
285: { NULL, NULL }, /* Fr */
286: { termp_ud_pre, NULL }, /* Ud */
1.37 kristaps 287: { NULL, termp_lb_post }, /* Lb */
1.14 kristaps 288: { termp_pp_pre, NULL }, /* Lp */
1.1 kristaps 289: { termp_lk_pre, NULL }, /* Lk */
290: { termp_mt_pre, NULL }, /* Mt */
291: { termp_brq_pre, termp_brq_post }, /* Brq */
292: { termp_brq_pre, termp_brq_post }, /* Bro */
293: { NULL, NULL }, /* Brc */
294: { NULL, NULL }, /* %C */
295: { NULL, NULL }, /* Es */
296: { NULL, NULL }, /* En */
1.26 kristaps 297: { termp_xx_pre, NULL }, /* Dx */
1.1 kristaps 298: { NULL, NULL }, /* %Q */
1.44 kristaps 299: { termp_br_pre, NULL }, /* br */
1.45 kristaps 300: { termp_sp_pre, NULL }, /* sp */
1.1 kristaps 301: };
302:
1.2 kristaps 303: #ifdef __linux__
1.9 kristaps 304: extern size_t strlcpy(char *, const char *, size_t);
305: extern size_t strlcat(char *, const char *, size_t);
1.2 kristaps 306: #endif
307:
1.1 kristaps 308: static int arg_hasattr(int, const struct mdoc_node *);
309: static int arg_getattrs(const int *, int *, size_t,
310: const struct mdoc_node *);
311: static int arg_getattr(int, const struct mdoc_node *);
312: static size_t arg_offset(const struct mdoc_argv *);
313: static size_t arg_width(const struct mdoc_argv *, int);
314: static int arg_listtype(const struct mdoc_node *);
1.54 kristaps 315: static void fmt_block_vspace(struct termp *,
1.1 kristaps 316: const struct mdoc_node *,
317: const struct mdoc_node *);
1.3 kristaps 318: static void print_node(DECL_ARGS);
319: static void print_head(struct termp *,
1.1 kristaps 320: const struct mdoc_meta *);
1.3 kristaps 321: static void print_body(DECL_ARGS);
322: static void print_foot(struct termp *,
1.1 kristaps 323: const struct mdoc_meta *);
324:
325:
326: int
327: mdoc_run(struct termp *p, const struct mdoc *m)
328: {
1.9 kristaps 329: /*
330: * Main output function. When this is called, assume that the
331: * tree is properly formed.
332: */
1.3 kristaps 333: print_head(p, mdoc_meta(m));
1.14 kristaps 334: assert(mdoc_node(m));
335: assert(MDOC_ROOT == mdoc_node(m)->type);
336: if (mdoc_node(m)->child)
337: print_body(p, NULL, mdoc_meta(m), mdoc_node(m)->child);
1.3 kristaps 338: print_foot(p, mdoc_meta(m));
339: return(1);
1.1 kristaps 340: }
341:
342:
1.3 kristaps 343: static void
1.1 kristaps 344: print_body(DECL_ARGS)
345: {
346:
1.3 kristaps 347: print_node(p, pair, meta, node);
1.1 kristaps 348: if ( ! node->next)
1.3 kristaps 349: return;
350: print_body(p, pair, meta, node->next);
1.1 kristaps 351: }
352:
353:
1.3 kristaps 354: static void
1.1 kristaps 355: print_node(DECL_ARGS)
356: {
357: int dochild;
358: struct termpair npair;
1.30 kristaps 359: size_t offset, rmargin;
1.1 kristaps 360:
361: dochild = 1;
1.29 kristaps 362: offset = p->offset;
1.30 kristaps 363: rmargin = p->rmargin;
1.29 kristaps 364:
1.1 kristaps 365: npair.ppair = pair;
366: npair.flag = 0;
367: npair.count = 0;
368:
1.46 kristaps 369: /*
370: * Note on termpair. This allows a pre function to set a termp
371: * flag that is automatically unset after the body, but before
372: * the post function. Thus, if a pre uses a termpair flag, it
373: * must be reapplied in the post for use.
374: */
375:
1.1 kristaps 376: if (MDOC_TEXT != node->type) {
377: if (termacts[node->tok].pre)
378: if ( ! (*termacts[node->tok].pre)(p, &npair, meta, node))
379: dochild = 0;
380: } else /* MDOC_TEXT == node->type */
381: term_word(p, node->string);
382:
383: /* Children. */
384:
1.28 kristaps 385: p->flags |= npair.flag;
1.1 kristaps 386:
387: if (dochild && node->child)
388: print_body(p, &npair, meta, node->child);
389:
1.46 kristaps 390: p->flags &= ~npair.flag;
391:
1.1 kristaps 392: /* Post-processing. */
393:
394: if (MDOC_TEXT != node->type)
395: if (termacts[node->tok].post)
396: (*termacts[node->tok].post)(p, &npair, meta, node);
1.29 kristaps 397:
398: p->offset = offset;
1.30 kristaps 399: p->rmargin = rmargin;
1.1 kristaps 400: }
401:
402:
1.3 kristaps 403: static void
1.1 kristaps 404: print_foot(struct termp *p, const struct mdoc_meta *meta)
405: {
406: struct tm *tm;
407: char *buf, *os;
408:
1.9 kristaps 409: /*
410: * Output the footer in new-groff style, that is, three columns
411: * with the middle being the manual date and flanking columns
412: * being the operating system:
413: *
414: * SYSTEM DATE SYSTEM
415: */
416:
1.1 kristaps 417: if (NULL == (buf = malloc(p->rmargin)))
418: err(1, "malloc");
419: if (NULL == (os = malloc(p->rmargin)))
420: err(1, "malloc");
421:
422: tm = localtime(&meta->date);
423:
1.42 kristaps 424: if (0 == strftime(buf, p->rmargin, "%B %e, %Y", tm))
1.1 kristaps 425: err(1, "strftime");
426:
427: (void)strlcpy(os, meta->os, p->rmargin);
428:
429: term_vspace(p);
430:
1.9 kristaps 431: p->offset = 0;
432: p->rmargin = (p->maxrmargin - strlen(buf) + 1) / 2;
1.1 kristaps 433: p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
434:
435: term_word(p, os);
436: term_flushln(p);
437:
1.9 kristaps 438: p->offset = p->rmargin;
439: p->rmargin = p->maxrmargin - strlen(os);
1.1 kristaps 440: p->flags |= TERMP_NOLPAD | TERMP_NOSPACE;
1.9 kristaps 441:
442: term_word(p, buf);
443: term_flushln(p);
444:
1.1 kristaps 445: p->offset = p->rmargin;
446: p->rmargin = p->maxrmargin;
447: p->flags &= ~TERMP_NOBREAK;
1.9 kristaps 448: p->flags |= TERMP_NOLPAD | TERMP_NOSPACE;
1.1 kristaps 449:
1.9 kristaps 450: term_word(p, os);
1.1 kristaps 451: term_flushln(p);
452:
1.9 kristaps 453: p->offset = 0;
454: p->rmargin = p->maxrmargin;
455: p->flags = 0;
456:
1.1 kristaps 457: free(buf);
458: free(os);
459: }
460:
461:
1.3 kristaps 462: static void
1.1 kristaps 463: print_head(struct termp *p, const struct mdoc_meta *meta)
464: {
465: char *buf, *title;
466:
467: p->rmargin = p->maxrmargin;
468: p->offset = 0;
469:
470: if (NULL == (buf = malloc(p->rmargin)))
471: err(1, "malloc");
472: if (NULL == (title = malloc(p->rmargin)))
473: err(1, "malloc");
474:
475: /*
476: * The header is strange. It has three components, which are
477: * really two with the first duplicated. It goes like this:
478: *
479: * IDENTIFIER TITLE IDENTIFIER
480: *
481: * The IDENTIFIER is NAME(SECTION), which is the command-name
482: * (if given, or "unknown" if not) followed by the manual page
483: * section. These are given in `Dt'. The TITLE is a free-form
484: * string depending on the manual volume. If not specified, it
485: * switches on the manual section.
486: */
487:
488: assert(meta->vol);
489: (void)strlcpy(buf, meta->vol, p->rmargin);
490:
491: if (meta->arch) {
492: (void)strlcat(buf, " (", p->rmargin);
493: (void)strlcat(buf, meta->arch, p->rmargin);
494: (void)strlcat(buf, ")", p->rmargin);
495: }
496:
497: (void)snprintf(title, p->rmargin, "%s(%d)",
498: meta->title, meta->msec);
499:
500: p->offset = 0;
1.8 kristaps 501: p->rmargin = (p->maxrmargin - strlen(buf) + 1) / 2;
1.1 kristaps 502: p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;
503:
504: term_word(p, title);
505: term_flushln(p);
506:
507: p->offset = p->rmargin;
508: p->rmargin = p->maxrmargin - strlen(title);
1.9 kristaps 509: p->flags |= TERMP_NOLPAD | TERMP_NOSPACE;
1.1 kristaps 510:
511: term_word(p, buf);
512: term_flushln(p);
513:
514: p->offset = p->rmargin;
515: p->rmargin = p->maxrmargin;
516: p->flags &= ~TERMP_NOBREAK;
517: p->flags |= TERMP_NOLPAD | TERMP_NOSPACE;
518:
519: term_word(p, title);
520: term_flushln(p);
521:
1.9 kristaps 522: p->offset = 0;
1.1 kristaps 523: p->rmargin = p->maxrmargin;
524: p->flags &= ~TERMP_NOSPACE;
525:
526: free(title);
527: free(buf);
528: }
529:
530:
531: static size_t
532: arg_width(const struct mdoc_argv *arg, int pos)
533: {
534: int i, len;
1.40 kristaps 535: const char *p;
1.1 kristaps 536:
537: assert(pos < (int)arg->sz && pos >= 0);
538: assert(arg->value[pos]);
539:
1.40 kristaps 540: p = arg->value[pos];
541:
542: if (0 == (len = (int)strlen(p)))
1.1 kristaps 543: return(0);
544:
545: for (i = 0; i < len - 1; i++)
1.40 kristaps 546: if ( ! isdigit((u_char)p[i]))
1.1 kristaps 547: break;
548:
1.40 kristaps 549: if (i == len - 1)
550: if ('n' == p[len - 1] || 'm' == p[len - 1])
551: return((size_t)atoi(p) + 2);
1.1 kristaps 552:
1.40 kristaps 553: return((size_t)len + 2);
1.1 kristaps 554: }
555:
556:
557: static int
558: arg_listtype(const struct mdoc_node *n)
559: {
560: int i, len;
561:
562: assert(MDOC_BLOCK == n->type);
563:
564: len = (int)(n->args ? n->args->argc : 0);
565:
566: for (i = 0; i < len; i++)
567: switch (n->args->argv[i].arg) {
568: case (MDOC_Bullet):
569: /* FALLTHROUGH */
570: case (MDOC_Dash):
571: /* FALLTHROUGH */
572: case (MDOC_Enum):
573: /* FALLTHROUGH */
574: case (MDOC_Hyphen):
575: /* FALLTHROUGH */
576: case (MDOC_Tag):
577: /* FALLTHROUGH */
578: case (MDOC_Inset):
579: /* FALLTHROUGH */
580: case (MDOC_Diag):
581: /* FALLTHROUGH */
582: case (MDOC_Item):
583: /* FALLTHROUGH */
584: case (MDOC_Column):
585: /* FALLTHROUGH */
1.38 kristaps 586: case (MDOC_Hang):
587: /* FALLTHROUGH */
1.1 kristaps 588: case (MDOC_Ohang):
589: return(n->args->argv[i].arg);
590: default:
591: break;
592: }
593:
1.38 kristaps 594: return(-1);
1.1 kristaps 595: }
596:
597:
598: static size_t
599: arg_offset(const struct mdoc_argv *arg)
600: {
1.40 kristaps 601: int len, i;
602: const char *p;
1.1 kristaps 603:
604: assert(*arg->value);
1.40 kristaps 605: p = *arg->value;
606:
607: if (0 == strcmp(p, "left"))
1.19 kristaps 608: return(0);
1.40 kristaps 609: if (0 == strcmp(p, "indent"))
1.16 kristaps 610: return(INDENT + 1);
1.40 kristaps 611: if (0 == strcmp(p, "indent-two"))
1.20 kristaps 612: return((INDENT + 1) * 2);
1.10 kristaps 613:
1.40 kristaps 614: if (0 == (len = (int)strlen(p)))
615: return(0);
616:
617: for (i = 0; i < len - 1; i++)
618: if ( ! isdigit((u_char)p[i]))
619: break;
620:
621: if (i == len - 1)
622: if ('n' == p[len - 1] || 'm' == p[len - 1])
623: return((size_t)atoi(p));
1.11 kristaps 624:
1.40 kristaps 625: return((size_t)len);
1.1 kristaps 626: }
627:
628:
629: static int
630: arg_hasattr(int arg, const struct mdoc_node *n)
631: {
632:
633: return(-1 != arg_getattr(arg, n));
634: }
635:
636:
637: static int
638: arg_getattr(int v, const struct mdoc_node *n)
639: {
640: int val;
641:
642: return(arg_getattrs(&v, &val, 1, n) ? val : -1);
643: }
644:
645:
646: static int
647: arg_getattrs(const int *keys, int *vals,
648: size_t sz, const struct mdoc_node *n)
649: {
650: int i, j, k;
651:
652: if (NULL == n->args)
653: return(0);
654:
655: for (k = i = 0; i < (int)n->args->argc; i++)
656: for (j = 0; j < (int)sz; j++)
657: if (n->args->argv[i].arg == keys[j]) {
658: vals[j] = i;
659: k++;
660: }
661: return(k);
662: }
663:
664:
665: /* ARGSUSED */
1.54 kristaps 666: static void
1.1 kristaps 667: fmt_block_vspace(struct termp *p,
668: const struct mdoc_node *bl,
669: const struct mdoc_node *node)
670: {
671: const struct mdoc_node *n;
672:
673: term_newln(p);
674:
1.59 kristaps 675: if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Compact, bl))
1.54 kristaps 676: return;
677:
678: /*
679: * Search through our prior nodes. If we follow a `Ss' or `Sh',
680: * then don't vspace.
681: */
1.1 kristaps 682:
683: for (n = node; n; n = n->parent) {
684: if (MDOC_BLOCK != n->type)
685: continue;
686: if (MDOC_Ss == n->tok)
1.54 kristaps 687: return;
1.1 kristaps 688: if (MDOC_Sh == n->tok)
1.54 kristaps 689: return;
1.1 kristaps 690: if (NULL == n->prev)
691: continue;
692: break;
693: }
694:
1.54 kristaps 695: /*
1.55 kristaps 696: * XXX - not documented: a `-column' does not ever assert vspace
697: * within the list.
1.54 kristaps 698: */
699:
1.59 kristaps 700: if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Column, bl))
1.54 kristaps 701: if (node->prev && MDOC_It == node->prev->tok)
702: return;
703:
1.55 kristaps 704: /*
705: * XXX - not documented: a `-diag' without a body does not
706: * assert a vspace prior to the next element.
707: */
1.59 kristaps 708: if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Diag, bl))
1.55 kristaps 709: if (node->prev && MDOC_It == node->prev->tok) {
710: assert(node->prev->body);
711: if (NULL == node->prev->body->child)
712: return;
713: }
714:
1.54 kristaps 715: term_vspace(p);
1.1 kristaps 716: }
717:
718:
719: /* ARGSUSED */
720: static int
721: termp_dq_pre(DECL_ARGS)
722: {
723:
724: if (MDOC_BODY != node->type)
725: return(1);
726:
727: term_word(p, "\\(lq");
728: p->flags |= TERMP_NOSPACE;
729: return(1);
730: }
731:
732:
733: /* ARGSUSED */
734: static void
735: termp_dq_post(DECL_ARGS)
736: {
737:
738: if (MDOC_BODY != node->type)
739: return;
740:
741: p->flags |= TERMP_NOSPACE;
742: term_word(p, "\\(rq");
743: }
744:
745:
746: /* ARGSUSED */
747: static int
748: termp_it_pre(DECL_ARGS)
749: {
750: const struct mdoc_node *bl, *n;
751: char buf[7];
1.39 kristaps 752: int i, type, keys[3], vals[3];
1.1 kristaps 753: size_t width, offset;
754:
1.54 kristaps 755: if (MDOC_BLOCK == node->type) {
756: fmt_block_vspace(p, node->parent->parent, node);
757: return(1);
758: }
1.1 kristaps 759:
760: bl = node->parent->parent->parent;
761:
762: /* Save parent attributes. */
763:
764: pair->flag = p->flags;
765:
766: /* Get list width and offset. */
767:
768: keys[0] = MDOC_Width;
769: keys[1] = MDOC_Offset;
770: keys[2] = MDOC_Column;
771:
772: vals[0] = vals[1] = vals[2] = -1;
773:
774: width = offset = 0;
775:
776: (void)arg_getattrs(keys, vals, 3, bl);
777:
778: type = arg_listtype(bl);
1.38 kristaps 779: assert(-1 != type);
1.1 kristaps 780:
781: /* Calculate real width and offset. */
782:
783: switch (type) {
784: case (MDOC_Column):
785: if (MDOC_BODY == node->type)
786: break;
1.58 kristaps 787: /*
788: * Work around groff's column handling. The offset is
789: * equal to the sum of all widths leading to the current
790: * column (plus the -offset value). If this column
791: * exceeds the stated number of columns, the width is
792: * set as 0, else it's the stated column width (later
793: * the 0 will be adjusted to default 10 or, if in the
794: * last column case, set to stretch to the margin).
795: */
796: for (i = 0, n = node->prev; n && n &&
797: i < (int)bl->args[vals[2]].argv->sz;
798: n = n->prev, i++)
1.1 kristaps 799: offset += arg_width
800: (&bl->args->argv[vals[2]], i);
1.58 kristaps 801:
802: /* Whether exceeds maximum column. */
803: if (i < (int)bl->args[vals[2]].argv->sz)
804: width = arg_width(&bl->args->argv[vals[2]], i);
805: else
806: width = 0;
807:
1.1 kristaps 808: if (vals[1] >= 0)
809: offset += arg_offset(&bl->args->argv[vals[1]]);
810: break;
811: default:
812: if (vals[0] >= 0)
813: width = arg_width(&bl->args->argv[vals[0]], 0);
814: if (vals[1] >= 0)
1.19 kristaps 815: offset += arg_offset(&bl->args->argv[vals[1]]);
1.1 kristaps 816: break;
817: }
818:
819: /*
820: * List-type can override the width in the case of fixed-head
821: * values (bullet, dash/hyphen, enum). Tags need a non-zero
1.38 kristaps 822: * offset. FIXME: double-check that correct.
1.1 kristaps 823: */
824:
825: switch (type) {
826: case (MDOC_Bullet):
827: /* FALLTHROUGH */
828: case (MDOC_Dash):
829: /* FALLTHROUGH */
830: case (MDOC_Hyphen):
831: if (width < 4)
832: width = 4;
833: break;
1.17 kristaps 834: case (MDOC_Enum):
835: if (width < 5)
836: width = 5;
837: break;
1.38 kristaps 838: case (MDOC_Hang):
1.39 kristaps 839: if (0 == width)
840: width = 8;
841: break;
1.49 kristaps 842: case (MDOC_Column):
843: /* FALLTHROUGH */
1.1 kristaps 844: case (MDOC_Tag):
845: if (0 == width)
846: width = 10;
847: break;
848: default:
849: break;
850: }
851:
852: /*
1.17 kristaps 853: * Whitespace control. Inset bodies need an initial space,
854: * while diagonal bodies need two.
1.1 kristaps 855: */
856:
1.51 kristaps 857: p->flags |= TERMP_NOSPACE;
858:
1.1 kristaps 859: switch (type) {
1.51 kristaps 860: case (MDOC_Diag):
1.62 ! kristaps 861: if (MDOC_BODY == node->type)
! 862: term_word(p, "\\ \\ ");
1.51 kristaps 863: break;
1.1 kristaps 864: case (MDOC_Inset):
865: if (MDOC_BODY == node->type)
1.51 kristaps 866: term_word(p, "\\ ");
1.1 kristaps 867: break;
868: default:
869: break;
870: }
871:
1.51 kristaps 872: p->flags |= TERMP_NOSPACE;
873:
1.1 kristaps 874: /*
875: * Style flags. Diagnostic heads need TTYPE_DIAG.
876: */
877:
878: switch (type) {
879: case (MDOC_Diag):
880: if (MDOC_HEAD == node->type)
881: p->flags |= ttypes[TTYPE_DIAG];
882: break;
883: default:
884: break;
885: }
886:
887: /*
888: * Pad and break control. This is the tricker part. Lists with
889: * set right-margins for the head get TERMP_NOBREAK because, if
890: * they overrun the margin, they wrap to the new margin.
891: * Correspondingly, the body for these types don't left-pad, as
892: * the head will pad out to to the right.
893: */
894:
895: switch (type) {
896: case (MDOC_Bullet):
897: /* FALLTHROUGH */
898: case (MDOC_Dash):
899: /* FALLTHROUGH */
900: case (MDOC_Enum):
901: /* FALLTHROUGH */
902: case (MDOC_Hyphen):
1.39 kristaps 903: if (MDOC_HEAD == node->type)
904: p->flags |= TERMP_NOBREAK;
905: else
906: p->flags |= TERMP_NOLPAD;
907: break;
1.38 kristaps 908: case (MDOC_Hang):
1.39 kristaps 909: if (MDOC_HEAD == node->type)
910: p->flags |= TERMP_NOBREAK;
911: else
912: p->flags |= TERMP_NOLPAD;
913:
1.59 kristaps 914: if (MDOC_HEAD != node->type)
915: break;
916:
917: /*
918: * This is ugly. If `-hang' is specified and the body
919: * is a `Bl' or `Bd', then we want basically to nullify
920: * the "overstep" effect in term_flushln() and treat
921: * this as a `-ohang' list instead.
922: */
923: if (node->next->child &&
924: (MDOC_Bl == node->next->child->tok ||
925: MDOC_Bd == node->next->child->tok)) {
926: p->flags &= ~TERMP_NOBREAK;
927: p->flags &= ~TERMP_NOLPAD;
928: } else
1.39 kristaps 929: p->flags |= TERMP_HANG;
930: break;
1.1 kristaps 931: case (MDOC_Tag):
932: if (MDOC_HEAD == node->type)
1.51 kristaps 933: p->flags |= TERMP_NOBREAK | TERMP_TWOSPACE;
1.1 kristaps 934: else
935: p->flags |= TERMP_NOLPAD;
1.38 kristaps 936:
1.39 kristaps 937: if (MDOC_HEAD != node->type)
938: break;
939: if (NULL == node->next || NULL == node->next->child)
940: p->flags |= TERMP_DANGLE;
1.1 kristaps 941: break;
942: case (MDOC_Column):
943: if (MDOC_HEAD == node->type) {
944: assert(node->next);
945: if (MDOC_BODY == node->next->type)
946: p->flags &= ~TERMP_NOBREAK;
947: else
948: p->flags |= TERMP_NOBREAK;
949: if (node->prev)
950: p->flags |= TERMP_NOLPAD;
951: }
952: break;
953: case (MDOC_Diag):
954: if (MDOC_HEAD == node->type)
955: p->flags |= TERMP_NOBREAK;
956: break;
957: default:
958: break;
959: }
960:
961: /*
962: * Margin control. Set-head-width lists have their right
963: * margins shortened. The body for these lists has the offset
964: * necessarily lengthened. Everybody gets the offset.
965: */
966:
967: p->offset += offset;
968:
969: switch (type) {
1.59 kristaps 970: case (MDOC_Hang):
971: /*
972: * Same stipulation as above, regarding `-hang'. We
973: * don't want to recalculate rmargin and offsets when
974: * using `Bd' or `Bl' within `-hang' overstep lists.
975: */
976: if (MDOC_HEAD == node->type && node->next->child &&
977: (MDOC_Bl == node->next->child->tok ||
978: MDOC_Bd == node->next->child->tok))
979: break;
980: /* FALLTHROUGH */
1.1 kristaps 981: case (MDOC_Bullet):
982: /* FALLTHROUGH */
983: case (MDOC_Dash):
984: /* FALLTHROUGH */
985: case (MDOC_Enum):
986: /* FALLTHROUGH */
987: case (MDOC_Hyphen):
988: /* FALLTHROUGH */
989: case (MDOC_Tag):
1.49 kristaps 990: assert(width);
1.1 kristaps 991: if (MDOC_HEAD == node->type)
992: p->rmargin = p->offset + width;
993: else
994: p->offset += width;
995: break;
996: case (MDOC_Column):
1.49 kristaps 997: assert(width);
1.1 kristaps 998: p->rmargin = p->offset + width;
1.50 kristaps 999: /*
1000: * XXX - this behaviour is not documented: the
1001: * right-most column is filled to the right margin.
1002: */
1003: if (MDOC_HEAD == node->type &&
1004: MDOC_BODY == node->next->type)
1005: p->rmargin = p->maxrmargin;
1.1 kristaps 1006: break;
1007: default:
1008: break;
1009: }
1010:
1011: /*
1012: * The dash, hyphen, bullet and enum lists all have a special
1.15 kristaps 1013: * HEAD character (temporarily bold, in some cases).
1.1 kristaps 1014: */
1015:
1016: if (MDOC_HEAD == node->type)
1017: switch (type) {
1018: case (MDOC_Bullet):
1.15 kristaps 1019: p->flags |= TERMP_BOLD;
1.1 kristaps 1020: term_word(p, "\\[bu]");
1.39 kristaps 1021: p->flags &= ~TERMP_BOLD;
1.1 kristaps 1022: break;
1023: case (MDOC_Dash):
1024: /* FALLTHROUGH */
1025: case (MDOC_Hyphen):
1.15 kristaps 1026: p->flags |= TERMP_BOLD;
1.27 kristaps 1027: term_word(p, "\\(hy");
1.39 kristaps 1028: p->flags &= ~TERMP_BOLD;
1.1 kristaps 1029: break;
1030: case (MDOC_Enum):
1031: (pair->ppair->ppair->count)++;
1032: (void)snprintf(buf, sizeof(buf), "%d.",
1033: pair->ppair->ppair->count);
1034: term_word(p, buf);
1035: break;
1036: default:
1037: break;
1038: }
1039:
1040: /*
1041: * If we're not going to process our children, indicate so here.
1042: */
1043:
1044: switch (type) {
1045: case (MDOC_Bullet):
1046: /* FALLTHROUGH */
1047: case (MDOC_Item):
1048: /* FALLTHROUGH */
1049: case (MDOC_Dash):
1050: /* FALLTHROUGH */
1051: case (MDOC_Hyphen):
1052: /* FALLTHROUGH */
1053: case (MDOC_Enum):
1054: if (MDOC_HEAD == node->type)
1055: return(0);
1056: break;
1057: case (MDOC_Column):
1058: if (MDOC_BODY == node->type)
1059: return(0);
1060: break;
1061: default:
1062: break;
1063: }
1064:
1065: return(1);
1066: }
1067:
1068:
1069: /* ARGSUSED */
1070: static void
1071: termp_it_post(DECL_ARGS)
1072: {
1073: int type;
1074:
1075: if (MDOC_BODY != node->type && MDOC_HEAD != node->type)
1076: return;
1077:
1078: type = arg_listtype(node->parent->parent->parent);
1.38 kristaps 1079: assert(-1 != type);
1.1 kristaps 1080:
1081: switch (type) {
1082: case (MDOC_Item):
1083: /* FALLTHROUGH */
1.53 kristaps 1084: case (MDOC_Diag):
1085: /* FALLTHROUGH */
1.1 kristaps 1086: case (MDOC_Inset):
1087: if (MDOC_BODY == node->type)
1088: term_flushln(p);
1089: break;
1090: case (MDOC_Column):
1091: if (MDOC_HEAD == node->type)
1092: term_flushln(p);
1093: break;
1094: default:
1095: term_flushln(p);
1096: break;
1097: }
1098:
1099: p->flags = pair->flag;
1100: }
1101:
1102:
1103: /* ARGSUSED */
1104: static int
1105: termp_nm_pre(DECL_ARGS)
1106: {
1107:
1108: if (SEC_SYNOPSIS == node->sec)
1109: term_newln(p);
1110:
1.28 kristaps 1111: pair->flag |= ttypes[TTYPE_PROG];
1112: p->flags |= ttypes[TTYPE_PROG];
1113:
1.1 kristaps 1114: if (NULL == node->child)
1115: term_word(p, meta->name);
1116:
1117: return(1);
1118: }
1119:
1120:
1121: /* ARGSUSED */
1122: static int
1123: termp_fl_pre(DECL_ARGS)
1124: {
1125:
1.28 kristaps 1126: pair->flag |= ttypes[TTYPE_CMD_FLAG];
1127: p->flags |= ttypes[TTYPE_CMD_FLAG];
1.1 kristaps 1128: term_word(p, "\\-");
1129: p->flags |= TERMP_NOSPACE;
1130: return(1);
1131: }
1132:
1133:
1134: /* ARGSUSED */
1135: static int
1.61 kristaps 1136: termp_an_pre(DECL_ARGS)
1137: {
1138:
1139: if (NULL == node->child)
1140: return(1);
1141:
1142: /*
1143: * XXX: this is poorly documented. If not in the AUTHORS
1144: * section, `An -split' will cause newlines to occur before the
1145: * author name. If in the AUTHORS section, by default, the
1146: * first `An' invocation is nosplit, then all subsequent ones,
1147: * regardless of whether interspersed with other macros/text,
1148: * are split. -split, in this case, will override the condition
1149: * of the implied first -nosplit.
1150: */
1151:
1152: if (node->sec == SEC_AUTHORS) {
1153: if ( ! (TERMP_ANPREC & p->flags)) {
1154: if (TERMP_SPLIT & p->flags)
1155: term_newln(p);
1156: return(1);
1157: }
1158: if (TERMP_NOSPLIT & p->flags)
1159: return(1);
1160: term_newln(p);
1161: return(1);
1162: }
1163:
1164: if (TERMP_SPLIT & p->flags)
1165: term_newln(p);
1166:
1167: return(1);
1168: }
1169:
1170:
1171: /* ARGSUSED */
1172: static void
1173: termp_an_post(DECL_ARGS)
1174: {
1175:
1176: if (node->child) {
1177: if (SEC_AUTHORS == node->sec)
1178: p->flags |= TERMP_ANPREC;
1179: return;
1180: }
1181:
1182: if (arg_getattr(MDOC_Split, node) > -1) {
1183: p->flags &= ~TERMP_NOSPLIT;
1184: p->flags |= TERMP_SPLIT;
1185: } else {
1186: p->flags &= ~TERMP_SPLIT;
1187: p->flags |= TERMP_NOSPLIT;
1188: }
1189:
1190: }
1191:
1192:
1193: /* ARGSUSED */
1194: static int
1.1 kristaps 1195: termp_ar_pre(DECL_ARGS)
1196: {
1197:
1.28 kristaps 1198: pair->flag |= ttypes[TTYPE_CMD_ARG];
1.1 kristaps 1199: return(1);
1200: }
1201:
1202:
1203: /* ARGSUSED */
1204: static int
1205: termp_ns_pre(DECL_ARGS)
1206: {
1207:
1208: p->flags |= TERMP_NOSPACE;
1209: return(1);
1210: }
1211:
1212:
1213: /* ARGSUSED */
1214: static int
1215: termp_pp_pre(DECL_ARGS)
1216: {
1217:
1218: term_vspace(p);
1219: return(1);
1220: }
1221:
1222:
1223: /* ARGSUSED */
1224: static int
1225: termp_rs_pre(DECL_ARGS)
1226: {
1227:
1228: if (MDOC_BLOCK == node->type && node->prev)
1229: term_vspace(p);
1230: return(1);
1231: }
1232:
1233:
1234: /* ARGSUSED */
1235: static int
1236: termp_rv_pre(DECL_ARGS)
1237: {
1238: int i;
1239:
1.34 kristaps 1240: i = arg_getattr(MDOC_Std, node);
1241: assert(-1 != i);
1242: assert(node->args->argv[i].sz);
1.1 kristaps 1243:
1244: term_newln(p);
1245: term_word(p, "The");
1246:
1247: p->flags |= ttypes[TTYPE_FUNC_NAME];
1248: term_word(p, *node->args->argv[i].value);
1249: p->flags &= ~ttypes[TTYPE_FUNC_NAME];
1250: p->flags |= TERMP_NOSPACE;
1251:
1252: term_word(p, "() function returns the value 0 if successful;");
1253: term_word(p, "otherwise the value -1 is returned and the");
1254: term_word(p, "global variable");
1255:
1256: p->flags |= ttypes[TTYPE_VAR_DECL];
1257: term_word(p, "errno");
1258: p->flags &= ~ttypes[TTYPE_VAR_DECL];
1259:
1260: term_word(p, "is set to indicate the error.");
1261:
1262: return(1);
1263: }
1264:
1265:
1266: /* ARGSUSED */
1267: static int
1268: termp_ex_pre(DECL_ARGS)
1269: {
1270: int i;
1271:
1.34 kristaps 1272: i = arg_getattr(MDOC_Std, node);
1273: assert(-1 != i);
1274: assert(node->args->argv[i].sz);
1.1 kristaps 1275:
1276: term_word(p, "The");
1277: p->flags |= ttypes[TTYPE_PROG];
1278: term_word(p, *node->args->argv[i].value);
1279: p->flags &= ~ttypes[TTYPE_PROG];
1280: term_word(p, "utility exits 0 on success, and >0 if an error occurs.");
1281:
1282: return(1);
1283: }
1284:
1285:
1286: /* ARGSUSED */
1287: static int
1288: termp_nd_pre(DECL_ARGS)
1289: {
1.25 kristaps 1290:
1291: if (MDOC_BODY != node->type)
1292: return(1);
1.30 kristaps 1293:
1.27 kristaps 1294: #if defined(__OpenBSD__) || defined(__linux__)
1.41 kristaps 1295: term_word(p, "\\(en");
1.23 kristaps 1296: #else
1297: term_word(p, "\\(em");
1298: #endif
1.1 kristaps 1299: return(1);
1300: }
1301:
1302:
1303: /* ARGSUSED */
1304: static void
1305: termp_bl_post(DECL_ARGS)
1306: {
1307:
1308: if (MDOC_BLOCK == node->type)
1309: term_newln(p);
1310: }
1311:
1312:
1313: /* ARGSUSED */
1314: static void
1315: termp_op_post(DECL_ARGS)
1316: {
1317:
1318: if (MDOC_BODY != node->type)
1319: return;
1320: p->flags |= TERMP_NOSPACE;
1321: term_word(p, "\\(rB");
1322: }
1323:
1324:
1325: /* ARGSUSED */
1326: static int
1327: termp_xr_pre(DECL_ARGS)
1328: {
1329: const struct mdoc_node *n;
1330:
1.11 kristaps 1331: assert(node->child && MDOC_TEXT == node->child->type);
1332: n = node->child;
1333:
1.1 kristaps 1334: term_word(p, n->string);
1335: if (NULL == (n = n->next))
1336: return(0);
1337: p->flags |= TERMP_NOSPACE;
1338: term_word(p, "(");
1339: p->flags |= TERMP_NOSPACE;
1340: term_word(p, n->string);
1341: p->flags |= TERMP_NOSPACE;
1342: term_word(p, ")");
1343: return(0);
1344: }
1345:
1346:
1347: /* ARGSUSED */
1348: static int
1349: termp_vt_pre(DECL_ARGS)
1350: {
1351:
1352: /* FIXME: this can be "type name". */
1.29 kristaps 1353: pair->flag |= ttypes[TTYPE_VAR_DECL];
1.1 kristaps 1354: return(1);
1355: }
1356:
1357:
1358: /* ARGSUSED */
1359: static void
1360: termp_vt_post(DECL_ARGS)
1361: {
1362:
1.32 kristaps 1363: if (node->sec != SEC_SYNOPSIS)
1364: return;
1365: if (node->next && MDOC_Vt == node->next->tok)
1366: term_newln(p);
1367: else if (node->next)
1.1 kristaps 1368: term_vspace(p);
1369: }
1370:
1371:
1372: /* ARGSUSED */
1373: static int
1374: termp_fd_pre(DECL_ARGS)
1375: {
1376:
1.29 kristaps 1377: pair->flag |= ttypes[TTYPE_FUNC_DECL];
1.1 kristaps 1378: return(1);
1379: }
1380:
1381:
1382: /* ARGSUSED */
1383: static void
1384: termp_fd_post(DECL_ARGS)
1385: {
1386:
1387: if (node->sec != SEC_SYNOPSIS)
1388: return;
1.29 kristaps 1389:
1.1 kristaps 1390: term_newln(p);
1391: if (node->next && MDOC_Fd != node->next->tok)
1392: term_vspace(p);
1393: }
1394:
1395:
1396: /* ARGSUSED */
1397: static int
1398: termp_sh_pre(DECL_ARGS)
1399: {
1400:
1401: switch (node->type) {
1402: case (MDOC_HEAD):
1403: term_vspace(p);
1.28 kristaps 1404: pair->flag |= ttypes[TTYPE_SECTION];
1.1 kristaps 1405: break;
1406: case (MDOC_BODY):
1407: p->offset = INDENT;
1408: break;
1409: default:
1410: break;
1411: }
1412: return(1);
1413: }
1414:
1415:
1416: /* ARGSUSED */
1417: static void
1418: termp_sh_post(DECL_ARGS)
1419: {
1420:
1421: switch (node->type) {
1422: case (MDOC_HEAD):
1423: term_newln(p);
1424: break;
1425: case (MDOC_BODY):
1426: term_newln(p);
1427: p->offset = 0;
1428: break;
1429: default:
1430: break;
1431: }
1432: }
1433:
1434:
1435: /* ARGSUSED */
1436: static int
1437: termp_op_pre(DECL_ARGS)
1438: {
1439:
1440: switch (node->type) {
1441: case (MDOC_BODY):
1442: term_word(p, "\\(lB");
1443: p->flags |= TERMP_NOSPACE;
1444: break;
1445: default:
1446: break;
1447: }
1448: return(1);
1449: }
1450:
1451:
1452: /* ARGSUSED */
1453: static int
1454: termp_bt_pre(DECL_ARGS)
1455: {
1456:
1457: term_word(p, "is currently in beta test.");
1458: return(1);
1459: }
1460:
1461:
1462: /* ARGSUSED */
1463: static void
1464: termp_lb_post(DECL_ARGS)
1465: {
1466:
1467: term_newln(p);
1468: }
1469:
1470:
1471: /* ARGSUSED */
1472: static int
1473: termp_ud_pre(DECL_ARGS)
1474: {
1475:
1476: term_word(p, "currently under development.");
1477: return(1);
1478: }
1479:
1480:
1481: /* ARGSUSED */
1482: static int
1483: termp_d1_pre(DECL_ARGS)
1484: {
1485:
1.4 kristaps 1486: if (MDOC_BLOCK != node->type)
1.1 kristaps 1487: return(1);
1488: term_newln(p);
1.29 kristaps 1489: p->offset += (INDENT + 1);
1.1 kristaps 1490: return(1);
1491: }
1492:
1493:
1494: /* ARGSUSED */
1495: static void
1496: termp_d1_post(DECL_ARGS)
1497: {
1498:
1.4 kristaps 1499: if (MDOC_BLOCK != node->type)
1.1 kristaps 1500: return;
1501: term_newln(p);
1502: }
1503:
1504:
1505: /* ARGSUSED */
1506: static int
1507: termp_aq_pre(DECL_ARGS)
1508: {
1509:
1510: if (MDOC_BODY != node->type)
1511: return(1);
1512: term_word(p, "\\(la");
1513: p->flags |= TERMP_NOSPACE;
1514: return(1);
1515: }
1516:
1517:
1518: /* ARGSUSED */
1519: static void
1520: termp_aq_post(DECL_ARGS)
1521: {
1522:
1523: if (MDOC_BODY != node->type)
1524: return;
1525: p->flags |= TERMP_NOSPACE;
1526: term_word(p, "\\(ra");
1527: }
1528:
1529:
1530: /* ARGSUSED */
1531: static int
1532: termp_ft_pre(DECL_ARGS)
1533: {
1534:
1535: if (SEC_SYNOPSIS == node->sec)
1536: if (node->prev && MDOC_Fo == node->prev->tok)
1537: term_vspace(p);
1.28 kristaps 1538: pair->flag |= ttypes[TTYPE_FUNC_TYPE];
1.1 kristaps 1539: return(1);
1540: }
1541:
1542:
1543: /* ARGSUSED */
1544: static void
1545: termp_ft_post(DECL_ARGS)
1546: {
1547:
1548: if (SEC_SYNOPSIS == node->sec)
1549: term_newln(p);
1550: }
1551:
1552:
1553: /* ARGSUSED */
1554: static int
1555: termp_fn_pre(DECL_ARGS)
1556: {
1557: const struct mdoc_node *n;
1558:
1.11 kristaps 1559: assert(node->child && MDOC_TEXT == node->child->type);
1.1 kristaps 1560:
1561: /* FIXME: can be "type funcname" "type varname"... */
1562:
1563: p->flags |= ttypes[TTYPE_FUNC_NAME];
1564: term_word(p, node->child->string);
1565: p->flags &= ~ttypes[TTYPE_FUNC_NAME];
1566:
1567: p->flags |= TERMP_NOSPACE;
1568: term_word(p, "(");
1569:
1570: for (n = node->child->next; n; n = n->next) {
1571: p->flags |= ttypes[TTYPE_FUNC_ARG];
1572: term_word(p, n->string);
1573: p->flags &= ~ttypes[TTYPE_FUNC_ARG];
1574: if (n->next)
1575: term_word(p, ",");
1576: }
1577:
1578: term_word(p, ")");
1579:
1580: if (SEC_SYNOPSIS == node->sec)
1581: term_word(p, ";");
1582:
1583: return(0);
1584: }
1585:
1586:
1587: /* ARGSUSED */
1588: static void
1589: termp_fn_post(DECL_ARGS)
1590: {
1591:
1592: if (node->sec == SEC_SYNOPSIS && node->next)
1593: term_vspace(p);
1594: }
1595:
1596:
1597: /* ARGSUSED */
1598: static int
1599: termp_sx_pre(DECL_ARGS)
1600: {
1601:
1.28 kristaps 1602: pair->flag |= ttypes[TTYPE_LINK];
1.1 kristaps 1603: return(1);
1604: }
1605:
1606:
1607: /* ARGSUSED */
1608: static int
1609: termp_fa_pre(DECL_ARGS)
1610: {
1611: struct mdoc_node *n;
1612:
1613: if (node->parent->tok != MDOC_Fo) {
1.28 kristaps 1614: pair->flag |= ttypes[TTYPE_FUNC_ARG];
1.1 kristaps 1615: return(1);
1616: }
1617:
1618: for (n = node->child; n; n = n->next) {
1619: p->flags |= ttypes[TTYPE_FUNC_ARG];
1620: term_word(p, n->string);
1621: p->flags &= ~ttypes[TTYPE_FUNC_ARG];
1622: if (n->next)
1623: term_word(p, ",");
1624: }
1625:
1626: if (node->child && node->next && node->next->tok == MDOC_Fa)
1627: term_word(p, ",");
1628:
1629: return(0);
1630: }
1631:
1632:
1633: /* ARGSUSED */
1634: static int
1635: termp_va_pre(DECL_ARGS)
1636: {
1637:
1.28 kristaps 1638: pair->flag |= ttypes[TTYPE_VAR_DECL];
1.1 kristaps 1639: return(1);
1640: }
1641:
1642:
1643: /* ARGSUSED */
1644: static int
1645: termp_bd_pre(DECL_ARGS)
1646: {
1.60 kristaps 1647: int i, type;
1.1 kristaps 1648:
1649: /*
1650: * This is fairly tricky due primarily to crappy documentation.
1651: * If -ragged or -filled are specified, the block does nothing
1652: * but change the indentation.
1653: *
1654: * If, on the other hand, -unfilled or -literal are specified,
1655: * then the game changes. Text is printed exactly as entered in
1656: * the display: if a macro line, a newline is appended to the
1657: * line. Blank lines are allowed.
1658: */
1659:
1.54 kristaps 1660: if (MDOC_BLOCK == node->type) {
1661: fmt_block_vspace(p, node, node);
1662: return(1);
1663: } else if (MDOC_BODY != node->type)
1.1 kristaps 1664: return(1);
1665:
1.60 kristaps 1666: assert(node->parent->args);
1.11 kristaps 1667:
1.60 kristaps 1668: for (type = -1, i = 0; -1 == type &&
1.1 kristaps 1669: i < (int)node->parent->args->argc; i++) {
1670: switch (node->parent->args->argv[i].arg) {
1671: case (MDOC_Ragged):
1672: /* FALLTHROUGH */
1673: case (MDOC_Filled):
1674: /* FALLTHROUGH */
1675: case (MDOC_Unfilled):
1676: /* FALLTHROUGH */
1677: case (MDOC_Literal):
1678: type = node->parent->args->argv[i].arg;
1679: break;
1680: default:
1681: break;
1682: }
1683: }
1.60 kristaps 1684:
1685: assert(type > -1);
1.1 kristaps 1686:
1687: i = arg_getattr(MDOC_Offset, node->parent);
1.60 kristaps 1688: if (-1 != i)
1.1 kristaps 1689: p->offset += arg_offset(&node->parent->args->argv[i]);
1690:
1691: switch (type) {
1692: case (MDOC_Literal):
1693: /* FALLTHROUGH */
1694: case (MDOC_Unfilled):
1695: break;
1696: default:
1697: return(1);
1698: }
1699:
1700: for (node = node->child; node; node = node->next) {
1.60 kristaps 1701: p->flags |= TERMP_NOSPACE;
1702: print_node(p, pair, meta, node);
1703: if (node->next)
1.1 kristaps 1704: term_flushln(p);
1705: }
1706:
1707: return(0);
1708: }
1709:
1710:
1711: /* ARGSUSED */
1712: static void
1713: termp_bd_post(DECL_ARGS)
1714: {
1715:
1716: if (MDOC_BODY != node->type)
1717: return;
1.60 kristaps 1718: p->flags |= TERMP_NOSPACE;
1.1 kristaps 1719: term_flushln(p);
1720: }
1721:
1722:
1723: /* ARGSUSED */
1724: static int
1725: termp_qq_pre(DECL_ARGS)
1726: {
1727:
1728: if (MDOC_BODY != node->type)
1729: return(1);
1730: term_word(p, "\"");
1731: p->flags |= TERMP_NOSPACE;
1732: return(1);
1733: }
1734:
1735:
1736: /* ARGSUSED */
1737: static void
1738: termp_qq_post(DECL_ARGS)
1739: {
1740:
1741: if (MDOC_BODY != node->type)
1742: return;
1743: p->flags |= TERMP_NOSPACE;
1744: term_word(p, "\"");
1745: }
1746:
1747:
1748: /* ARGSUSED */
1749: static void
1750: termp_bx_post(DECL_ARGS)
1751: {
1752:
1753: if (node->child)
1754: p->flags |= TERMP_NOSPACE;
1755: term_word(p, "BSD");
1756: }
1757:
1758:
1759: /* ARGSUSED */
1760: static int
1.26 kristaps 1761: termp_xx_pre(DECL_ARGS)
1.1 kristaps 1762: {
1.26 kristaps 1763: const char *pp;
1.1 kristaps 1764:
1.26 kristaps 1765: pp = NULL;
1766: switch (node->tok) {
1767: case (MDOC_Bsx):
1768: pp = "BSDI BSD/OS";
1769: break;
1770: case (MDOC_Dx):
1771: pp = "DragonFlyBSD";
1772: break;
1773: case (MDOC_Fx):
1774: pp = "FreeBSD";
1775: break;
1776: case (MDOC_Nx):
1777: pp = "NetBSD";
1778: break;
1779: case (MDOC_Ox):
1780: pp = "OpenBSD";
1781: break;
1782: case (MDOC_Ux):
1783: pp = "UNIX";
1784: break;
1785: default:
1786: break;
1787: }
1.1 kristaps 1788:
1.26 kristaps 1789: assert(pp);
1790: term_word(p, pp);
1.1 kristaps 1791: return(1);
1792: }
1793:
1794:
1795: /* ARGSUSED */
1796: static int
1797: termp_sq_pre(DECL_ARGS)
1798: {
1799:
1800: if (MDOC_BODY != node->type)
1801: return(1);
1802: term_word(p, "\\(oq");
1803: p->flags |= TERMP_NOSPACE;
1804: return(1);
1805: }
1806:
1807:
1808: /* ARGSUSED */
1809: static void
1810: termp_sq_post(DECL_ARGS)
1811: {
1812:
1813: if (MDOC_BODY != node->type)
1814: return;
1815: p->flags |= TERMP_NOSPACE;
1816: term_word(p, "\\(aq");
1817: }
1818:
1819:
1820: /* ARGSUSED */
1821: static int
1.57 kristaps 1822: termp_pa_pre(DECL_ARGS)
1823: {
1824:
1825: pair->flag |= ttypes[TTYPE_FILE];
1826: return(1);
1827: }
1828:
1829:
1830: /* ARGSUSED */
1831: static int
1.1 kristaps 1832: termp_pf_pre(DECL_ARGS)
1833: {
1834:
1835: p->flags |= TERMP_IGNDELIM;
1836: return(1);
1837: }
1838:
1839:
1840: /* ARGSUSED */
1841: static void
1842: termp_pf_post(DECL_ARGS)
1843: {
1844:
1845: p->flags &= ~TERMP_IGNDELIM;
1846: p->flags |= TERMP_NOSPACE;
1847: }
1848:
1849:
1850: /* ARGSUSED */
1851: static int
1852: termp_ss_pre(DECL_ARGS)
1853: {
1854:
1855: switch (node->type) {
1856: case (MDOC_BLOCK):
1857: term_newln(p);
1858: if (node->prev)
1859: term_vspace(p);
1860: break;
1861: case (MDOC_HEAD):
1.28 kristaps 1862: pair->flag |= ttypes[TTYPE_SSECTION];
1.5 kristaps 1863: p->offset = HALFINDENT;
1.1 kristaps 1864: break;
1865: default:
1866: break;
1867: }
1868:
1869: return(1);
1870: }
1871:
1872:
1873: /* ARGSUSED */
1874: static void
1875: termp_ss_post(DECL_ARGS)
1876: {
1877:
1.29 kristaps 1878: if (MDOC_HEAD == node->type)
1.1 kristaps 1879: term_newln(p);
1880: }
1881:
1882:
1883: /* ARGSUSED */
1884: static int
1885: termp_em_pre(DECL_ARGS)
1886: {
1887:
1.28 kristaps 1888: pair->flag |= ttypes[TTYPE_EMPH];
1.1 kristaps 1889: return(1);
1890: }
1891:
1892:
1893: /* ARGSUSED */
1894: static int
1895: termp_cd_pre(DECL_ARGS)
1896: {
1897:
1.28 kristaps 1898: pair->flag |= ttypes[TTYPE_CONFIG];
1.1 kristaps 1899: term_newln(p);
1900: return(1);
1901: }
1902:
1903:
1904: /* ARGSUSED */
1905: static int
1906: termp_cm_pre(DECL_ARGS)
1907: {
1908:
1.28 kristaps 1909: pair->flag |= ttypes[TTYPE_CMD_FLAG];
1.1 kristaps 1910: return(1);
1911: }
1912:
1913:
1914: /* ARGSUSED */
1915: static int
1916: termp_ic_pre(DECL_ARGS)
1917: {
1918:
1.28 kristaps 1919: pair->flag |= ttypes[TTYPE_CMD];
1.1 kristaps 1920: return(1);
1921: }
1922:
1923:
1924: /* ARGSUSED */
1925: static int
1926: termp_in_pre(DECL_ARGS)
1927: {
1928:
1.28 kristaps 1929: pair->flag |= ttypes[TTYPE_INCLUDE];
1930: p->flags |= ttypes[TTYPE_INCLUDE];
1.22 kristaps 1931:
1932: if (SEC_SYNOPSIS == node->sec)
1933: term_word(p, "#include");
1934:
1.1 kristaps 1935: term_word(p, "<");
1936: p->flags |= TERMP_NOSPACE;
1937: return(1);
1938: }
1939:
1940:
1941: /* ARGSUSED */
1942: static void
1943: termp_in_post(DECL_ARGS)
1944: {
1945:
1.46 kristaps 1946: p->flags |= TERMP_NOSPACE | ttypes[TTYPE_INCLUDE];
1.1 kristaps 1947: term_word(p, ">");
1.46 kristaps 1948: p->flags &= ~ttypes[TTYPE_INCLUDE];
1.1 kristaps 1949:
1950: if (SEC_SYNOPSIS != node->sec)
1951: return;
1.22 kristaps 1952:
1953: term_newln(p);
1954: /*
1955: * XXX Not entirely correct. If `.In foo bar' is specified in
1956: * the SYNOPSIS section, then it produces a single break after
1957: * the <foo>; mandoc asserts a vertical space. Since this
1958: * construction is rarely used, I think it's fine.
1959: */
1.1 kristaps 1960: if (node->next && MDOC_In != node->next->tok)
1961: term_vspace(p);
1962: }
1963:
1964:
1965: /* ARGSUSED */
1966: static int
1.45 kristaps 1967: termp_sp_pre(DECL_ARGS)
1968: {
1969: int i, len;
1970:
1971: if (NULL == node->child) {
1972: term_vspace(p);
1973: return(0);
1974: }
1975:
1976: len = atoi(node->child->string);
1977: if (0 == len)
1978: term_newln(p);
1979: for (i = 0; i < len; i++)
1980: term_vspace(p);
1981:
1982: return(0);
1983: }
1984:
1985:
1986: /* ARGSUSED */
1987: static int
1.44 kristaps 1988: termp_br_pre(DECL_ARGS)
1989: {
1990:
1991: term_newln(p);
1992: return(1);
1993: }
1994:
1995:
1996: /* ARGSUSED */
1997: static int
1.1 kristaps 1998: termp_brq_pre(DECL_ARGS)
1999: {
2000:
2001: if (MDOC_BODY != node->type)
2002: return(1);
2003: term_word(p, "\\(lC");
2004: p->flags |= TERMP_NOSPACE;
2005: return(1);
2006: }
2007:
2008:
2009: /* ARGSUSED */
2010: static void
2011: termp_brq_post(DECL_ARGS)
2012: {
2013:
2014: if (MDOC_BODY != node->type)
2015: return;
2016: p->flags |= TERMP_NOSPACE;
2017: term_word(p, "\\(rC");
2018: }
2019:
2020:
2021: /* ARGSUSED */
2022: static int
2023: termp_bq_pre(DECL_ARGS)
2024: {
2025:
2026: if (MDOC_BODY != node->type)
2027: return(1);
2028: term_word(p, "\\(lB");
2029: p->flags |= TERMP_NOSPACE;
2030: return(1);
2031: }
2032:
2033:
2034: /* ARGSUSED */
2035: static void
2036: termp_bq_post(DECL_ARGS)
2037: {
2038:
2039: if (MDOC_BODY != node->type)
2040: return;
2041: p->flags |= TERMP_NOSPACE;
2042: term_word(p, "\\(rB");
2043: }
2044:
2045:
2046: /* ARGSUSED */
2047: static int
2048: termp_pq_pre(DECL_ARGS)
2049: {
2050:
2051: if (MDOC_BODY != node->type)
2052: return(1);
2053: term_word(p, "\\&(");
2054: p->flags |= TERMP_NOSPACE;
2055: return(1);
2056: }
2057:
2058:
2059: /* ARGSUSED */
2060: static void
2061: termp_pq_post(DECL_ARGS)
2062: {
2063:
2064: if (MDOC_BODY != node->type)
2065: return;
2066: term_word(p, ")");
2067: }
2068:
2069:
2070: /* ARGSUSED */
2071: static int
2072: termp_fo_pre(DECL_ARGS)
2073: {
2074: const struct mdoc_node *n;
2075:
2076: if (MDOC_BODY == node->type) {
1.33 kristaps 2077: p->flags |= TERMP_NOSPACE;
1.1 kristaps 2078: term_word(p, "(");
2079: p->flags |= TERMP_NOSPACE;
2080: return(1);
2081: } else if (MDOC_HEAD != node->type)
2082: return(1);
2083:
2084: p->flags |= ttypes[TTYPE_FUNC_NAME];
2085: for (n = node->child; n; n = n->next) {
1.11 kristaps 2086: assert(MDOC_TEXT == n->type);
1.1 kristaps 2087: term_word(p, n->string);
2088: }
2089: p->flags &= ~ttypes[TTYPE_FUNC_NAME];
2090:
2091: return(0);
2092: }
2093:
2094:
2095: /* ARGSUSED */
2096: static void
2097: termp_fo_post(DECL_ARGS)
2098: {
2099:
2100: if (MDOC_BODY != node->type)
2101: return;
2102: p->flags |= TERMP_NOSPACE;
2103: term_word(p, ")");
2104: p->flags |= TERMP_NOSPACE;
2105: term_word(p, ";");
2106: term_newln(p);
2107: }
2108:
2109:
2110: /* ARGSUSED */
2111: static int
2112: termp_bf_pre(DECL_ARGS)
2113: {
2114: const struct mdoc_node *n;
2115:
1.28 kristaps 2116: if (MDOC_HEAD == node->type)
1.1 kristaps 2117: return(0);
1.28 kristaps 2118: else if (MDOC_BLOCK != node->type)
1.1 kristaps 2119: return(1);
2120:
2121: if (NULL == (n = node->head->child)) {
2122: if (arg_hasattr(MDOC_Emphasis, node))
1.28 kristaps 2123: pair->flag |= ttypes[TTYPE_EMPH];
1.1 kristaps 2124: else if (arg_hasattr(MDOC_Symbolic, node))
1.28 kristaps 2125: pair->flag |= ttypes[TTYPE_SYMB];
1.1 kristaps 2126:
2127: return(1);
2128: }
2129:
1.11 kristaps 2130: assert(MDOC_TEXT == n->type);
1.1 kristaps 2131: if (0 == strcmp("Em", n->string))
1.28 kristaps 2132: pair->flag |= ttypes[TTYPE_EMPH];
1.1 kristaps 2133: else if (0 == strcmp("Sy", n->string))
1.28 kristaps 2134: pair->flag |= ttypes[TTYPE_SYMB];
1.1 kristaps 2135:
2136: return(1);
CVSweb