Print this page
9718 update mandoc to 1.14.4
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/mandoc/roff.h
+++ new/usr/src/cmd/mandoc/roff.h
1 -/* $Id: roff.h,v 1.58 2017/07/08 14:51:05 schwarze Exp $ */
1 +/* $Id: roff.h,v 1.59 2018/04/11 17:11:13 schwarze Exp $ */
2 2 /*
3 3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 4 * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
5 5 *
6 6 * Permission to use, copy, modify, and distribute this software for any
7 7 * purpose with or without fee is hereby granted, provided that the above
8 8 * copyright notice and this permission notice appear in all copies.
9 9 *
10 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
13 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 17 */
18 18
19 19 struct ohash;
20 20 struct mdoc_arg;
21 21 union mdoc_data;
22 22
23 23 enum roff_macroset {
24 24 MACROSET_NONE = 0,
25 25 MACROSET_MDOC,
26 26 MACROSET_MAN
27 27 };
28 28
29 29 enum roff_sec {
30 30 SEC_NONE = 0,
31 31 SEC_NAME,
32 32 SEC_LIBRARY,
33 33 SEC_SYNOPSIS,
34 34 SEC_DESCRIPTION,
35 35 SEC_CONTEXT,
36 36 SEC_IMPLEMENTATION, /* IMPLEMENTATION NOTES */
37 37 SEC_RETURN_VALUES,
38 38 SEC_ENVIRONMENT,
39 39 SEC_FILES,
40 40 SEC_EXIT_STATUS,
41 41 SEC_EXAMPLES,
42 42 SEC_DIAGNOSTICS,
43 43 SEC_COMPATIBILITY,
44 44 SEC_ERRORS,
45 45 SEC_SEE_ALSO,
46 46 SEC_STANDARDS,
47 47 SEC_HISTORY,
48 48 SEC_AUTHORS,
49 49 SEC_CAVEATS,
50 50 SEC_BUGS,
51 51 SEC_SECURITY,
52 52 SEC_CUSTOM,
53 53 SEC__MAX
↓ open down ↓ |
42 lines elided |
↑ open up ↑ |
54 54 };
55 55
56 56 enum roff_type {
57 57 ROFFT_ROOT,
58 58 ROFFT_BLOCK,
59 59 ROFFT_HEAD,
60 60 ROFFT_BODY,
61 61 ROFFT_TAIL,
62 62 ROFFT_ELEM,
63 63 ROFFT_TEXT,
64 + ROFFT_COMMENT,
64 65 ROFFT_TBL,
65 66 ROFFT_EQN
66 67 };
67 68
68 69 enum roff_tok {
69 70 ROFF_br = 0,
70 71 ROFF_ce,
71 72 ROFF_ft,
72 73 ROFF_ll,
73 74 ROFF_mc,
74 75 ROFF_po,
75 76 ROFF_rj,
76 77 ROFF_sp,
77 78 ROFF_ta,
78 79 ROFF_ti,
79 80 ROFF_MAX,
80 81 ROFF_ab,
81 82 ROFF_ad,
82 83 ROFF_af,
83 84 ROFF_aln,
84 85 ROFF_als,
85 86 ROFF_am,
86 87 ROFF_am1,
87 88 ROFF_ami,
88 89 ROFF_ami1,
89 90 ROFF_as,
90 91 ROFF_as1,
91 92 ROFF_asciify,
92 93 ROFF_backtrace,
93 94 ROFF_bd,
94 95 ROFF_bleedat,
95 96 ROFF_blm,
96 97 ROFF_box,
97 98 ROFF_boxa,
98 99 ROFF_bp,
99 100 ROFF_BP,
100 101 ROFF_break,
101 102 ROFF_breakchar,
102 103 ROFF_brnl,
103 104 ROFF_brp,
104 105 ROFF_brpnl,
105 106 ROFF_c2,
106 107 ROFF_cc,
107 108 ROFF_cf,
108 109 ROFF_cflags,
109 110 ROFF_ch,
110 111 ROFF_char,
111 112 ROFF_chop,
112 113 ROFF_class,
113 114 ROFF_close,
114 115 ROFF_CL,
115 116 ROFF_color,
116 117 ROFF_composite,
117 118 ROFF_continue,
118 119 ROFF_cp,
119 120 ROFF_cropat,
120 121 ROFF_cs,
121 122 ROFF_cu,
122 123 ROFF_da,
123 124 ROFF_dch,
124 125 ROFF_Dd,
125 126 ROFF_de,
126 127 ROFF_de1,
127 128 ROFF_defcolor,
128 129 ROFF_dei,
129 130 ROFF_dei1,
130 131 ROFF_device,
131 132 ROFF_devicem,
132 133 ROFF_di,
133 134 ROFF_do,
134 135 ROFF_ds,
135 136 ROFF_ds1,
136 137 ROFF_dwh,
137 138 ROFF_dt,
138 139 ROFF_ec,
139 140 ROFF_ecr,
140 141 ROFF_ecs,
141 142 ROFF_el,
142 143 ROFF_em,
143 144 ROFF_EN,
144 145 ROFF_eo,
145 146 ROFF_EP,
146 147 ROFF_EQ,
147 148 ROFF_errprint,
148 149 ROFF_ev,
149 150 ROFF_evc,
150 151 ROFF_ex,
151 152 ROFF_fallback,
152 153 ROFF_fam,
153 154 ROFF_fc,
154 155 ROFF_fchar,
155 156 ROFF_fcolor,
156 157 ROFF_fdeferlig,
157 158 ROFF_feature,
158 159 /* MAN_fi; ignored in mdoc(7) */
159 160 ROFF_fkern,
160 161 ROFF_fl,
161 162 ROFF_flig,
162 163 ROFF_fp,
163 164 ROFF_fps,
164 165 ROFF_fschar,
165 166 ROFF_fspacewidth,
166 167 ROFF_fspecial,
167 168 ROFF_ftr,
168 169 ROFF_fzoom,
169 170 ROFF_gcolor,
170 171 ROFF_hc,
171 172 ROFF_hcode,
172 173 ROFF_hidechar,
173 174 ROFF_hla,
174 175 ROFF_hlm,
175 176 ROFF_hpf,
176 177 ROFF_hpfa,
177 178 ROFF_hpfcode,
178 179 ROFF_hw,
179 180 ROFF_hy,
180 181 ROFF_hylang,
181 182 ROFF_hylen,
182 183 ROFF_hym,
183 184 ROFF_hypp,
184 185 ROFF_hys,
185 186 ROFF_ie,
186 187 ROFF_if,
187 188 ROFF_ig,
188 189 /* MAN_in; ignored in mdoc(7) */
189 190 ROFF_index,
190 191 ROFF_it,
191 192 ROFF_itc,
192 193 ROFF_IX,
193 194 ROFF_kern,
194 195 ROFF_kernafter,
195 196 ROFF_kernbefore,
196 197 ROFF_kernpair,
197 198 ROFF_lc,
198 199 ROFF_lc_ctype,
199 200 ROFF_lds,
200 201 ROFF_length,
201 202 ROFF_letadj,
202 203 ROFF_lf,
203 204 ROFF_lg,
204 205 ROFF_lhang,
205 206 ROFF_linetabs,
206 207 ROFF_lnr,
207 208 ROFF_lnrf,
208 209 ROFF_lpfx,
209 210 ROFF_ls,
210 211 ROFF_lsm,
211 212 ROFF_lt,
212 213 ROFF_mediasize,
213 214 ROFF_minss,
214 215 ROFF_mk,
215 216 ROFF_mso,
216 217 ROFF_na,
217 218 ROFF_ne,
218 219 /* MAN_nf; ignored in mdoc(7) */
219 220 ROFF_nh,
220 221 ROFF_nhychar,
221 222 ROFF_nm,
222 223 ROFF_nn,
223 224 ROFF_nop,
224 225 ROFF_nr,
225 226 ROFF_nrf,
226 227 ROFF_nroff,
227 228 ROFF_ns,
228 229 ROFF_nx,
229 230 ROFF_open,
230 231 ROFF_opena,
231 232 ROFF_os,
232 233 ROFF_output,
233 234 ROFF_padj,
234 235 ROFF_papersize,
235 236 ROFF_pc,
236 237 ROFF_pev,
237 238 ROFF_pi,
238 239 ROFF_PI,
239 240 ROFF_pl,
240 241 ROFF_pm,
241 242 ROFF_pn,
242 243 ROFF_pnr,
243 244 ROFF_ps,
244 245 ROFF_psbb,
245 246 ROFF_pshape,
246 247 ROFF_pso,
247 248 ROFF_ptr,
248 249 ROFF_pvs,
249 250 ROFF_rchar,
250 251 ROFF_rd,
251 252 ROFF_recursionlimit,
252 253 ROFF_return,
253 254 ROFF_rfschar,
254 255 ROFF_rhang,
255 256 ROFF_rm,
256 257 ROFF_rn,
257 258 ROFF_rnn,
258 259 ROFF_rr,
259 260 ROFF_rs,
260 261 ROFF_rt,
261 262 ROFF_schar,
262 263 ROFF_sentchar,
263 264 ROFF_shc,
264 265 ROFF_shift,
265 266 ROFF_sizes,
266 267 ROFF_so,
267 268 ROFF_spacewidth,
268 269 ROFF_special,
269 270 ROFF_spreadwarn,
270 271 ROFF_ss,
271 272 ROFF_sty,
272 273 ROFF_substring,
273 274 ROFF_sv,
274 275 ROFF_sy,
275 276 ROFF_T_,
276 277 ROFF_tc,
277 278 ROFF_TE,
278 279 ROFF_TH,
279 280 ROFF_tkf,
280 281 ROFF_tl,
281 282 ROFF_tm,
282 283 ROFF_tm1,
283 284 ROFF_tmc,
284 285 ROFF_tr,
285 286 ROFF_track,
286 287 ROFF_transchar,
287 288 ROFF_trf,
288 289 ROFF_trimat,
289 290 ROFF_trin,
290 291 ROFF_trnt,
291 292 ROFF_troff,
292 293 ROFF_TS,
293 294 ROFF_uf,
294 295 ROFF_ul,
295 296 ROFF_unformat,
296 297 ROFF_unwatch,
297 298 ROFF_unwatchn,
298 299 ROFF_vpt,
299 300 ROFF_vs,
300 301 ROFF_warn,
301 302 ROFF_warnscale,
302 303 ROFF_watch,
303 304 ROFF_watchlength,
304 305 ROFF_watchn,
305 306 ROFF_wh,
306 307 ROFF_while,
307 308 ROFF_write,
308 309 ROFF_writec,
309 310 ROFF_writem,
310 311 ROFF_xflag,
311 312 ROFF_cblock,
312 313 ROFF_RENAMED,
313 314 ROFF_USERDEF,
314 315 TOKEN_NONE,
315 316 MDOC_Dd,
316 317 MDOC_Dt,
317 318 MDOC_Os,
318 319 MDOC_Sh,
319 320 MDOC_Ss,
320 321 MDOC_Pp,
321 322 MDOC_D1,
322 323 MDOC_Dl,
323 324 MDOC_Bd,
324 325 MDOC_Ed,
325 326 MDOC_Bl,
326 327 MDOC_El,
327 328 MDOC_It,
328 329 MDOC_Ad,
329 330 MDOC_An,
330 331 MDOC_Ap,
331 332 MDOC_Ar,
332 333 MDOC_Cd,
333 334 MDOC_Cm,
334 335 MDOC_Dv,
335 336 MDOC_Er,
336 337 MDOC_Ev,
337 338 MDOC_Ex,
338 339 MDOC_Fa,
339 340 MDOC_Fd,
340 341 MDOC_Fl,
341 342 MDOC_Fn,
342 343 MDOC_Ft,
343 344 MDOC_Ic,
344 345 MDOC_In,
345 346 MDOC_Li,
346 347 MDOC_Nd,
347 348 MDOC_Nm,
348 349 MDOC_Op,
349 350 MDOC_Ot,
350 351 MDOC_Pa,
351 352 MDOC_Rv,
352 353 MDOC_St,
353 354 MDOC_Va,
354 355 MDOC_Vt,
355 356 MDOC_Xr,
356 357 MDOC__A,
357 358 MDOC__B,
358 359 MDOC__D,
359 360 MDOC__I,
360 361 MDOC__J,
361 362 MDOC__N,
362 363 MDOC__O,
363 364 MDOC__P,
364 365 MDOC__R,
365 366 MDOC__T,
366 367 MDOC__V,
367 368 MDOC_Ac,
368 369 MDOC_Ao,
369 370 MDOC_Aq,
370 371 MDOC_At,
371 372 MDOC_Bc,
372 373 MDOC_Bf,
373 374 MDOC_Bo,
374 375 MDOC_Bq,
375 376 MDOC_Bsx,
376 377 MDOC_Bx,
377 378 MDOC_Db,
378 379 MDOC_Dc,
379 380 MDOC_Do,
380 381 MDOC_Dq,
381 382 MDOC_Ec,
382 383 MDOC_Ef,
383 384 MDOC_Em,
384 385 MDOC_Eo,
385 386 MDOC_Fx,
386 387 MDOC_Ms,
387 388 MDOC_No,
388 389 MDOC_Ns,
389 390 MDOC_Nx,
390 391 MDOC_Ox,
391 392 MDOC_Pc,
392 393 MDOC_Pf,
393 394 MDOC_Po,
394 395 MDOC_Pq,
395 396 MDOC_Qc,
396 397 MDOC_Ql,
397 398 MDOC_Qo,
398 399 MDOC_Qq,
399 400 MDOC_Re,
400 401 MDOC_Rs,
401 402 MDOC_Sc,
402 403 MDOC_So,
403 404 MDOC_Sq,
404 405 MDOC_Sm,
405 406 MDOC_Sx,
406 407 MDOC_Sy,
407 408 MDOC_Tn,
408 409 MDOC_Ux,
409 410 MDOC_Xc,
410 411 MDOC_Xo,
411 412 MDOC_Fo,
412 413 MDOC_Fc,
413 414 MDOC_Oo,
414 415 MDOC_Oc,
415 416 MDOC_Bk,
416 417 MDOC_Ek,
417 418 MDOC_Bt,
418 419 MDOC_Hf,
419 420 MDOC_Fr,
420 421 MDOC_Ud,
421 422 MDOC_Lb,
422 423 MDOC_Lp,
423 424 MDOC_Lk,
424 425 MDOC_Mt,
425 426 MDOC_Brq,
426 427 MDOC_Bro,
427 428 MDOC_Brc,
428 429 MDOC__C,
429 430 MDOC_Es,
430 431 MDOC_En,
431 432 MDOC_Dx,
432 433 MDOC__Q,
433 434 MDOC__U,
434 435 MDOC_Ta,
435 436 MDOC_MAX,
436 437 MAN_TH,
437 438 MAN_SH,
438 439 MAN_SS,
439 440 MAN_TP,
440 441 MAN_LP,
441 442 MAN_PP,
442 443 MAN_P,
443 444 MAN_IP,
444 445 MAN_HP,
445 446 MAN_SM,
446 447 MAN_SB,
447 448 MAN_BI,
448 449 MAN_IB,
449 450 MAN_BR,
450 451 MAN_RB,
451 452 MAN_R,
452 453 MAN_B,
453 454 MAN_I,
454 455 MAN_IR,
455 456 MAN_RI,
456 457 MAN_nf,
457 458 MAN_fi,
458 459 MAN_RE,
459 460 MAN_RS,
460 461 MAN_DT,
461 462 MAN_UC,
462 463 MAN_PD,
463 464 MAN_AT,
464 465 MAN_in,
465 466 MAN_OP,
466 467 MAN_EX,
467 468 MAN_EE,
468 469 MAN_UR,
469 470 MAN_UE,
470 471 MAN_MT,
471 472 MAN_ME,
472 473 MAN_MAX
473 474 };
474 475
475 476 enum roff_next {
476 477 ROFF_NEXT_SIBLING = 0,
477 478 ROFF_NEXT_CHILD
478 479 };
479 480
480 481 /*
481 482 * Indicates that a BODY's formatting has ended, but
482 483 * the scope is still open. Used for badly nested blocks.
483 484 */
484 485 enum mdoc_endbody {
485 486 ENDBODY_NOT = 0,
486 487 ENDBODY_SPACE /* Is broken: append a space. */
487 488 };
488 489
489 490 struct roff_node {
490 491 struct roff_node *parent; /* Parent AST node. */
491 492 struct roff_node *child; /* First child AST node. */
492 493 struct roff_node *last; /* Last child AST node. */
493 494 struct roff_node *next; /* Sibling AST node. */
494 495 struct roff_node *prev; /* Prior sibling AST node. */
495 496 struct roff_node *head; /* BLOCK */
496 497 struct roff_node *body; /* BLOCK/ENDBODY */
497 498 struct roff_node *tail; /* BLOCK */
498 499 struct mdoc_arg *args; /* BLOCK/ELEM */
499 500 union mdoc_data *norm; /* Normalized arguments. */
500 501 char *string; /* TEXT */
501 502 const struct tbl_span *span; /* TBL */
502 503 struct eqn_box *eqn; /* EQN */
503 504 int line; /* Input file line number. */
504 505 int pos; /* Input file column number. */
505 506 int flags;
506 507 #define NODE_VALID (1 << 0) /* Has been validated. */
507 508 #define NODE_ENDED (1 << 1) /* Gone past body end mark. */
508 509 #define NODE_EOS (1 << 2) /* At sentence boundary. */
509 510 #define NODE_LINE (1 << 3) /* First macro/text on line. */
510 511 #define NODE_SYNPRETTY (1 << 4) /* SYNOPSIS-style formatting. */
511 512 #define NODE_BROKEN (1 << 5) /* Must validate parent when ending. */
512 513 #define NODE_DELIMO (1 << 6)
513 514 #define NODE_DELIMC (1 << 7)
514 515 #define NODE_NOSRC (1 << 8) /* Generated node, not in input file. */
515 516 #define NODE_NOPRT (1 << 9) /* Shall not print anything. */
516 517 int prev_font; /* Before entering this node. */
517 518 int aux; /* Decoded node data, type-dependent. */
518 519 enum roff_tok tok; /* Request or macro ID. */
519 520 enum roff_type type; /* AST node type. */
520 521 enum roff_sec sec; /* Current named section. */
521 522 enum mdoc_endbody end; /* BODY */
522 523 };
523 524
524 525 struct roff_meta {
525 526 char *msec; /* Manual section, usually a digit. */
526 527 char *vol; /* Manual volume title. */
527 528 char *os; /* Operating system. */
528 529 char *arch; /* Machine architecture. */
529 530 char *title; /* Manual title, usually CAPS. */
530 531 char *name; /* Leading manual name. */
531 532 char *date; /* Normalized date. */
532 533 int hasbody; /* Document is not empty. */
533 534 int rcsids; /* Bits indexed by enum mandoc_os. */
534 535 enum mandoc_os os_e; /* Operating system. */
535 536 };
536 537
537 538 struct roff_man {
538 539 struct roff_meta meta; /* Document meta-data. */
539 540 struct mparse *parse; /* Parse pointer. */
540 541 struct roff *roff; /* Roff parser state data. */
541 542 struct ohash *mdocmac; /* Mdoc macro lookup table. */
542 543 struct ohash *manmac; /* Man macro lookup table. */
543 544 const char *os_s; /* Default operating system. */
544 545 struct roff_node *first; /* The first node parsed. */
545 546 struct roff_node *last; /* The last node parsed. */
546 547 struct roff_node *last_es; /* The most recent Es node. */
547 548 int quick; /* Abort parse early. */
548 549 int flags; /* Parse flags. */
549 550 #define MDOC_LITERAL (1 << 1) /* In a literal scope. */
550 551 #define MDOC_PBODY (1 << 2) /* In the document body. */
551 552 #define MDOC_NEWLINE (1 << 3) /* First macro/text in a line. */
552 553 #define MDOC_PHRASE (1 << 4) /* In a Bl -column phrase. */
553 554 #define MDOC_PHRASELIT (1 << 5) /* Literal within a phrase. */
554 555 #define MDOC_FREECOL (1 << 6) /* `It' invocation should close. */
555 556 #define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting. */
556 557 #define MDOC_KEEP (1 << 8) /* In a word keep. */
557 558 #define MDOC_SMOFF (1 << 9) /* Spacing is off. */
558 559 #define MDOC_NODELIMC (1 << 10) /* Disable closing delimiter handling. */
559 560 #define MAN_ELINE (1 << 11) /* Next-line element scope. */
560 561 #define MAN_BLINE (1 << 12) /* Next-line block scope. */
561 562 #define MDOC_PHRASEQF (1 << 13) /* Quote first word encountered. */
562 563 #define MDOC_PHRASEQL (1 << 14) /* Quote last word of this phrase. */
563 564 #define MDOC_PHRASEQN (1 << 15) /* Quote first word of the next phrase. */
564 565 #define MAN_LITERAL MDOC_LITERAL
565 566 #define MAN_NEWLINE MDOC_NEWLINE
566 567 enum roff_macroset macroset; /* Kind of high-level macros used. */
567 568 enum roff_sec lastsec; /* Last section seen. */
568 569 enum roff_sec lastnamed; /* Last standard section seen. */
569 570 enum roff_next next; /* Where to put the next node. */
570 571 };
571 572
572 573 extern const char *const *roff_name;
573 574
574 575
575 576 void deroff(char **, const struct roff_node *);
576 577 struct ohash *roffhash_alloc(enum roff_tok, enum roff_tok);
577 578 enum roff_tok roffhash_find(struct ohash *, const char *, size_t);
578 579 void roffhash_free(struct ohash *);
579 580 void roff_validate(struct roff_man *);
↓ open down ↓ |
506 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX