]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_macro.c
1 /* $Id: mdoc_macro.c,v 1.211 2017/02/10 16:20:34 schwarze Exp $ */
3 * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2010, 2012-2016 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
*, int, int, int,
51 static int lookup(struct roff_man
*, int, int, int, const char *);
52 static int macro_or_word(MACRO_PROT_ARGS
, int);
53 static int parse_rest(struct roff_man
*, int, int, int *, char *);
54 static int rew_alt(int);
55 static void rew_elem(struct roff_man
*, int);
56 static void rew_last(struct roff_man
*, const struct roff_node
*);
57 static void rew_pending(struct roff_man
*,
58 const struct roff_node
*);
60 const struct mdoc_macro __mdoc_macros
[MDOC_MAX
] = {
61 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ap */
62 { in_line_eoln
, MDOC_PROLOGUE
}, /* Dd */
63 { in_line_eoln
, MDOC_PROLOGUE
}, /* Dt */
64 { in_line_eoln
, MDOC_PROLOGUE
}, /* Os */
65 { blk_full
, MDOC_PARSED
| MDOC_JOIN
}, /* Sh */
66 { blk_full
, MDOC_PARSED
| MDOC_JOIN
}, /* Ss */
67 { in_line_eoln
, 0 }, /* Pp */
68 { blk_part_imp
, MDOC_PARSED
| MDOC_JOIN
}, /* D1 */
69 { blk_part_imp
, MDOC_PARSED
| MDOC_JOIN
}, /* Dl */
70 { blk_full
, MDOC_EXPLICIT
}, /* Bd */
71 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ed */
72 { blk_full
, MDOC_EXPLICIT
}, /* Bl */
73 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* El */
74 { blk_full
, MDOC_PARSED
| MDOC_JOIN
}, /* It */
75 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ad */
76 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* An */
77 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ar */
78 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Cd */
79 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Cm */
80 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dv */
81 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Er */
82 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ev */
83 { in_line_eoln
, 0 }, /* Ex */
84 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fa */
85 { in_line_eoln
, 0 }, /* Fd */
86 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fl */
87 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fn */
88 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ft */
89 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ic */
90 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* In */
91 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Li */
92 { blk_full
, MDOC_JOIN
}, /* Nd */
93 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nm */
94 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Op */
95 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ot */
96 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Pa */
97 { in_line_eoln
, 0 }, /* Rv */
98 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* St */
99 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Va */
100 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Vt */
101 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Xr */
102 { in_line_eoln
, MDOC_JOIN
}, /* %A */
103 { in_line_eoln
, MDOC_JOIN
}, /* %B */
104 { in_line_eoln
, MDOC_JOIN
}, /* %D */
105 { in_line_eoln
, MDOC_JOIN
}, /* %I */
106 { in_line_eoln
, MDOC_JOIN
}, /* %J */
107 { in_line_eoln
, 0 }, /* %N */
108 { in_line_eoln
, MDOC_JOIN
}, /* %O */
109 { in_line_eoln
, 0 }, /* %P */
110 { in_line_eoln
, MDOC_JOIN
}, /* %R */
111 { in_line_eoln
, MDOC_JOIN
}, /* %T */
112 { in_line_eoln
, 0 }, /* %V */
113 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
114 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ac */
115 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
116 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ao */
117 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Aq */
118 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* At */
119 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
120 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bc */
121 { blk_full
, MDOC_EXPLICIT
}, /* Bf */
122 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
123 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bo */
124 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Bq */
125 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bsx */
126 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bx */
127 { in_line_eoln
, 0 }, /* Db */
128 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
129 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Dc */
130 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
131 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Do */
132 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Dq */
133 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Ec */
134 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ef */
135 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Em */
136 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Eo */
137 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fx */
138 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ms */
139 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* No */
140 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
|
141 MDOC_IGNDELIM
| MDOC_JOIN
}, /* Ns */
142 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nx */
143 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ox */
144 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
145 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Pc */
146 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_IGNDELIM
}, /* Pf */
147 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
148 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Po */
149 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Pq */
150 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
151 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Qc */
152 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ql */
153 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
154 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Qo */
155 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Qq */
156 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Re */
157 { blk_full
, MDOC_EXPLICIT
}, /* Rs */
158 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
159 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Sc */
160 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
161 MDOC_EXPLICIT
| MDOC_JOIN
}, /* So */
162 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sq */
163 { in_line_argn
, 0 }, /* Sm */
164 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sx */
165 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sy */
166 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Tn */
167 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ux */
168 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Xc */
169 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Xo */
170 { blk_full
, MDOC_EXPLICIT
| MDOC_CALLABLE
}, /* Fo */
171 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
172 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Fc */
173 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
174 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Oo */
175 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
176 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Oc */
177 { blk_full
, MDOC_EXPLICIT
}, /* Bk */
178 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ek */
179 { in_line_eoln
, 0 }, /* Bt */
180 { in_line_eoln
, 0 }, /* Hf */
181 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fr */
182 { in_line_eoln
, 0 }, /* Ud */
183 { in_line
, 0 }, /* Lb */
184 { in_line_eoln
, 0 }, /* Lp */
185 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Lk */
186 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Mt */
187 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Brq */
188 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
189 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bro */
190 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
191 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Brc */
192 { in_line_eoln
, MDOC_JOIN
}, /* %C */
193 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Es */
194 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* En */
195 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dx */
196 { in_line_eoln
, MDOC_JOIN
}, /* %Q */
197 { in_line_eoln
, 0 }, /* br */
198 { in_line_eoln
, 0 }, /* sp */
199 { in_line_eoln
, 0 }, /* %U */
200 { phrase_ta
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ta */
201 { in_line_eoln
, MDOC_PROLOGUE
}, /* ll */
204 const struct mdoc_macro
* const mdoc_macros
= __mdoc_macros
;
208 * This is called at the end of parsing. It must traverse up the tree,
209 * closing out open [implicit] scopes. Obviously, open explicit scopes
213 mdoc_endparse(struct roff_man
*mdoc
)
217 /* Scan for open explicit scopes. */
219 n
= mdoc
->last
->flags
& NODE_VALID
?
220 mdoc
->last
->parent
: mdoc
->last
;
222 for ( ; n
; n
= n
->parent
)
223 if (n
->type
== ROFFT_BLOCK
&&
224 mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
)
225 mandoc_msg(MANDOCERR_BLK_NOEND
, mdoc
->parse
,
226 n
->line
, n
->pos
, mdoc_macronames
[n
->tok
]);
228 /* Rewind to the first. */
230 rew_last(mdoc
, mdoc
->first
);
231 mdoc_state_reset(mdoc
);
235 * Look up the macro at *p called by "from",
236 * or as a line macro if from == TOKEN_NONE.
239 lookup(struct roff_man
*mdoc
, int from
, int line
, int ppos
, const char *p
)
243 if (mdoc
->flags
& MDOC_PHRASEQF
) {
244 mdoc
->flags
&= ~MDOC_PHRASEQF
;
247 if (from
== TOKEN_NONE
|| mdoc_macros
[from
].flags
& MDOC_PARSED
) {
248 res
= mdoc_hash_find(p
);
249 if (res
!= TOKEN_NONE
) {
250 if (mdoc_macros
[res
].flags
& MDOC_CALLABLE
)
252 if (res
!= MDOC_br
&& res
!= MDOC_sp
&& res
!= MDOC_ll
)
253 mandoc_msg(MANDOCERR_MACRO_CALL
,
254 mdoc
->parse
, line
, ppos
, p
);
261 * Rewind up to and including a specific node.
264 rew_last(struct roff_man
*mdoc
, const struct roff_node
*to
)
267 if (to
->flags
& NODE_VALID
)
270 while (mdoc
->last
!= to
) {
271 mdoc_state(mdoc
, mdoc
->last
);
272 mdoc
->last
->flags
|= NODE_VALID
| NODE_ENDED
;
273 mdoc
->last
= mdoc
->last
->parent
;
275 mdoc_state(mdoc
, mdoc
->last
);
276 mdoc
->last
->flags
|= NODE_VALID
| NODE_ENDED
;
277 mdoc
->next
= ROFF_NEXT_SIBLING
;
281 * Rewind up to a specific block, including all blocks that broke it.
284 rew_pending(struct roff_man
*mdoc
, const struct roff_node
*n
)
290 if (mdoc
->last
== n
) {
293 roff_body_alloc(mdoc
, n
->line
, n
->pos
,
301 if ( ! (n
->flags
& NODE_BROKEN
))
307 if ((n
= n
->parent
) == NULL
)
310 if (n
->type
== ROFFT_BLOCK
||
311 n
->type
== ROFFT_HEAD
) {
312 if (n
->flags
& NODE_ENDED
)
322 * For a block closing macro, return the corresponding opening one.
323 * Otherwise, return the macro itself.
367 rew_elem(struct roff_man
*mdoc
, int tok
)
372 if (n
->type
!= ROFFT_ELEM
)
374 assert(n
->type
== ROFFT_ELEM
);
375 assert(tok
== n
->tok
);
380 * If there is an open sub-block of the target requiring
381 * explicit close-out, postpone closing out the target until
382 * the rew_pending() call closing out the sub-block.
385 find_pending(struct roff_man
*mdoc
, int tok
, int line
, int ppos
,
386 struct roff_node
*target
)
392 for (n
= mdoc
->last
; n
!= NULL
&& n
!= target
; n
= n
->parent
) {
393 if (n
->flags
& NODE_ENDED
) {
394 if ( ! (n
->flags
& NODE_VALID
))
395 n
->flags
|= NODE_BROKEN
;
398 if (n
->type
== ROFFT_BLOCK
&&
399 mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
) {
401 n
->flags
= NODE_BROKEN
;
402 if (target
->type
== ROFFT_HEAD
)
403 target
->flags
= NODE_ENDED
;
404 else if ( ! (target
->flags
& NODE_ENDED
)) {
405 mandoc_vmsg(MANDOCERR_BLK_NEST
,
406 mdoc
->parse
, line
, ppos
,
407 "%s breaks %s", mdoc_macronames
[tok
],
408 mdoc_macronames
[n
->tok
]);
409 mdoc_endbody_alloc(mdoc
, line
, ppos
,
410 tok
, target
, ENDBODY_NOSPACE
);
418 * Allocate a word and check whether it's punctuation or not.
419 * Punctuation consists of those tokens found in mdoc_isdelim().
422 dword(struct roff_man
*mdoc
, int line
, int col
, const char *p
,
423 enum mdelim d
, int may_append
)
430 ! (mdoc
->flags
& (MDOC_SYNOPSIS
| MDOC_KEEP
| MDOC_SMOFF
)) &&
431 d
== DELIM_NONE
&& mdoc
->last
->type
== ROFFT_TEXT
&&
432 mdoc_isdelim(mdoc
->last
->string
) == DELIM_NONE
) {
433 roff_word_append(mdoc
, p
);
437 roff_word_alloc(mdoc
, line
, col
, p
);
440 * If the word consists of a bare delimiter,
441 * flag the new node accordingly,
442 * unless doing so was vetoed by the invoking macro.
443 * Always clear the veto, it is only valid for one word.
447 mdoc
->last
->flags
|= NODE_DELIMO
;
448 else if (d
== DELIM_CLOSE
&&
449 ! (mdoc
->flags
& MDOC_NODELIMC
) &&
450 mdoc
->last
->parent
->tok
!= MDOC_Fd
)
451 mdoc
->last
->flags
|= NODE_DELIMC
;
452 mdoc
->flags
&= ~MDOC_NODELIMC
;
456 append_delims(struct roff_man
*mdoc
, int line
, int *pos
, char *buf
)
461 if (buf
[*pos
] == '\0')
466 if (mdoc_args(mdoc
, line
, pos
, buf
, TOKEN_NONE
, &p
) ==
469 dword(mdoc
, line
, la
, p
, DELIM_MAX
, 1);
472 * If we encounter end-of-sentence symbols, then trigger
475 * XXX: it's easy to allow this to propagate outward to
476 * the last symbol, such that `. )' will cause the
477 * correct double-spacing. However, (1) groff isn't
478 * smart enough to do this and (2) it would require
479 * knowing which symbols break this behaviour, for
480 * example, `. ;' shouldn't propagate the double-space.
483 if (mandoc_eos(p
, strlen(p
)))
484 mdoc
->last
->flags
|= NODE_EOS
;
490 * If it is a macro, call it and return 1.
491 * Otherwise, allocate it and return 0.
494 macro_or_word(MACRO_PROT_ARGS
, int parsed
)
503 else if (parsed
&& ! (mdoc
->flags
& MDOC_PHRASELIT
))
504 ntok
= lookup(mdoc
, tok
, line
, ppos
, p
);
506 if (ntok
== TOKEN_NONE
) {
507 dword(mdoc
, line
, ppos
, p
, DELIM_MAX
, tok
== TOKEN_NONE
||
508 mdoc_macros
[tok
].flags
& MDOC_JOIN
);
511 if (mdoc_macros
[tok
].fp
== in_line_eoln
)
513 mdoc_macro(mdoc
, ntok
, line
, ppos
, pos
, buf
);
514 if (tok
== TOKEN_NONE
)
515 append_delims(mdoc
, line
, pos
, buf
);
521 * Close out block partial/full explicit.
524 blk_exp_close(MACRO_PROT_ARGS
)
526 struct roff_node
*body
; /* Our own body. */
527 struct roff_node
*endbody
; /* Our own end marker. */
528 struct roff_node
*itblk
; /* An It block starting later. */
529 struct roff_node
*later
; /* A sub-block starting later. */
530 struct roff_node
*n
; /* Search back to our block. */
531 struct roff_node
*target
; /* For find_pending(). */
533 int j
, lastarg
, maxargs
, nl
, pending
;
538 nl
= MDOC_NEWLINE
& mdoc
->flags
;
545 mdoc
->flags
&= ~MDOC_KEEP
;
552 /* Search backwards for the beginning of our own body. */
556 for (n
= mdoc
->last
; n
; n
= n
->parent
) {
557 if (n
->flags
& NODE_ENDED
|| n
->tok
!= atok
||
558 n
->type
!= ROFFT_BODY
|| n
->end
!= ENDBODY_NOT
)
565 * Search backwards for beginnings of blocks,
566 * both of our own and of pending sub-blocks.
569 endbody
= itblk
= later
= NULL
;
570 for (n
= mdoc
->last
; n
; n
= n
->parent
) {
571 if (n
->flags
& NODE_ENDED
) {
572 if ( ! (n
->flags
& NODE_VALID
))
573 n
->flags
|= NODE_BROKEN
;
578 * Mismatching end macros can never break anything
579 * and we only care about the breaking of BLOCKs.
582 if (body
== NULL
|| n
->type
!= ROFFT_BLOCK
)
586 * SYNOPSIS name blocks can not be broken themselves,
587 * but they do get broken together with a broken child.
590 if (n
->tok
== MDOC_Nm
) {
592 n
->flags
|= NODE_BROKEN
| NODE_ENDED
;
596 if (n
->tok
== MDOC_It
) {
601 if (atok
== n
->tok
) {
605 * Found the start of our own block.
606 * When there is no pending sub block,
607 * just proceed to closing out.
611 (tok
== MDOC_El
&& itblk
== NULL
))
615 * When there is a pending sub block, postpone
616 * closing out the current block until the
617 * rew_pending() closing out the sub-block.
618 * Mark the place where the formatting - but not
619 * the scope - of the current block ends.
622 mandoc_vmsg(MANDOCERR_BLK_NEST
, mdoc
->parse
,
623 line
, ppos
, "%s breaks %s",
624 mdoc_macronames
[atok
],
625 mdoc_macronames
[later
->tok
]);
627 endbody
= mdoc_endbody_alloc(mdoc
, line
, ppos
,
628 atok
, body
, ENDBODY_SPACE
);
631 itblk
->flags
|= NODE_ENDED
| NODE_BROKEN
;
634 * If a block closing macro taking arguments
635 * breaks another block, put the arguments
636 * into the end marker.
640 mdoc
->next
= ROFF_NEXT_CHILD
;
644 /* Explicit blocks close out description lines. */
646 if (n
->tok
== MDOC_Nd
) {
651 /* Breaking an open sub block. */
653 n
->flags
|= NODE_BROKEN
;
659 mandoc_msg(MANDOCERR_BLK_NOTOPEN
, mdoc
->parse
,
660 line
, ppos
, mdoc_macronames
[tok
]);
661 if (maxargs
&& endbody
== NULL
) {
663 * Stray .Ec without previous .Eo:
664 * Break the output line, keep the arguments.
666 roff_elem_alloc(mdoc
, line
, ppos
, MDOC_br
);
667 rew_elem(mdoc
, MDOC_br
);
669 } else if (endbody
== NULL
) {
670 rew_last(mdoc
, body
);
672 mdoc_tail_alloc(mdoc
, line
, ppos
, atok
);
675 if ( ! (mdoc_macros
[tok
].flags
& MDOC_PARSED
)) {
676 if (buf
[*pos
] != '\0')
677 mandoc_vmsg(MANDOCERR_ARG_SKIP
,
678 mdoc
->parse
, line
, ppos
,
679 "%s %s", mdoc_macronames
[tok
],
681 if (endbody
== NULL
&& n
!= NULL
)
682 rew_pending(mdoc
, n
);
693 if (j
== maxargs
&& n
!= NULL
)
696 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
697 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
)
700 ntok
= ac
== ARGS_QWORD
? TOKEN_NONE
:
701 lookup(mdoc
, tok
, line
, lastarg
, p
);
703 if (ntok
== TOKEN_NONE
) {
704 dword(mdoc
, line
, lastarg
, p
, DELIM_MAX
,
705 MDOC_JOIN
& mdoc_macros
[tok
].flags
);
711 mdoc
->flags
&= ~MDOC_NEWLINE
;
712 mdoc_macro(mdoc
, ntok
, line
, lastarg
, pos
, buf
);
717 if (ntok
!= TOKEN_NONE
&& n
->flags
& NODE_BROKEN
) {
720 target
= target
->parent
;
721 while ( ! (target
->flags
& NODE_ENDED
));
722 pending
= find_pending(mdoc
, ntok
, line
, ppos
,
727 rew_pending(mdoc
, n
);
730 append_delims(mdoc
, line
, pos
, buf
);
734 in_line(MACRO_PROT_ARGS
)
736 int la
, scope
, cnt
, firstarg
, mayopen
, nc
, nl
;
740 struct mdoc_arg
*arg
;
743 nl
= MDOC_NEWLINE
& mdoc
->flags
;
746 * Whether we allow ignored elements (those without content,
747 * usually because of reserved words) to squeak by.
764 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
769 for (cnt
= scope
= 0;; ) {
771 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
774 * At the end of a macro line,
775 * opening delimiters do not suppress spacing.
778 if (ac
== ARGS_EOLN
) {
780 mdoc
->last
->flags
&= ~NODE_DELIMO
;
785 * The rest of the macro line is only punctuation,
786 * to be handled by append_delims().
787 * If there were no other arguments,
788 * do not allow the first one to suppress spacing,
789 * even if it turns out to be a closing one.
792 if (ac
== ARGS_PUNCT
) {
793 if (cnt
== 0 && (nc
== 0 || tok
== MDOC_An
))
794 mdoc
->flags
|= MDOC_NODELIMC
;
798 ntok
= (ac
== ARGS_QWORD
|| (tok
== MDOC_Fn
&& !cnt
)) ?
799 TOKEN_NONE
: lookup(mdoc
, tok
, line
, la
, p
);
802 * In this case, we've located a submacro and must
803 * execute it. Close out scope, if open. If no
804 * elements have been generated, either create one (nc)
805 * or raise a warning.
808 if (ntok
!= TOKEN_NONE
) {
812 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
813 rew_last(mdoc
, mdoc
->last
);
814 } else if ( ! nc
&& ! cnt
) {
816 mandoc_msg(MANDOCERR_MACRO_EMPTY
,
817 mdoc
->parse
, line
, ppos
,
818 mdoc_macronames
[tok
]);
820 mdoc_macro(mdoc
, ntok
, line
, la
, pos
, buf
);
822 append_delims(mdoc
, line
, pos
, buf
);
827 * Non-quote-enclosed punctuation. Set up our scope, if
828 * a word; rewind the scope, if a delimiter; then append
832 d
= ac
== ARGS_QWORD
? DELIM_NONE
: mdoc_isdelim(p
);
834 if (DELIM_NONE
!= d
) {
836 * If we encounter closing punctuation, no word
837 * has been emitted, no scope is open, and we're
838 * allowed to have an empty element, then start
841 if ((d
== DELIM_CLOSE
||
842 (d
== DELIM_MIDDLE
&& tok
== MDOC_Fl
)) &&
843 !cnt
&& !scope
&& nc
&& mayopen
) {
844 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
851 * Close out our scope, if one is open, before
859 } else if (mayopen
&& !scope
) {
860 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
865 dword(mdoc
, line
, la
, p
, d
,
866 MDOC_JOIN
& mdoc_macros
[tok
].flags
);
869 * If the first argument is a closing delimiter,
870 * do not suppress spacing before it.
873 if (firstarg
&& d
== DELIM_CLOSE
&& !nc
)
874 mdoc
->last
->flags
&= ~NODE_DELIMC
;
878 * `Fl' macros have their scope re-opened with each new
879 * word so that the `-' can be added to each one without
880 * having to parse out spaces.
882 if (scope
&& tok
== MDOC_Fl
) {
892 * If no elements have been collected and we're allowed to have
893 * empties (nc), open a scope and close it out. Otherwise,
899 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
900 rew_last(mdoc
, mdoc
->last
);
903 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
904 line
, ppos
, mdoc_macronames
[tok
]);
908 append_delims(mdoc
, line
, pos
, buf
);
912 blk_full(MACRO_PROT_ARGS
)
915 struct mdoc_arg
*arg
;
916 struct roff_node
*blk
; /* Our own or a broken block. */
917 struct roff_node
*head
; /* Our own head. */
918 struct roff_node
*body
; /* Our own body. */
920 enum margserr ac
, lac
;
923 nl
= MDOC_NEWLINE
& mdoc
->flags
;
925 if (buf
[*pos
] == '\0' && (tok
== MDOC_Sh
|| tok
== MDOC_Ss
)) {
926 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
927 line
, ppos
, mdoc_macronames
[tok
]);
931 if ( ! (mdoc_macros
[tok
].flags
& MDOC_EXPLICIT
)) {
933 /* Here, tok is one of Sh Ss Nm Nd It. */
936 for (n
= mdoc
->last
; n
!= NULL
; n
= n
->parent
) {
937 if (n
->flags
& NODE_ENDED
) {
938 if ( ! (n
->flags
& NODE_VALID
))
939 n
->flags
|= NODE_BROKEN
;
942 if (n
->type
!= ROFFT_BLOCK
)
945 if (tok
== MDOC_It
&& n
->tok
== MDOC_Bl
) {
947 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
948 mdoc
->parse
, line
, ppos
,
950 mdoc_macronames
[blk
->tok
]);
951 rew_pending(mdoc
, blk
);
956 if (mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
) {
960 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
961 mdoc
->parse
, line
, ppos
,
963 mdoc_macronames
[tok
],
964 mdoc_macronames
[n
->tok
]);
965 rew_pending(mdoc
, n
);
969 /* Delay in case it's astray. */
978 /* Here, n is one of Sh Ss Nm Nd It. */
980 if (tok
!= MDOC_Sh
&& (n
->tok
== MDOC_Sh
||
981 (tok
!= MDOC_Ss
&& (n
->tok
== MDOC_Ss
||
982 (tok
!= MDOC_It
&& n
->tok
== MDOC_It
)))))
985 /* Item breaking an explicit block. */
988 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
989 mdoc
->parse
, line
, ppos
,
991 mdoc_macronames
[blk
->tok
]);
992 rew_pending(mdoc
, blk
);
996 /* Close out prior implicit scopes. */
998 rew_pending(mdoc
, n
);
1001 /* Skip items outside lists. */
1003 if (tok
== MDOC_It
&& (n
== NULL
|| n
->tok
!= MDOC_Bl
)) {
1004 mandoc_vmsg(MANDOCERR_IT_STRAY
, mdoc
->parse
,
1005 line
, ppos
, "It %s", buf
+ *pos
);
1006 roff_elem_alloc(mdoc
, line
, ppos
, MDOC_br
);
1007 rew_elem(mdoc
, MDOC_br
);
1013 * This routine accommodates implicitly- and explicitly-scoped
1014 * macro openings. Implicit ones first close out prior scope
1015 * (seen above). Delay opening the head until necessary to
1016 * allow leading punctuation to print. Special consideration
1017 * for `It -column', which has phrase-part syntax instead of
1018 * regular child nodes.
1021 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1022 blk
= mdoc_block_alloc(mdoc
, line
, ppos
, tok
, arg
);
1026 * Exception: Heads of `It' macros in `-diag' lists are not
1027 * parsed, even though `It' macros in general are parsed.
1030 parsed
= tok
!= MDOC_It
||
1031 mdoc
->last
->parent
->tok
!= MDOC_Bl
||
1032 mdoc
->last
->parent
->norm
->Bl
.type
!= LIST_diag
;
1035 * The `Nd' macro has all arguments in its body: it's a hybrid
1036 * of block partial-explicit and full-implicit. Stupid.
1039 if (tok
== MDOC_Nd
) {
1040 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1041 rew_last(mdoc
, head
);
1042 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1046 mdoc
->flags
|= MDOC_KEEP
;
1052 * If we are right after a tab character,
1053 * do not parse the first word for macros.
1056 if (mdoc
->flags
& MDOC_PHRASEQN
) {
1057 mdoc
->flags
&= ~MDOC_PHRASEQN
;
1058 mdoc
->flags
|= MDOC_PHRASEQF
;
1063 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1064 if (ac
== ARGS_EOLN
) {
1065 if (lac
!= ARGS_PHRASE
||
1066 ! (mdoc
->flags
& MDOC_PHRASEQF
))
1070 * This line ends in a tab; start the next
1071 * column now, with a leading blank.
1075 rew_last(mdoc
, body
);
1076 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1077 roff_word_alloc(mdoc
, line
, ppos
, "\\&");
1081 if (tok
== MDOC_Bd
|| tok
== MDOC_Bk
) {
1082 mandoc_vmsg(MANDOCERR_ARG_EXCESS
,
1083 mdoc
->parse
, line
, la
, "%s ... %s",
1084 mdoc_macronames
[tok
], buf
+ la
);
1087 if (tok
== MDOC_Rs
) {
1088 mandoc_vmsg(MANDOCERR_ARG_SKIP
, mdoc
->parse
,
1089 line
, la
, "Rs %s", buf
+ la
);
1092 if (ac
== ARGS_PUNCT
)
1096 * Emit leading punctuation (i.e., punctuation before
1097 * the ROFFT_HEAD) for non-phrase types.
1101 ac
!= ARGS_PHRASE
&&
1103 mdoc_isdelim(p
) == DELIM_OPEN
) {
1104 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1108 /* Open a head if one hasn't been opened. */
1111 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1113 if (ac
== ARGS_PHRASE
) {
1116 * If we haven't opened a body yet, rewind the
1117 * head; if we have, rewind that instead.
1120 rew_last(mdoc
, body
== NULL
? head
: body
);
1121 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1123 /* Process to the tab or to the end of the line. */
1125 mdoc
->flags
|= MDOC_PHRASE
;
1126 parse_rest(mdoc
, TOKEN_NONE
, line
, &la
, buf
);
1127 mdoc
->flags
&= ~MDOC_PHRASE
;
1129 /* There may have been `Ta' macros. */
1131 while (body
->next
!= NULL
)
1136 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, parsed
))
1140 if (blk
->flags
& NODE_VALID
)
1143 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1144 if (nl
&& tok
!= MDOC_Bd
&& tok
!= MDOC_Bl
&& tok
!= MDOC_Rs
)
1145 append_delims(mdoc
, line
, pos
, buf
);
1148 if (find_pending(mdoc
, tok
, line
, ppos
, head
))
1151 /* Close out scopes to remain in a consistent state. */
1153 rew_last(mdoc
, head
);
1154 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1156 if (mdoc
->flags
& MDOC_FREECOL
) {
1157 rew_last(mdoc
, body
);
1158 rew_last(mdoc
, blk
);
1159 mdoc
->flags
&= ~MDOC_FREECOL
;
1164 blk_part_imp(MACRO_PROT_ARGS
)
1169 struct roff_node
*blk
; /* saved block context */
1170 struct roff_node
*body
; /* saved body context */
1171 struct roff_node
*n
;
1173 nl
= MDOC_NEWLINE
& mdoc
->flags
;
1176 * A macro that spans to the end of the line. This is generally
1177 * (but not necessarily) called as the first macro. The block
1178 * has a head as the immediate child, which is always empty,
1179 * followed by zero or more opening punctuation nodes, then the
1180 * body (which may be empty, depending on the macro), then zero
1181 * or more closing punctuation nodes.
1184 blk
= mdoc_block_alloc(mdoc
, line
, ppos
, tok
, NULL
);
1185 rew_last(mdoc
, roff_head_alloc(mdoc
, line
, ppos
, tok
));
1188 * Open the body scope "on-demand", that is, after we've
1189 * processed all our the leading delimiters (open parenthesis,
1193 for (body
= NULL
; ; ) {
1195 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1196 if (ac
== ARGS_EOLN
|| ac
== ARGS_PUNCT
)
1199 if (body
== NULL
&& ac
!= ARGS_QWORD
&&
1200 mdoc_isdelim(p
) == DELIM_OPEN
) {
1201 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1206 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1208 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1212 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1214 if (find_pending(mdoc
, tok
, line
, ppos
, body
))
1217 rew_last(mdoc
, body
);
1219 append_delims(mdoc
, line
, pos
, buf
);
1220 rew_pending(mdoc
, blk
);
1222 /* Move trailing .Ns out of scope. */
1224 for (n
= body
->child
; n
&& n
->next
; n
= n
->next
)
1226 if (n
&& n
->tok
== MDOC_Ns
)
1227 mdoc_node_relink(mdoc
, n
);
1231 blk_part_exp(MACRO_PROT_ARGS
)
1235 struct roff_node
*head
; /* keep track of head */
1238 nl
= MDOC_NEWLINE
& mdoc
->flags
;
1241 * The opening of an explicit macro having zero or more leading
1242 * punctuation nodes; a head with optional single element (the
1243 * case of `Eo'); and a body that may be empty.
1246 roff_block_alloc(mdoc
, line
, ppos
, tok
);
1250 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1251 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
)
1254 /* Flush out leading punctuation. */
1256 if (head
== NULL
&& ac
!= ARGS_QWORD
&&
1257 mdoc_isdelim(p
) == DELIM_OPEN
) {
1258 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1263 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1264 if (tok
== MDOC_Eo
) /* Not parsed. */
1265 dword(mdoc
, line
, la
, p
, DELIM_MAX
, 0);
1266 rew_last(mdoc
, head
);
1267 roff_body_alloc(mdoc
, line
, ppos
, tok
);
1272 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1276 /* Clean-up to leave in a consistent state. */
1279 rew_last(mdoc
, roff_head_alloc(mdoc
, line
, ppos
, tok
));
1280 roff_body_alloc(mdoc
, line
, ppos
, tok
);
1283 append_delims(mdoc
, line
, pos
, buf
);
1287 in_line_argn(MACRO_PROT_ARGS
)
1289 struct mdoc_arg
*arg
;
1293 int state
; /* arg#; -1: not yet open; -2: closed */
1294 int la
, maxargs
, nl
;
1296 nl
= mdoc
->flags
& MDOC_NEWLINE
;
1299 * A line macro that has a fixed number of arguments (maxargs).
1300 * Only open the scope once the first non-leading-punctuation is
1301 * found (unless MDOC_IGNDELIM is noted, like in `Pf'), then
1302 * keep it open until the maximum number of arguments are
1322 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1328 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1330 if (ac
== ARGS_WORD
&& state
== -1 &&
1331 ! (mdoc_macros
[tok
].flags
& MDOC_IGNDELIM
) &&
1332 mdoc_isdelim(p
) == DELIM_OPEN
) {
1333 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1337 if (state
== -1 && tok
!= MDOC_In
&&
1338 tok
!= MDOC_St
&& tok
!= MDOC_Xr
) {
1339 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1343 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
) {
1344 if (abs(state
) < 2 && tok
== MDOC_Pf
)
1345 mandoc_vmsg(MANDOCERR_PF_SKIP
,
1346 mdoc
->parse
, line
, ppos
, "Pf %s",
1347 p
== NULL
? "at eol" : p
);
1351 if (state
== maxargs
) {
1352 rew_elem(mdoc
, tok
);
1356 ntok
= (ac
== ARGS_QWORD
|| (tok
== MDOC_Pf
&& state
== 0)) ?
1357 TOKEN_NONE
: lookup(mdoc
, tok
, line
, la
, p
);
1359 if (ntok
!= TOKEN_NONE
) {
1361 rew_elem(mdoc
, tok
);
1364 mdoc_macro(mdoc
, ntok
, line
, la
, pos
, buf
);
1368 if (ac
== ARGS_QWORD
||
1369 mdoc_macros
[tok
].flags
& MDOC_IGNDELIM
||
1370 mdoc_isdelim(p
) == DELIM_NONE
) {
1372 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1374 } else if (state
>= 0)
1376 } else if (state
>= 0) {
1377 rew_elem(mdoc
, tok
);
1381 dword(mdoc
, line
, la
, p
, DELIM_MAX
,
1382 MDOC_JOIN
& mdoc_macros
[tok
].flags
);
1386 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
1387 line
, ppos
, mdoc_macronames
[tok
]);
1391 if (state
== 0 && tok
== MDOC_Pf
)
1392 append_delims(mdoc
, line
, pos
, buf
);
1394 rew_elem(mdoc
, tok
);
1396 append_delims(mdoc
, line
, pos
, buf
);
1400 in_line_eoln(MACRO_PROT_ARGS
)
1402 struct roff_node
*n
;
1403 struct mdoc_arg
*arg
;
1405 if ((tok
== MDOC_Pp
|| tok
== MDOC_Lp
) &&
1406 ! (mdoc
->flags
& MDOC_SYNOPSIS
)) {
1408 if (mdoc
->next
== ROFF_NEXT_SIBLING
)
1410 if (n
->tok
== MDOC_Nm
)
1411 rew_last(mdoc
, n
->parent
);
1414 if (buf
[*pos
] == '\0' &&
1415 (tok
== MDOC_Fd
|| mdoc_macronames
[tok
][0] == '%')) {
1416 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
1417 line
, ppos
, mdoc_macronames
[tok
]);
1421 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1422 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1423 if (parse_rest(mdoc
, tok
, line
, pos
, buf
))
1425 rew_elem(mdoc
, tok
);
1429 * The simplest argument parser available: Parse the remaining
1430 * words until the end of the phrase or line and return 0
1431 * or until the next macro, call that macro, and return 1.
1434 parse_rest(struct roff_man
*mdoc
, int tok
, int line
, int *pos
, char *buf
)
1440 if (mdoc_args(mdoc
, line
, pos
, buf
, tok
, NULL
) == ARGS_EOLN
)
1442 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1448 ctx_synopsis(MACRO_PROT_ARGS
)
1451 if (~mdoc
->flags
& (MDOC_SYNOPSIS
| MDOC_NEWLINE
))
1452 in_line(mdoc
, tok
, line
, ppos
, pos
, buf
);
1453 else if (tok
== MDOC_Nm
)
1454 blk_full(mdoc
, tok
, line
, ppos
, pos
, buf
);
1456 assert(tok
== MDOC_Vt
);
1457 blk_part_imp(mdoc
, tok
, line
, ppos
, pos
, buf
);
1462 * Phrases occur within `Bl -column' entries, separated by `Ta' or tabs.
1463 * They're unusual because they're basically free-form text until a
1464 * macro is encountered.
1467 phrase_ta(MACRO_PROT_ARGS
)
1469 struct roff_node
*body
, *n
;
1471 /* Make sure we are in a column list or ignore this macro. */
1474 for (n
= mdoc
->last
; n
!= NULL
; n
= n
->parent
) {
1475 if (n
->flags
& NODE_ENDED
)
1477 if (n
->tok
== MDOC_It
&& n
->type
== ROFFT_BODY
)
1479 if (n
->tok
== MDOC_Bl
&& n
->end
== ENDBODY_NOT
)
1483 if (n
== NULL
|| n
->norm
->Bl
.type
!= LIST_column
) {
1484 mandoc_msg(MANDOCERR_TA_STRAY
, mdoc
->parse
,
1489 /* Advance to the next column. */
1491 rew_last(mdoc
, body
);
1492 roff_body_alloc(mdoc
, line
, ppos
, MDOC_It
);
1493 parse_rest(mdoc
, TOKEN_NONE
, line
, pos
, buf
);