]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_macro.c
1 /* $Id: mdoc_macro.c,v 1.223 2017/05/05 15:17:32 schwarze Exp $ */
3 * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #include <sys/types.h>
32 #include "libmandoc.h"
36 static void blk_full(MACRO_PROT_ARGS
);
37 static void blk_exp_close(MACRO_PROT_ARGS
);
38 static void blk_part_exp(MACRO_PROT_ARGS
);
39 static void blk_part_imp(MACRO_PROT_ARGS
);
40 static void ctx_synopsis(MACRO_PROT_ARGS
);
41 static void in_line_eoln(MACRO_PROT_ARGS
);
42 static void in_line_argn(MACRO_PROT_ARGS
);
43 static void in_line(MACRO_PROT_ARGS
);
44 static void phrase_ta(MACRO_PROT_ARGS
);
46 static void append_delims(struct roff_man
*, int, int *, char *);
47 static void dword(struct roff_man
*, int, int, const char *,
49 static int find_pending(struct roff_man
*, enum roff_tok
,
50 int, int, struct roff_node
*);
51 static int lookup(struct roff_man
*, int, int, int, const char *);
52 static int macro_or_word(MACRO_PROT_ARGS
, int);
53 static void break_intermediate(struct roff_node
*,
55 static int parse_rest(struct roff_man
*, enum roff_tok
,
57 static enum roff_tok
rew_alt(enum roff_tok
);
58 static void rew_elem(struct roff_man
*, enum roff_tok
);
59 static void rew_last(struct roff_man
*, const struct roff_node
*);
60 static void rew_pending(struct roff_man
*,
61 const struct roff_node
*);
63 const struct mdoc_macro __mdoc_macros
[MDOC_MAX
- MDOC_Dd
] = {
64 { in_line_eoln
, MDOC_PROLOGUE
}, /* Dd */
65 { in_line_eoln
, MDOC_PROLOGUE
}, /* Dt */
66 { in_line_eoln
, MDOC_PROLOGUE
}, /* Os */
67 { blk_full
, MDOC_PARSED
| MDOC_JOIN
}, /* Sh */
68 { blk_full
, MDOC_PARSED
| MDOC_JOIN
}, /* Ss */
69 { in_line_eoln
, 0 }, /* Pp */
70 { blk_part_imp
, MDOC_PARSED
| MDOC_JOIN
}, /* D1 */
71 { blk_part_imp
, MDOC_PARSED
| MDOC_JOIN
}, /* Dl */
72 { blk_full
, MDOC_EXPLICIT
}, /* Bd */
73 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ed */
74 { blk_full
, MDOC_EXPLICIT
}, /* Bl */
75 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* El */
76 { blk_full
, MDOC_PARSED
| MDOC_JOIN
}, /* It */
77 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ad */
78 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* An */
79 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ap */
80 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ar */
81 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Cd */
82 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Cm */
83 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dv */
84 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Er */
85 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ev */
86 { in_line_eoln
, 0 }, /* Ex */
87 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fa */
88 { in_line_eoln
, 0 }, /* Fd */
89 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fl */
90 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fn */
91 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ft */
92 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ic */
93 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* In */
94 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Li */
95 { blk_full
, MDOC_JOIN
}, /* Nd */
96 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nm */
97 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Op */
98 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ot */
99 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Pa */
100 { in_line_eoln
, 0 }, /* Rv */
101 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* St */
102 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Va */
103 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Vt */
104 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Xr */
105 { in_line_eoln
, MDOC_JOIN
}, /* %A */
106 { in_line_eoln
, MDOC_JOIN
}, /* %B */
107 { in_line_eoln
, MDOC_JOIN
}, /* %D */
108 { in_line_eoln
, MDOC_JOIN
}, /* %I */
109 { in_line_eoln
, MDOC_JOIN
}, /* %J */
110 { in_line_eoln
, 0 }, /* %N */
111 { in_line_eoln
, MDOC_JOIN
}, /* %O */
112 { in_line_eoln
, 0 }, /* %P */
113 { in_line_eoln
, MDOC_JOIN
}, /* %R */
114 { in_line_eoln
, MDOC_JOIN
}, /* %T */
115 { in_line_eoln
, 0 }, /* %V */
116 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
117 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ac */
118 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
119 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ao */
120 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Aq */
121 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* At */
122 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
123 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bc */
124 { blk_full
, MDOC_EXPLICIT
}, /* Bf */
125 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
126 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bo */
127 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Bq */
128 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bsx */
129 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bx */
130 { in_line_eoln
, 0 }, /* Db */
131 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
132 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Dc */
133 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
134 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Do */
135 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Dq */
136 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Ec */
137 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ef */
138 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Em */
139 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Eo */
140 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fx */
141 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ms */
142 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* No */
143 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
|
144 MDOC_IGNDELIM
| MDOC_JOIN
}, /* Ns */
145 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nx */
146 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ox */
147 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
148 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Pc */
149 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_IGNDELIM
}, /* Pf */
150 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
151 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Po */
152 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Pq */
153 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
154 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Qc */
155 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ql */
156 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
157 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Qo */
158 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Qq */
159 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Re */
160 { blk_full
, MDOC_EXPLICIT
}, /* Rs */
161 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
162 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Sc */
163 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
164 MDOC_EXPLICIT
| MDOC_JOIN
}, /* So */
165 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sq */
166 { in_line_argn
, 0 }, /* Sm */
167 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sx */
168 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sy */
169 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Tn */
170 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ux */
171 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Xc */
172 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Xo */
173 { blk_full
, MDOC_EXPLICIT
| MDOC_CALLABLE
}, /* Fo */
174 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
175 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Fc */
176 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
177 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Oo */
178 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
179 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Oc */
180 { blk_full
, MDOC_EXPLICIT
}, /* Bk */
181 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ek */
182 { in_line_eoln
, 0 }, /* Bt */
183 { in_line_eoln
, 0 }, /* Hf */
184 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fr */
185 { in_line_eoln
, 0 }, /* Ud */
186 { in_line
, 0 }, /* Lb */
187 { in_line_eoln
, 0 }, /* Lp */
188 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Lk */
189 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Mt */
190 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Brq */
191 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
192 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bro */
193 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
194 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Brc */
195 { in_line_eoln
, MDOC_JOIN
}, /* %C */
196 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Es */
197 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* En */
198 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dx */
199 { in_line_eoln
, MDOC_JOIN
}, /* %Q */
200 { in_line_eoln
, 0 }, /* %U */
201 { phrase_ta
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ta */
203 const struct mdoc_macro
*const mdoc_macros
= __mdoc_macros
- MDOC_Dd
;
207 * This is called at the end of parsing. It must traverse up the tree,
208 * closing out open [implicit] scopes. Obviously, open explicit scopes
212 mdoc_endparse(struct roff_man
*mdoc
)
216 /* Scan for open explicit scopes. */
218 n
= mdoc
->last
->flags
& NODE_VALID
?
219 mdoc
->last
->parent
: mdoc
->last
;
221 for ( ; n
; n
= n
->parent
)
222 if (n
->type
== ROFFT_BLOCK
&&
223 mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
)
224 mandoc_msg(MANDOCERR_BLK_NOEND
, mdoc
->parse
,
225 n
->line
, n
->pos
, roff_name
[n
->tok
]);
227 /* Rewind to the first. */
229 rew_last(mdoc
, mdoc
->first
);
230 mdoc_state_reset(mdoc
);
234 * Look up the macro at *p called by "from",
235 * or as a line macro if from == TOKEN_NONE.
238 lookup(struct roff_man
*mdoc
, int from
, int line
, int ppos
, const char *p
)
242 if (mdoc
->flags
& MDOC_PHRASEQF
) {
243 mdoc
->flags
&= ~MDOC_PHRASEQF
;
246 if (from
== TOKEN_NONE
|| mdoc_macros
[from
].flags
& MDOC_PARSED
) {
247 res
= roffhash_find(mdoc
->mdocmac
, p
, 0);
248 if (res
!= TOKEN_NONE
) {
249 if (mdoc_macros
[res
].flags
& MDOC_CALLABLE
)
251 mandoc_msg(MANDOCERR_MACRO_CALL
,
252 mdoc
->parse
, line
, ppos
, p
);
259 * Rewind up to and including a specific node.
262 rew_last(struct roff_man
*mdoc
, const struct roff_node
*to
)
265 if (to
->flags
& NODE_VALID
)
268 while (mdoc
->last
!= to
) {
269 mdoc_state(mdoc
, mdoc
->last
);
270 mdoc
->last
->flags
|= NODE_VALID
| NODE_ENDED
;
271 mdoc
->last
= mdoc
->last
->parent
;
273 mdoc_state(mdoc
, mdoc
->last
);
274 mdoc
->last
->flags
|= NODE_VALID
| NODE_ENDED
;
275 mdoc
->next
= ROFF_NEXT_SIBLING
;
279 * Rewind up to a specific block, including all blocks that broke it.
282 rew_pending(struct roff_man
*mdoc
, const struct roff_node
*n
)
288 if (mdoc
->last
== n
) {
291 roff_body_alloc(mdoc
, n
->line
, n
->pos
,
299 if ( ! (n
->flags
& NODE_BROKEN
))
305 if ((n
= n
->parent
) == NULL
)
308 if (n
->type
== ROFFT_BLOCK
||
309 n
->type
== ROFFT_HEAD
) {
310 if (n
->flags
& NODE_ENDED
)
320 * For a block closing macro, return the corresponding opening one.
321 * Otherwise, return the macro itself.
324 rew_alt(enum roff_tok tok
)
365 rew_elem(struct roff_man
*mdoc
, enum roff_tok tok
)
370 if (n
->type
!= ROFFT_ELEM
)
372 assert(n
->type
== ROFFT_ELEM
);
373 assert(tok
== n
->tok
);
378 break_intermediate(struct roff_node
*n
, struct roff_node
*breaker
)
381 n
->type
!= ROFFT_BLOCK
&& n
->type
!= ROFFT_HEAD
&&
382 (n
->type
!= ROFFT_BODY
|| n
->end
!= ENDBODY_NOT
))
384 while (n
!= breaker
) {
385 if ( ! (n
->flags
& NODE_VALID
))
386 n
->flags
|= NODE_BROKEN
;
392 * If there is an open sub-block of the target requiring
393 * explicit close-out, postpone closing out the target until
394 * the rew_pending() call closing out the sub-block.
397 find_pending(struct roff_man
*mdoc
, enum roff_tok tok
, int line
, int ppos
,
398 struct roff_node
*target
)
403 if (target
->flags
& NODE_VALID
)
407 for (n
= mdoc
->last
; n
!= NULL
&& n
!= target
; n
= n
->parent
) {
408 if (n
->flags
& NODE_ENDED
)
410 if (n
->type
== ROFFT_BLOCK
&&
411 mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
) {
413 break_intermediate(mdoc
->last
, target
);
414 if (target
->type
== ROFFT_HEAD
)
415 target
->flags
|= NODE_ENDED
;
416 else if ( ! (target
->flags
& NODE_ENDED
)) {
417 mandoc_vmsg(MANDOCERR_BLK_NEST
,
418 mdoc
->parse
, line
, ppos
,
419 "%s breaks %s", roff_name
[tok
],
421 mdoc_endbody_alloc(mdoc
, line
, ppos
,
430 * Allocate a word and check whether it's punctuation or not.
431 * Punctuation consists of those tokens found in mdoc_isdelim().
434 dword(struct roff_man
*mdoc
, int line
, int col
, const char *p
,
435 enum mdelim d
, int may_append
)
442 ! (mdoc
->flags
& (MDOC_SYNOPSIS
| MDOC_KEEP
| MDOC_SMOFF
)) &&
443 d
== DELIM_NONE
&& mdoc
->last
->type
== ROFFT_TEXT
&&
444 mdoc_isdelim(mdoc
->last
->string
) == DELIM_NONE
) {
445 roff_word_append(mdoc
, p
);
449 roff_word_alloc(mdoc
, line
, col
, p
);
452 * If the word consists of a bare delimiter,
453 * flag the new node accordingly,
454 * unless doing so was vetoed by the invoking macro.
455 * Always clear the veto, it is only valid for one word.
459 mdoc
->last
->flags
|= NODE_DELIMO
;
460 else if (d
== DELIM_CLOSE
&&
461 ! (mdoc
->flags
& MDOC_NODELIMC
) &&
462 mdoc
->last
->parent
->tok
!= MDOC_Fd
)
463 mdoc
->last
->flags
|= NODE_DELIMC
;
464 mdoc
->flags
&= ~MDOC_NODELIMC
;
468 append_delims(struct roff_man
*mdoc
, int line
, int *pos
, char *buf
)
473 if (buf
[*pos
] == '\0')
478 if (mdoc_args(mdoc
, line
, pos
, buf
, TOKEN_NONE
, &p
) ==
481 dword(mdoc
, line
, la
, p
, DELIM_MAX
, 1);
484 * If we encounter end-of-sentence symbols, then trigger
487 * XXX: it's easy to allow this to propagate outward to
488 * the last symbol, such that `. )' will cause the
489 * correct double-spacing. However, (1) groff isn't
490 * smart enough to do this and (2) it would require
491 * knowing which symbols break this behaviour, for
492 * example, `. ;' shouldn't propagate the double-space.
495 if (mandoc_eos(p
, strlen(p
)))
496 mdoc
->last
->flags
|= NODE_EOS
;
502 * If it is a macro, call it and return 1.
503 * Otherwise, allocate it and return 0.
506 macro_or_word(MACRO_PROT_ARGS
, int parsed
)
515 else if (parsed
&& ! (mdoc
->flags
& MDOC_PHRASELIT
))
516 ntok
= lookup(mdoc
, tok
, line
, ppos
, p
);
518 if (ntok
== TOKEN_NONE
) {
519 dword(mdoc
, line
, ppos
, p
, DELIM_MAX
, tok
== TOKEN_NONE
||
520 mdoc_macros
[tok
].flags
& MDOC_JOIN
);
523 if (tok
!= TOKEN_NONE
&&
524 mdoc_macros
[tok
].fp
== in_line_eoln
)
526 mdoc_macro(mdoc
, ntok
, line
, ppos
, pos
, buf
);
527 if (tok
== TOKEN_NONE
)
528 append_delims(mdoc
, line
, pos
, buf
);
534 * Close out block partial/full explicit.
537 blk_exp_close(MACRO_PROT_ARGS
)
539 struct roff_node
*body
; /* Our own body. */
540 struct roff_node
*endbody
; /* Our own end marker. */
541 struct roff_node
*itblk
; /* An It block starting later. */
542 struct roff_node
*later
; /* A sub-block starting later. */
543 struct roff_node
*n
; /* Search back to our block. */
544 struct roff_node
*target
; /* For find_pending(). */
546 int j
, lastarg
, maxargs
, nl
, pending
;
548 enum roff_tok atok
, ntok
;
551 nl
= MDOC_NEWLINE
& mdoc
->flags
;
558 mdoc
->flags
&= ~MDOC_KEEP
;
565 /* Search backwards for the beginning of our own body. */
569 for (n
= mdoc
->last
; n
; n
= n
->parent
) {
570 if (n
->flags
& NODE_ENDED
|| n
->tok
!= atok
||
571 n
->type
!= ROFFT_BODY
|| n
->end
!= ENDBODY_NOT
)
578 * Search backwards for beginnings of blocks,
579 * both of our own and of pending sub-blocks.
582 endbody
= itblk
= later
= NULL
;
583 for (n
= mdoc
->last
; n
; n
= n
->parent
) {
584 if (n
->flags
& NODE_ENDED
)
588 * Mismatching end macros can never break anything
589 * and we only care about the breaking of BLOCKs.
592 if (body
== NULL
|| n
->type
!= ROFFT_BLOCK
)
596 * SYNOPSIS name blocks can not be broken themselves,
597 * but they do get broken together with a broken child.
600 if (n
->tok
== MDOC_Nm
) {
602 n
->flags
|= NODE_BROKEN
| NODE_ENDED
;
606 if (n
->tok
== MDOC_It
) {
611 if (atok
== n
->tok
) {
614 * Found the start of our own block.
615 * When there is no pending sub block,
616 * just proceed to closing out.
620 (tok
== MDOC_El
&& itblk
== NULL
))
624 * When there is a pending sub block, postpone
625 * closing out the current block until the
626 * rew_pending() closing out the sub-block.
627 * Mark the place where the formatting - but not
628 * the scope - of the current block ends.
631 mandoc_vmsg(MANDOCERR_BLK_NEST
, mdoc
->parse
,
632 line
, ppos
, "%s breaks %s",
633 roff_name
[atok
], roff_name
[later
->tok
]);
635 endbody
= mdoc_endbody_alloc(mdoc
, line
, ppos
,
639 itblk
->flags
|= NODE_ENDED
| NODE_BROKEN
;
642 * If a block closing macro taking arguments
643 * breaks another block, put the arguments
644 * into the end marker.
648 mdoc
->next
= ROFF_NEXT_CHILD
;
653 * Explicit blocks close out description lines, but
654 * even those can get broken together with a child.
657 if (n
->tok
== MDOC_Nd
) {
659 n
->flags
|= NODE_BROKEN
| NODE_ENDED
;
665 /* Breaking an open sub block. */
667 break_intermediate(mdoc
->last
, body
);
668 n
->flags
|= NODE_BROKEN
;
674 mandoc_msg(MANDOCERR_BLK_NOTOPEN
, mdoc
->parse
,
675 line
, ppos
, roff_name
[tok
]);
676 if (maxargs
&& endbody
== NULL
) {
678 * Stray .Ec without previous .Eo:
679 * Break the output line, keep the arguments.
681 roff_elem_alloc(mdoc
, line
, ppos
, ROFF_br
);
682 rew_elem(mdoc
, ROFF_br
);
684 } else if (endbody
== NULL
) {
685 rew_last(mdoc
, body
);
687 mdoc_tail_alloc(mdoc
, line
, ppos
, atok
);
690 if ( ! (mdoc_macros
[tok
].flags
& MDOC_PARSED
)) {
691 if (buf
[*pos
] != '\0')
692 mandoc_vmsg(MANDOCERR_ARG_SKIP
,
693 mdoc
->parse
, line
, ppos
,
694 "%s %s", roff_name
[tok
],
696 if (endbody
== NULL
&& n
!= NULL
)
697 rew_pending(mdoc
, n
);
708 if (j
== maxargs
&& n
!= NULL
)
711 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
712 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
)
715 ntok
= ac
== ARGS_QWORD
? TOKEN_NONE
:
716 lookup(mdoc
, tok
, line
, lastarg
, p
);
718 if (ntok
== TOKEN_NONE
) {
719 dword(mdoc
, line
, lastarg
, p
, DELIM_MAX
,
720 MDOC_JOIN
& mdoc_macros
[tok
].flags
);
726 mdoc
->flags
&= ~MDOC_NEWLINE
;
727 mdoc_macro(mdoc
, ntok
, line
, lastarg
, pos
, buf
);
733 if (ntok
!= TOKEN_NONE
&& n
->flags
& NODE_BROKEN
) {
736 target
= target
->parent
;
737 while ( ! (target
->flags
& NODE_ENDED
));
738 pending
= find_pending(mdoc
, ntok
, line
, ppos
, target
);
741 rew_pending(mdoc
, n
);
744 append_delims(mdoc
, line
, pos
, buf
);
748 in_line(MACRO_PROT_ARGS
)
750 int la
, scope
, cnt
, firstarg
, mayopen
, nc
, nl
;
754 struct mdoc_arg
*arg
;
757 nl
= MDOC_NEWLINE
& mdoc
->flags
;
760 * Whether we allow ignored elements (those without content,
761 * usually because of reserved words) to squeak by.
778 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
783 for (cnt
= scope
= 0;; ) {
785 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
788 * At the end of a macro line,
789 * opening delimiters do not suppress spacing.
792 if (ac
== ARGS_EOLN
) {
794 mdoc
->last
->flags
&= ~NODE_DELIMO
;
799 * The rest of the macro line is only punctuation,
800 * to be handled by append_delims().
801 * If there were no other arguments,
802 * do not allow the first one to suppress spacing,
803 * even if it turns out to be a closing one.
806 if (ac
== ARGS_PUNCT
) {
807 if (cnt
== 0 && (nc
== 0 || tok
== MDOC_An
))
808 mdoc
->flags
|= MDOC_NODELIMC
;
812 ntok
= (ac
== ARGS_QWORD
|| (tok
== MDOC_Fn
&& !cnt
)) ?
813 TOKEN_NONE
: lookup(mdoc
, tok
, line
, la
, p
);
816 * In this case, we've located a submacro and must
817 * execute it. Close out scope, if open. If no
818 * elements have been generated, either create one (nc)
819 * or raise a warning.
822 if (ntok
!= TOKEN_NONE
) {
826 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
827 rew_last(mdoc
, mdoc
->last
);
828 } else if ( ! nc
&& ! cnt
) {
830 mandoc_msg(MANDOCERR_MACRO_EMPTY
,
831 mdoc
->parse
, line
, ppos
,
834 mdoc_macro(mdoc
, ntok
, line
, la
, pos
, buf
);
836 append_delims(mdoc
, line
, pos
, buf
);
841 * Non-quote-enclosed punctuation. Set up our scope, if
842 * a word; rewind the scope, if a delimiter; then append
846 d
= ac
== ARGS_QWORD
? DELIM_NONE
: mdoc_isdelim(p
);
848 if (DELIM_NONE
!= d
) {
850 * If we encounter closing punctuation, no word
851 * has been emitted, no scope is open, and we're
852 * allowed to have an empty element, then start
855 if ((d
== DELIM_CLOSE
||
856 (d
== DELIM_MIDDLE
&& tok
== MDOC_Fl
)) &&
857 !cnt
&& !scope
&& nc
&& mayopen
) {
858 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
865 * Close out our scope, if one is open, before
873 } else if (mayopen
&& !scope
) {
874 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
879 dword(mdoc
, line
, la
, p
, d
,
880 mdoc_macros
[tok
].flags
& MDOC_JOIN
);
883 * If the first argument is a closing delimiter,
884 * do not suppress spacing before it.
887 if (firstarg
&& d
== DELIM_CLOSE
&& !nc
)
888 mdoc
->last
->flags
&= ~NODE_DELIMC
;
892 * `Fl' macros have their scope re-opened with each new
893 * word so that the `-' can be added to each one without
894 * having to parse out spaces.
896 if (scope
&& tok
== MDOC_Fl
) {
902 if (scope
&& tok
!= MDOC_Lk
) {
908 * If no elements have been collected and we're allowed to have
909 * empties (nc), open a scope and close it out. Otherwise,
915 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
916 rew_last(mdoc
, mdoc
->last
);
919 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
920 line
, ppos
, roff_name
[tok
]);
924 append_delims(mdoc
, line
, pos
, buf
);
930 blk_full(MACRO_PROT_ARGS
)
933 struct mdoc_arg
*arg
;
934 struct roff_node
*blk
; /* Our own or a broken block. */
935 struct roff_node
*head
; /* Our own head. */
936 struct roff_node
*body
; /* Our own body. */
938 enum margserr ac
, lac
;
941 nl
= MDOC_NEWLINE
& mdoc
->flags
;
943 if (buf
[*pos
] == '\0' && (tok
== MDOC_Sh
|| tok
== MDOC_Ss
)) {
944 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
945 line
, ppos
, roff_name
[tok
]);
949 if ( ! (mdoc_macros
[tok
].flags
& MDOC_EXPLICIT
)) {
951 /* Here, tok is one of Sh Ss Nm Nd It. */
954 for (n
= mdoc
->last
; n
!= NULL
; n
= n
->parent
) {
955 if (n
->flags
& NODE_ENDED
) {
956 if ( ! (n
->flags
& NODE_VALID
))
957 n
->flags
|= NODE_BROKEN
;
960 if (n
->type
!= ROFFT_BLOCK
)
963 if (tok
== MDOC_It
&& n
->tok
== MDOC_Bl
) {
965 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
966 mdoc
->parse
, line
, ppos
,
968 roff_name
[blk
->tok
]);
969 rew_pending(mdoc
, blk
);
974 if (mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
) {
978 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
979 mdoc
->parse
, line
, ppos
,
980 "%s breaks %s", roff_name
[tok
],
982 rew_pending(mdoc
, n
);
986 /* Delay in case it's astray. */
995 /* Here, n is one of Sh Ss Nm Nd It. */
997 if (tok
!= MDOC_Sh
&& (n
->tok
== MDOC_Sh
||
998 (tok
!= MDOC_Ss
&& (n
->tok
== MDOC_Ss
||
999 (tok
!= MDOC_It
&& n
->tok
== MDOC_It
)))))
1002 /* Item breaking an explicit block. */
1005 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
1006 mdoc
->parse
, line
, ppos
,
1007 "It breaks %s", roff_name
[blk
->tok
]);
1008 rew_pending(mdoc
, blk
);
1012 /* Close out prior implicit scopes. */
1014 rew_pending(mdoc
, n
);
1017 /* Skip items outside lists. */
1019 if (tok
== MDOC_It
&& (n
== NULL
|| n
->tok
!= MDOC_Bl
)) {
1020 mandoc_vmsg(MANDOCERR_IT_STRAY
, mdoc
->parse
,
1021 line
, ppos
, "It %s", buf
+ *pos
);
1022 roff_elem_alloc(mdoc
, line
, ppos
, ROFF_br
);
1023 rew_elem(mdoc
, ROFF_br
);
1029 * This routine accommodates implicitly- and explicitly-scoped
1030 * macro openings. Implicit ones first close out prior scope
1031 * (seen above). Delay opening the head until necessary to
1032 * allow leading punctuation to print. Special consideration
1033 * for `It -column', which has phrase-part syntax instead of
1034 * regular child nodes.
1037 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1038 blk
= mdoc_block_alloc(mdoc
, line
, ppos
, tok
, arg
);
1042 * Exception: Heads of `It' macros in `-diag' lists are not
1043 * parsed, even though `It' macros in general are parsed.
1046 parsed
= tok
!= MDOC_It
||
1047 mdoc
->last
->parent
->tok
!= MDOC_Bl
||
1048 mdoc
->last
->parent
->norm
->Bl
.type
!= LIST_diag
;
1051 * The `Nd' macro has all arguments in its body: it's a hybrid
1052 * of block partial-explicit and full-implicit. Stupid.
1055 if (tok
== MDOC_Nd
) {
1056 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1057 rew_last(mdoc
, head
);
1058 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1062 mdoc
->flags
|= MDOC_KEEP
;
1068 * If we are right after a tab character,
1069 * do not parse the first word for macros.
1072 if (mdoc
->flags
& MDOC_PHRASEQN
) {
1073 mdoc
->flags
&= ~MDOC_PHRASEQN
;
1074 mdoc
->flags
|= MDOC_PHRASEQF
;
1079 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1080 if (ac
== ARGS_EOLN
) {
1081 if (lac
!= ARGS_PHRASE
||
1082 ! (mdoc
->flags
& MDOC_PHRASEQF
))
1086 * This line ends in a tab; start the next
1087 * column now, with a leading blank.
1091 rew_last(mdoc
, body
);
1092 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1093 roff_word_alloc(mdoc
, line
, ppos
, "\\&");
1097 if (tok
== MDOC_Bd
|| tok
== MDOC_Bk
) {
1098 mandoc_vmsg(MANDOCERR_ARG_EXCESS
,
1099 mdoc
->parse
, line
, la
, "%s ... %s",
1100 roff_name
[tok
], buf
+ la
);
1103 if (tok
== MDOC_Rs
) {
1104 mandoc_vmsg(MANDOCERR_ARG_SKIP
, mdoc
->parse
,
1105 line
, la
, "Rs %s", buf
+ la
);
1108 if (ac
== ARGS_PUNCT
)
1112 * Emit leading punctuation (i.e., punctuation before
1113 * the ROFFT_HEAD) for non-phrase types.
1117 ac
!= ARGS_PHRASE
&&
1119 mdoc_isdelim(p
) == DELIM_OPEN
) {
1120 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1124 /* Open a head if one hasn't been opened. */
1127 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1129 if (ac
== ARGS_PHRASE
) {
1132 * If we haven't opened a body yet, rewind the
1133 * head; if we have, rewind that instead.
1136 rew_last(mdoc
, body
== NULL
? head
: body
);
1137 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1139 /* Process to the tab or to the end of the line. */
1141 mdoc
->flags
|= MDOC_PHRASE
;
1142 parse_rest(mdoc
, TOKEN_NONE
, line
, &la
, buf
);
1143 mdoc
->flags
&= ~MDOC_PHRASE
;
1145 /* There may have been `Ta' macros. */
1147 while (body
->next
!= NULL
)
1152 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, parsed
))
1156 if (blk
->flags
& NODE_VALID
)
1159 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1160 if (nl
&& tok
!= MDOC_Bd
&& tok
!= MDOC_Bl
&& tok
!= MDOC_Rs
)
1161 append_delims(mdoc
, line
, pos
, buf
);
1164 if (find_pending(mdoc
, tok
, line
, ppos
, head
))
1167 /* Close out scopes to remain in a consistent state. */
1169 rew_last(mdoc
, head
);
1170 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1172 if (mdoc
->flags
& MDOC_FREECOL
) {
1173 rew_last(mdoc
, body
);
1174 rew_last(mdoc
, blk
);
1175 mdoc
->flags
&= ~MDOC_FREECOL
;
1180 blk_part_imp(MACRO_PROT_ARGS
)
1185 struct roff_node
*blk
; /* saved block context */
1186 struct roff_node
*body
; /* saved body context */
1187 struct roff_node
*n
;
1189 nl
= MDOC_NEWLINE
& mdoc
->flags
;
1192 * A macro that spans to the end of the line. This is generally
1193 * (but not necessarily) called as the first macro. The block
1194 * has a head as the immediate child, which is always empty,
1195 * followed by zero or more opening punctuation nodes, then the
1196 * body (which may be empty, depending on the macro), then zero
1197 * or more closing punctuation nodes.
1200 blk
= mdoc_block_alloc(mdoc
, line
, ppos
, tok
, NULL
);
1201 rew_last(mdoc
, roff_head_alloc(mdoc
, line
, ppos
, tok
));
1204 * Open the body scope "on-demand", that is, after we've
1205 * processed all our the leading delimiters (open parenthesis,
1209 for (body
= NULL
; ; ) {
1211 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1212 if (ac
== ARGS_EOLN
|| ac
== ARGS_PUNCT
)
1215 if (body
== NULL
&& ac
!= ARGS_QWORD
&&
1216 mdoc_isdelim(p
) == DELIM_OPEN
) {
1217 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1222 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1224 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1228 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1230 if (find_pending(mdoc
, tok
, line
, ppos
, body
))
1233 rew_last(mdoc
, body
);
1235 append_delims(mdoc
, line
, pos
, buf
);
1236 rew_pending(mdoc
, blk
);
1238 /* Move trailing .Ns out of scope. */
1240 for (n
= body
->child
; n
&& n
->next
; n
= n
->next
)
1242 if (n
&& n
->tok
== MDOC_Ns
)
1243 mdoc_node_relink(mdoc
, n
);
1247 blk_part_exp(MACRO_PROT_ARGS
)
1251 struct roff_node
*head
; /* keep track of head */
1254 nl
= MDOC_NEWLINE
& mdoc
->flags
;
1257 * The opening of an explicit macro having zero or more leading
1258 * punctuation nodes; a head with optional single element (the
1259 * case of `Eo'); and a body that may be empty.
1262 roff_block_alloc(mdoc
, line
, ppos
, tok
);
1266 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1267 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
)
1270 /* Flush out leading punctuation. */
1272 if (head
== NULL
&& ac
!= ARGS_QWORD
&&
1273 mdoc_isdelim(p
) == DELIM_OPEN
) {
1274 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1279 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1280 if (tok
== MDOC_Eo
) /* Not parsed. */
1281 dword(mdoc
, line
, la
, p
, DELIM_MAX
, 0);
1282 rew_last(mdoc
, head
);
1283 roff_body_alloc(mdoc
, line
, ppos
, tok
);
1288 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1292 /* Clean-up to leave in a consistent state. */
1295 rew_last(mdoc
, roff_head_alloc(mdoc
, line
, ppos
, tok
));
1296 roff_body_alloc(mdoc
, line
, ppos
, tok
);
1299 append_delims(mdoc
, line
, pos
, buf
);
1303 in_line_argn(MACRO_PROT_ARGS
)
1305 struct mdoc_arg
*arg
;
1309 int state
; /* arg#; -1: not yet open; -2: closed */
1310 int la
, maxargs
, nl
;
1312 nl
= mdoc
->flags
& MDOC_NEWLINE
;
1315 * A line macro that has a fixed number of arguments (maxargs).
1316 * Only open the scope once the first non-leading-punctuation is
1317 * found (unless MDOC_IGNDELIM is noted, like in `Pf'), then
1318 * keep it open until the maximum number of arguments are
1338 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1344 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1346 if (ac
== ARGS_WORD
&& state
== -1 &&
1347 ! (mdoc_macros
[tok
].flags
& MDOC_IGNDELIM
) &&
1348 mdoc_isdelim(p
) == DELIM_OPEN
) {
1349 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1353 if (state
== -1 && tok
!= MDOC_In
&&
1354 tok
!= MDOC_St
&& tok
!= MDOC_Xr
) {
1355 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1359 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
) {
1360 if (abs(state
) < 2 && tok
== MDOC_Pf
)
1361 mandoc_vmsg(MANDOCERR_PF_SKIP
,
1362 mdoc
->parse
, line
, ppos
, "Pf %s",
1363 p
== NULL
? "at eol" : p
);
1367 if (state
== maxargs
) {
1368 rew_elem(mdoc
, tok
);
1372 ntok
= (ac
== ARGS_QWORD
|| (tok
== MDOC_Pf
&& state
== 0)) ?
1373 TOKEN_NONE
: lookup(mdoc
, tok
, line
, la
, p
);
1375 if (ntok
!= TOKEN_NONE
) {
1377 rew_elem(mdoc
, tok
);
1380 mdoc_macro(mdoc
, ntok
, line
, la
, pos
, buf
);
1384 if (ac
== ARGS_QWORD
||
1385 mdoc_macros
[tok
].flags
& MDOC_IGNDELIM
||
1386 mdoc_isdelim(p
) == DELIM_NONE
) {
1388 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1390 } else if (state
>= 0)
1392 } else if (state
>= 0) {
1393 rew_elem(mdoc
, tok
);
1397 dword(mdoc
, line
, la
, p
, DELIM_MAX
,
1398 mdoc_macros
[tok
].flags
& MDOC_JOIN
);
1402 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
1403 line
, ppos
, roff_name
[tok
]);
1407 if (state
== 0 && tok
== MDOC_Pf
)
1408 append_delims(mdoc
, line
, pos
, buf
);
1410 rew_elem(mdoc
, tok
);
1412 append_delims(mdoc
, line
, pos
, buf
);
1416 in_line_eoln(MACRO_PROT_ARGS
)
1418 struct roff_node
*n
;
1419 struct mdoc_arg
*arg
;
1421 if ((tok
== MDOC_Pp
|| tok
== MDOC_Lp
) &&
1422 ! (mdoc
->flags
& MDOC_SYNOPSIS
)) {
1424 if (mdoc
->next
== ROFF_NEXT_SIBLING
)
1426 if (n
->tok
== MDOC_Nm
)
1427 rew_last(mdoc
, n
->parent
);
1430 if (buf
[*pos
] == '\0' &&
1431 (tok
== MDOC_Fd
|| *roff_name
[tok
] == '%')) {
1432 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
1433 line
, ppos
, roff_name
[tok
]);
1437 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1438 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1439 if (parse_rest(mdoc
, tok
, line
, pos
, buf
))
1441 rew_elem(mdoc
, tok
);
1445 * The simplest argument parser available: Parse the remaining
1446 * words until the end of the phrase or line and return 0
1447 * or until the next macro, call that macro, and return 1.
1450 parse_rest(struct roff_man
*mdoc
, enum roff_tok tok
,
1451 int line
, int *pos
, char *buf
)
1457 if (mdoc_args(mdoc
, line
, pos
, buf
, tok
, NULL
) == ARGS_EOLN
)
1459 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1465 ctx_synopsis(MACRO_PROT_ARGS
)
1468 if (~mdoc
->flags
& (MDOC_SYNOPSIS
| MDOC_NEWLINE
))
1469 in_line(mdoc
, tok
, line
, ppos
, pos
, buf
);
1470 else if (tok
== MDOC_Nm
)
1471 blk_full(mdoc
, tok
, line
, ppos
, pos
, buf
);
1473 assert(tok
== MDOC_Vt
);
1474 blk_part_imp(mdoc
, tok
, line
, ppos
, pos
, buf
);
1479 * Phrases occur within `Bl -column' entries, separated by `Ta' or tabs.
1480 * They're unusual because they're basically free-form text until a
1481 * macro is encountered.
1484 phrase_ta(MACRO_PROT_ARGS
)
1486 struct roff_node
*body
, *n
;
1488 /* Make sure we are in a column list or ignore this macro. */
1491 for (n
= mdoc
->last
; n
!= NULL
; n
= n
->parent
) {
1492 if (n
->flags
& NODE_ENDED
)
1494 if (n
->tok
== MDOC_It
&& n
->type
== ROFFT_BODY
)
1496 if (n
->tok
== MDOC_Bl
&& n
->end
== ENDBODY_NOT
)
1500 if (n
== NULL
|| n
->norm
->Bl
.type
!= LIST_column
) {
1501 mandoc_msg(MANDOCERR_TA_STRAY
, mdoc
->parse
,
1506 /* Advance to the next column. */
1508 rew_last(mdoc
, body
);
1509 roff_body_alloc(mdoc
, line
, ppos
, MDOC_It
);
1510 parse_rest(mdoc
, TOKEN_NONE
, line
, pos
, buf
);