]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_macro.c
1 /* $Id: mdoc_macro.c,v 1.188 2015/04/05 23:04:41 schwarze Exp $ */
3 * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2010, 2012-2015 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"
35 static void blk_full(MACRO_PROT_ARGS
);
36 static void blk_exp_close(MACRO_PROT_ARGS
);
37 static void blk_part_exp(MACRO_PROT_ARGS
);
38 static void blk_part_imp(MACRO_PROT_ARGS
);
39 static void ctx_synopsis(MACRO_PROT_ARGS
);
40 static void in_line_eoln(MACRO_PROT_ARGS
);
41 static void in_line_argn(MACRO_PROT_ARGS
);
42 static void in_line(MACRO_PROT_ARGS
);
43 static void phrase_ta(MACRO_PROT_ARGS
);
45 static void append_delims(struct mdoc
*, int, int *, char *);
46 static void dword(struct mdoc
*, int, int, const char *,
48 static int find_pending(struct mdoc
*, int, int, int,
50 static int lookup(struct mdoc
*, int, int, int, const char *);
51 static int macro_or_word(MACRO_PROT_ARGS
, int);
52 static int parse_rest(struct mdoc
*, int, int, int *, char *);
53 static int rew_alt(int);
54 static void rew_elem(struct mdoc
*, int);
55 static void rew_last(struct mdoc
*, const struct roff_node
*);
56 static void rew_pending(struct mdoc
*, const struct roff_node
*);
58 const struct mdoc_macro __mdoc_macros
[MDOC_MAX
] = {
59 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ap */
60 { in_line_eoln
, MDOC_PROLOGUE
}, /* Dd */
61 { in_line_eoln
, MDOC_PROLOGUE
}, /* Dt */
62 { in_line_eoln
, MDOC_PROLOGUE
}, /* Os */
63 { blk_full
, MDOC_PARSED
| MDOC_JOIN
}, /* Sh */
64 { blk_full
, MDOC_PARSED
| MDOC_JOIN
}, /* Ss */
65 { in_line_eoln
, 0 }, /* Pp */
66 { blk_part_imp
, MDOC_PARSED
| MDOC_JOIN
}, /* D1 */
67 { blk_part_imp
, MDOC_PARSED
| MDOC_JOIN
}, /* Dl */
68 { blk_full
, MDOC_EXPLICIT
}, /* Bd */
69 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ed */
70 { blk_full
, MDOC_EXPLICIT
}, /* Bl */
71 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* El */
72 { blk_full
, MDOC_PARSED
| MDOC_JOIN
}, /* It */
73 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ad */
74 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* An */
75 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ar */
76 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Cd */
77 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Cm */
78 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dv */
79 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Er */
80 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ev */
81 { in_line_eoln
, 0 }, /* Ex */
82 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fa */
83 { in_line_eoln
, 0 }, /* Fd */
84 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fl */
85 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fn */
86 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ft */
87 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ic */
88 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* In */
89 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Li */
90 { blk_full
, MDOC_JOIN
}, /* Nd */
91 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nm */
92 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Op */
93 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ot */
94 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Pa */
95 { in_line_eoln
, 0 }, /* Rv */
96 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* St */
97 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Va */
98 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Vt */
99 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Xr */
100 { in_line_eoln
, MDOC_JOIN
}, /* %A */
101 { in_line_eoln
, MDOC_JOIN
}, /* %B */
102 { in_line_eoln
, MDOC_JOIN
}, /* %D */
103 { in_line_eoln
, MDOC_JOIN
}, /* %I */
104 { in_line_eoln
, MDOC_JOIN
}, /* %J */
105 { in_line_eoln
, 0 }, /* %N */
106 { in_line_eoln
, MDOC_JOIN
}, /* %O */
107 { in_line_eoln
, 0 }, /* %P */
108 { in_line_eoln
, MDOC_JOIN
}, /* %R */
109 { in_line_eoln
, MDOC_JOIN
}, /* %T */
110 { in_line_eoln
, 0 }, /* %V */
111 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
112 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ac */
113 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
114 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ao */
115 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Aq */
116 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* At */
117 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
118 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bc */
119 { blk_full
, MDOC_EXPLICIT
}, /* Bf */
120 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
121 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bo */
122 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Bq */
123 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bsx */
124 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bx */
125 { in_line_eoln
, 0 }, /* Db */
126 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
127 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Dc */
128 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
129 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Do */
130 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Dq */
131 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Ec */
132 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ef */
133 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Em */
134 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Eo */
135 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fx */
136 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ms */
137 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* No */
138 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
|
139 MDOC_IGNDELIM
| MDOC_JOIN
}, /* Ns */
140 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nx */
141 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ox */
142 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
143 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Pc */
144 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_IGNDELIM
}, /* Pf */
145 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
146 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Po */
147 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Pq */
148 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
149 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Qc */
150 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ql */
151 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
152 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Qo */
153 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Qq */
154 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Re */
155 { blk_full
, MDOC_EXPLICIT
}, /* Rs */
156 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
157 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Sc */
158 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
159 MDOC_EXPLICIT
| MDOC_JOIN
}, /* So */
160 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sq */
161 { in_line_argn
, 0 }, /* Sm */
162 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sx */
163 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sy */
164 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Tn */
165 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ux */
166 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Xc */
167 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Xo */
168 { blk_full
, MDOC_EXPLICIT
| MDOC_CALLABLE
}, /* Fo */
169 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
170 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Fc */
171 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
172 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Oo */
173 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
174 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Oc */
175 { blk_full
, MDOC_EXPLICIT
}, /* Bk */
176 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ek */
177 { in_line_eoln
, 0 }, /* Bt */
178 { in_line_eoln
, 0 }, /* Hf */
179 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fr */
180 { in_line_eoln
, 0 }, /* Ud */
181 { in_line
, 0 }, /* Lb */
182 { in_line_eoln
, 0 }, /* Lp */
183 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Lk */
184 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Mt */
185 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Brq */
186 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
187 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bro */
188 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
189 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Brc */
190 { in_line_eoln
, MDOC_JOIN
}, /* %C */
191 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Es */
192 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* En */
193 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dx */
194 { in_line_eoln
, MDOC_JOIN
}, /* %Q */
195 { in_line_eoln
, 0 }, /* br */
196 { in_line_eoln
, 0 }, /* sp */
197 { in_line_eoln
, 0 }, /* %U */
198 { phrase_ta
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ta */
199 { in_line_eoln
, MDOC_PROLOGUE
}, /* ll */
202 const struct mdoc_macro
* const mdoc_macros
= __mdoc_macros
;
206 * This is called at the end of parsing. It must traverse up the tree,
207 * closing out open [implicit] scopes. Obviously, open explicit scopes
211 mdoc_macroend(struct mdoc
*mdoc
)
215 /* Scan for open explicit scopes. */
217 n
= mdoc
->last
->flags
& MDOC_VALID
?
218 mdoc
->last
->parent
: mdoc
->last
;
220 for ( ; n
; n
= n
->parent
)
221 if (n
->type
== ROFFT_BLOCK
&&
222 mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
)
223 mandoc_msg(MANDOCERR_BLK_NOEND
, mdoc
->parse
,
224 n
->line
, n
->pos
, mdoc_macronames
[n
->tok
]);
226 /* Rewind to the first. */
228 rew_last(mdoc
, mdoc
->first
);
232 * Look up the macro at *p called by "from",
233 * or as a line macro if from == MDOC_MAX.
236 lookup(struct mdoc
*mdoc
, int from
, int line
, int ppos
, const char *p
)
240 if (from
== MDOC_MAX
|| mdoc_macros
[from
].flags
& MDOC_PARSED
) {
241 res
= mdoc_hash_find(p
);
242 if (res
!= MDOC_MAX
) {
243 if (mdoc_macros
[res
].flags
& MDOC_CALLABLE
)
245 if (res
!= MDOC_br
&& res
!= MDOC_sp
&& res
!= MDOC_ll
)
246 mandoc_msg(MANDOCERR_MACRO_CALL
,
247 mdoc
->parse
, line
, ppos
, p
);
254 * Rewind up to and including a specific node.
257 rew_last(struct mdoc
*mdoc
, const struct roff_node
*to
)
259 struct roff_node
*n
, *np
;
261 if (to
->flags
& MDOC_VALID
)
264 mdoc
->next
= MDOC_NEXT_SIBLING
;
265 while (mdoc
->last
!= to
) {
267 * Save the parent here, because we may delete the
268 * mdoc->last node in the post-validation phase and reset
269 * it to mdoc->last->parent, causing a step in the closing
272 np
= mdoc
->last
->parent
;
273 mdoc_valid_post(mdoc
);
277 mdoc
->last
->last
= n
;
279 mdoc_valid_post(mdoc
);
283 * Rewind up to a specific block, including all blocks that broke it.
286 rew_pending(struct mdoc
*mdoc
, const struct roff_node
*n
)
294 mdoc_body_alloc(mdoc
, n
->line
, n
->pos
, n
->tok
);
302 if ( ! (n
->flags
& MDOC_BROKEN
))
306 if ((n
= n
->parent
) == NULL
)
309 if (n
->type
== ROFFT_BLOCK
||
310 n
->type
== ROFFT_HEAD
) {
311 if (n
->flags
& MDOC_ENDED
)
321 * For a block closing macro, return the corresponding opening one.
322 * Otherwise, return the macro itself.
367 rew_elem(struct mdoc
*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 mdoc
*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
& MDOC_ENDED
) {
394 if ( ! (n
->flags
& MDOC_VALID
))
395 n
->flags
|= MDOC_BROKEN
;
398 if (n
->type
== ROFFT_BLOCK
&&
399 mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
) {
401 n
->flags
= MDOC_BROKEN
;
402 if (target
->type
== ROFFT_HEAD
)
403 target
->flags
= MDOC_ENDED
;
404 else if ( ! (target
->flags
& MDOC_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 mdoc
*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 mdoc_word_append(mdoc
, p
);
437 mdoc_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
|= MDOC_DELIMO
;
448 else if (d
== DELIM_CLOSE
&&
449 ! (mdoc
->flags
& MDOC_NODELIMC
) &&
450 mdoc
->last
->parent
->tok
!= MDOC_Fd
)
451 mdoc
->last
->flags
|= MDOC_DELIMC
;
452 mdoc
->flags
&= ~MDOC_NODELIMC
;
456 append_delims(struct mdoc
*mdoc
, int line
, int *pos
, char *buf
)
461 if (buf
[*pos
] == '\0')
466 if (mdoc_args(mdoc
, line
, pos
, buf
, MDOC_MAX
, &p
) == ARGS_EOLN
)
468 dword(mdoc
, line
, la
, p
, DELIM_MAX
, 1);
471 * If we encounter end-of-sentence symbols, then trigger
474 * XXX: it's easy to allow this to propagate outward to
475 * the last symbol, such that `. )' will cause the
476 * correct double-spacing. However, (1) groff isn't
477 * smart enough to do this and (2) it would require
478 * knowing which symbols break this behaviour, for
479 * example, `. ;' shouldn't propagate the double-space.
482 if (mandoc_eos(p
, strlen(p
)))
483 mdoc
->last
->flags
|= MDOC_EOS
;
489 * If it is a macro, call it and return 1.
490 * Otherwise, allocate it and return 0.
493 macro_or_word(MACRO_PROT_ARGS
, int parsed
)
502 else if (parsed
&& ! (mdoc
->flags
& MDOC_PHRASELIT
))
503 ntok
= lookup(mdoc
, tok
, line
, ppos
, p
);
505 if (ntok
== MDOC_MAX
) {
506 dword(mdoc
, line
, ppos
, p
, DELIM_MAX
, tok
== MDOC_MAX
||
507 mdoc_macros
[tok
].flags
& MDOC_JOIN
);
510 if (mdoc_macros
[tok
].fp
== in_line_eoln
)
512 mdoc_macro(mdoc
, ntok
, line
, ppos
, pos
, buf
);
514 append_delims(mdoc
, line
, pos
, buf
);
520 * Close out block partial/full explicit.
523 blk_exp_close(MACRO_PROT_ARGS
)
525 struct roff_node
*body
; /* Our own body. */
526 struct roff_node
*endbody
; /* Our own end marker. */
527 struct roff_node
*itblk
; /* An It block starting later. */
528 struct roff_node
*later
; /* A sub-block starting later. */
529 struct roff_node
*n
; /* Search back to our block. */
530 struct roff_node
*target
; /* For find_pending(). */
532 int j
, lastarg
, maxargs
, nl
, pending
;
537 nl
= MDOC_NEWLINE
& mdoc
->flags
;
544 mdoc
->flags
&= ~MDOC_KEEP
;
552 * Search backwards for beginnings of blocks,
553 * both of our own and of pending sub-blocks.
557 body
= endbody
= itblk
= later
= NULL
;
558 for (n
= mdoc
->last
; n
; n
= n
->parent
) {
559 if (n
->flags
& MDOC_ENDED
) {
560 if ( ! (n
->flags
& MDOC_VALID
))
561 n
->flags
|= MDOC_BROKEN
;
565 /* Remember the start of our own body. */
567 if (n
->type
== ROFFT_BODY
&& atok
== n
->tok
) {
568 if (n
->end
== ENDBODY_NOT
)
573 if (n
->type
!= ROFFT_BLOCK
|| n
->tok
== MDOC_Nm
)
576 if (n
->tok
== MDOC_It
) {
581 if (atok
== n
->tok
) {
585 * Found the start of our own block.
586 * When there is no pending sub block,
587 * just proceed to closing out.
591 (tok
== MDOC_El
&& itblk
== NULL
))
595 * When there is a pending sub block, postpone
596 * closing out the current block until the
597 * rew_pending() closing out the sub-block.
598 * Mark the place where the formatting - but not
599 * the scope - of the current block ends.
602 mandoc_vmsg(MANDOCERR_BLK_NEST
, mdoc
->parse
,
603 line
, ppos
, "%s breaks %s",
604 mdoc_macronames
[atok
],
605 mdoc_macronames
[later
->tok
]);
607 endbody
= mdoc_endbody_alloc(mdoc
, line
, ppos
,
608 atok
, body
, ENDBODY_SPACE
);
611 itblk
->flags
|= MDOC_ENDED
| MDOC_BROKEN
;
614 * If a block closing macro taking arguments
615 * breaks another block, put the arguments
616 * into the end marker.
620 mdoc
->next
= MDOC_NEXT_CHILD
;
624 /* Explicit blocks close out description lines. */
626 if (n
->tok
== MDOC_Nd
) {
631 /* Breaking an open sub block. */
633 n
->flags
|= MDOC_BROKEN
;
639 mandoc_msg(MANDOCERR_BLK_NOTOPEN
, mdoc
->parse
,
640 line
, ppos
, mdoc_macronames
[tok
]);
641 if (maxargs
&& endbody
== NULL
) {
643 * Stray .Ec without previous .Eo:
644 * Break the output line, keep the arguments.
646 mdoc_elem_alloc(mdoc
, line
, ppos
, MDOC_br
, NULL
);
647 rew_elem(mdoc
, MDOC_br
);
649 } else if (endbody
== NULL
) {
650 rew_last(mdoc
, body
);
652 mdoc_tail_alloc(mdoc
, line
, ppos
, atok
);
655 if ( ! (mdoc_macros
[tok
].flags
& MDOC_PARSED
)) {
656 if (buf
[*pos
] != '\0')
657 mandoc_vmsg(MANDOCERR_ARG_SKIP
,
658 mdoc
->parse
, line
, ppos
,
659 "%s %s", mdoc_macronames
[tok
],
661 if (endbody
== NULL
&& n
!= NULL
)
662 rew_pending(mdoc
, n
);
671 if (j
== maxargs
&& n
!= NULL
)
674 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
675 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
)
678 ntok
= ac
== ARGS_QWORD
? MDOC_MAX
:
679 lookup(mdoc
, tok
, line
, lastarg
, p
);
681 if (ntok
== MDOC_MAX
) {
682 dword(mdoc
, line
, lastarg
, p
, DELIM_MAX
,
683 MDOC_JOIN
& mdoc_macros
[tok
].flags
);
689 mdoc
->flags
&= ~MDOC_NEWLINE
;
690 mdoc_macro(mdoc
, ntok
, line
, lastarg
, pos
, buf
);
695 if (n
!= mdoc
->last
&& n
->flags
& MDOC_BROKEN
) {
698 target
= target
->parent
;
699 while ( ! (target
->flags
& MDOC_ENDED
));
700 pending
= find_pending(mdoc
, ntok
, line
, ppos
,
705 rew_pending(mdoc
, n
);
708 append_delims(mdoc
, line
, pos
, buf
);
712 in_line(MACRO_PROT_ARGS
)
714 int la
, scope
, cnt
, firstarg
, mayopen
, nc
, nl
;
718 struct mdoc_arg
*arg
;
721 nl
= MDOC_NEWLINE
& mdoc
->flags
;
724 * Whether we allow ignored elements (those without content,
725 * usually because of reserved words) to squeak by.
747 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
752 for (cnt
= scope
= 0;; ) {
754 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
757 * At the end of a macro line,
758 * opening delimiters do not suppress spacing.
761 if (ac
== ARGS_EOLN
) {
763 mdoc
->last
->flags
&= ~MDOC_DELIMO
;
768 * The rest of the macro line is only punctuation,
769 * to be handled by append_delims().
770 * If there were no other arguments,
771 * do not allow the first one to suppress spacing,
772 * even if it turns out to be a closing one.
775 if (ac
== ARGS_PUNCT
) {
776 if (cnt
== 0 && (nc
== 0 || tok
== MDOC_An
))
777 mdoc
->flags
|= MDOC_NODELIMC
;
781 ntok
= (ac
== ARGS_QWORD
|| (tok
== MDOC_Fn
&& !cnt
)) ?
782 MDOC_MAX
: lookup(mdoc
, tok
, line
, la
, p
);
785 * In this case, we've located a submacro and must
786 * execute it. Close out scope, if open. If no
787 * elements have been generated, either create one (nc)
788 * or raise a warning.
791 if (ntok
!= MDOC_MAX
) {
795 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
796 rew_last(mdoc
, mdoc
->last
);
797 } else if ( ! nc
&& ! cnt
) {
799 mandoc_msg(MANDOCERR_MACRO_EMPTY
,
800 mdoc
->parse
, line
, ppos
,
801 mdoc_macronames
[tok
]);
803 mdoc_macro(mdoc
, ntok
, line
, la
, pos
, buf
);
805 append_delims(mdoc
, line
, pos
, buf
);
810 * Non-quote-enclosed punctuation. Set up our scope, if
811 * a word; rewind the scope, if a delimiter; then append
815 d
= ac
== ARGS_QWORD
? DELIM_NONE
: mdoc_isdelim(p
);
817 if (DELIM_NONE
!= d
) {
819 * If we encounter closing punctuation, no word
820 * has been emitted, no scope is open, and we're
821 * allowed to have an empty element, then start
824 if ((d
== DELIM_CLOSE
||
825 (d
== DELIM_MIDDLE
&& tok
== MDOC_Fl
)) &&
826 !cnt
&& !scope
&& nc
&& mayopen
) {
827 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
834 * Close out our scope, if one is open, before
842 } else if (mayopen
&& !scope
) {
843 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
848 dword(mdoc
, line
, la
, p
, d
,
849 MDOC_JOIN
& mdoc_macros
[tok
].flags
);
852 * If the first argument is a closing delimiter,
853 * do not suppress spacing before it.
856 if (firstarg
&& d
== DELIM_CLOSE
&& !nc
)
857 mdoc
->last
->flags
&= ~MDOC_DELIMC
;
861 * `Fl' macros have their scope re-opened with each new
862 * word so that the `-' can be added to each one without
863 * having to parse out spaces.
865 if (scope
&& tok
== MDOC_Fl
) {
875 * If no elements have been collected and we're allowed to have
876 * empties (nc), open a scope and close it out. Otherwise,
882 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
883 rew_last(mdoc
, mdoc
->last
);
886 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
887 line
, ppos
, mdoc_macronames
[tok
]);
891 append_delims(mdoc
, line
, pos
, buf
);
895 blk_full(MACRO_PROT_ARGS
)
898 struct mdoc_arg
*arg
;
899 struct roff_node
*blk
; /* Our own or a broken block. */
900 struct roff_node
*head
; /* Our own head. */
901 struct roff_node
*body
; /* Our own body. */
903 enum margserr ac
, lac
;
906 nl
= MDOC_NEWLINE
& mdoc
->flags
;
908 if (buf
[*pos
] == '\0' && (tok
== MDOC_Sh
|| tok
== MDOC_Ss
)) {
909 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
910 line
, ppos
, mdoc_macronames
[tok
]);
914 if ( ! (mdoc_macros
[tok
].flags
& MDOC_EXPLICIT
)) {
916 /* Here, tok is one of Sh Ss Nm Nd It. */
919 for (n
= mdoc
->last
; n
!= NULL
; n
= n
->parent
) {
920 if (n
->flags
& MDOC_ENDED
) {
921 if ( ! (n
->flags
& MDOC_VALID
))
922 n
->flags
|= MDOC_BROKEN
;
925 if (n
->type
!= ROFFT_BLOCK
)
928 if (tok
== MDOC_It
&& n
->tok
== MDOC_Bl
) {
930 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
931 mdoc
->parse
, line
, ppos
,
933 mdoc_macronames
[blk
->tok
]);
934 rew_pending(mdoc
, blk
);
939 if (mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
) {
944 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
945 mdoc
->parse
, line
, ppos
,
947 mdoc_macronames
[tok
],
948 mdoc_macronames
[n
->tok
]);
949 rew_pending(mdoc
, n
);
953 /* Delay in case it's astray. */
962 /* Here, n is one of Sh Ss Nm Nd It. */
964 if (tok
!= MDOC_Sh
&& (n
->tok
== MDOC_Sh
||
965 (tok
!= MDOC_Ss
&& (n
->tok
== MDOC_Ss
||
966 (tok
!= MDOC_It
&& n
->tok
== MDOC_It
)))))
969 /* Item breaking an explicit block. */
972 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
973 mdoc
->parse
, line
, ppos
,
975 mdoc_macronames
[blk
->tok
]);
976 rew_pending(mdoc
, blk
);
980 /* Close out prior implicit scopes. */
985 /* Skip items outside lists. */
987 if (tok
== MDOC_It
&& (n
== NULL
|| n
->tok
!= MDOC_Bl
)) {
988 mandoc_vmsg(MANDOCERR_IT_STRAY
, mdoc
->parse
,
989 line
, ppos
, "It %s", buf
+ *pos
);
990 mdoc_elem_alloc(mdoc
, line
, ppos
, MDOC_br
, NULL
);
991 rew_elem(mdoc
, MDOC_br
);
997 * This routine accommodates implicitly- and explicitly-scoped
998 * macro openings. Implicit ones first close out prior scope
999 * (seen above). Delay opening the head until necessary to
1000 * allow leading punctuation to print. Special consideration
1001 * for `It -column', which has phrase-part syntax instead of
1002 * regular child nodes.
1005 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1006 blk
= mdoc_block_alloc(mdoc
, line
, ppos
, tok
, arg
);
1010 * Exception: Heads of `It' macros in `-diag' lists are not
1011 * parsed, even though `It' macros in general are parsed.
1014 parsed
= tok
!= MDOC_It
||
1015 mdoc
->last
->parent
->tok
!= MDOC_Bl
||
1016 mdoc
->last
->parent
->norm
->Bl
.type
!= LIST_diag
;
1019 * The `Nd' macro has all arguments in its body: it's a hybrid
1020 * of block partial-explicit and full-implicit. Stupid.
1023 if (tok
== MDOC_Nd
) {
1024 head
= mdoc_head_alloc(mdoc
, line
, ppos
, tok
);
1025 rew_last(mdoc
, head
);
1026 body
= mdoc_body_alloc(mdoc
, line
, ppos
, tok
);
1030 mdoc
->flags
|= MDOC_KEEP
;
1036 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1037 if (ac
== ARGS_EOLN
) {
1038 if (lac
!= ARGS_PPHRASE
&& lac
!= ARGS_PHRASE
)
1041 * This is necessary: if the last token on a
1042 * line is a `Ta' or tab, then we'll get
1043 * ARGS_EOLN, so we must be smart enough to
1044 * reopen our scope if the last parse was a
1045 * phrase or partial phrase.
1048 rew_last(mdoc
, body
);
1049 body
= mdoc_body_alloc(mdoc
, line
, ppos
, tok
);
1052 if (tok
== MDOC_Bd
|| tok
== MDOC_Bk
) {
1053 mandoc_vmsg(MANDOCERR_ARG_EXCESS
,
1054 mdoc
->parse
, line
, la
, "%s ... %s",
1055 mdoc_macronames
[tok
], buf
+ la
);
1058 if (tok
== MDOC_Rs
) {
1059 mandoc_vmsg(MANDOCERR_ARG_SKIP
, mdoc
->parse
,
1060 line
, la
, "Rs %s", buf
+ la
);
1063 if (ac
== ARGS_PUNCT
)
1067 * Emit leading punctuation (i.e., punctuation before
1068 * the ROFFT_HEAD) for non-phrase types.
1073 ac
!= ARGS_PHRASE
&&
1074 ac
!= ARGS_PPHRASE
&&
1076 mdoc_isdelim(p
) == DELIM_OPEN
) {
1077 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1081 /* Open a head if one hasn't been opened. */
1084 head
= mdoc_head_alloc(mdoc
, line
, ppos
, tok
);
1086 if (ac
== ARGS_PHRASE
||
1088 ac
== ARGS_PPHRASE
) {
1091 * If we haven't opened a body yet, rewind the
1092 * head; if we have, rewind that instead.
1095 rew_last(mdoc
, body
== NULL
? head
: body
);
1096 body
= mdoc_body_alloc(mdoc
, line
, ppos
, tok
);
1099 * Process phrases: set whether we're in a
1100 * partial-phrase (this effects line handling)
1101 * then call down into the phrase parser.
1104 if (ac
== ARGS_PPHRASE
)
1105 mdoc
->flags
|= MDOC_PPHRASE
;
1106 if (ac
== ARGS_PEND
&& lac
== ARGS_PPHRASE
)
1107 mdoc
->flags
|= MDOC_PPHRASE
;
1108 parse_rest(mdoc
, MDOC_MAX
, line
, &la
, buf
);
1109 mdoc
->flags
&= ~MDOC_PPHRASE
;
1113 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, parsed
))
1117 if (blk
->flags
& MDOC_VALID
)
1120 head
= mdoc_head_alloc(mdoc
, line
, ppos
, tok
);
1121 if (nl
&& tok
!= MDOC_Bd
&& tok
!= MDOC_Bl
&& tok
!= MDOC_Rs
)
1122 append_delims(mdoc
, line
, pos
, buf
);
1125 if (find_pending(mdoc
, tok
, line
, ppos
, head
))
1128 /* Close out scopes to remain in a consistent state. */
1130 rew_last(mdoc
, head
);
1131 body
= mdoc_body_alloc(mdoc
, line
, ppos
, tok
);
1133 if (mdoc
->flags
& MDOC_FREECOL
) {
1134 rew_last(mdoc
, body
);
1135 rew_last(mdoc
, blk
);
1136 mdoc
->flags
&= ~MDOC_FREECOL
;
1141 blk_part_imp(MACRO_PROT_ARGS
)
1146 struct roff_node
*blk
; /* saved block context */
1147 struct roff_node
*body
; /* saved body context */
1148 struct roff_node
*n
;
1150 nl
= MDOC_NEWLINE
& mdoc
->flags
;
1153 * A macro that spans to the end of the line. This is generally
1154 * (but not necessarily) called as the first macro. The block
1155 * has a head as the immediate child, which is always empty,
1156 * followed by zero or more opening punctuation nodes, then the
1157 * body (which may be empty, depending on the macro), then zero
1158 * or more closing punctuation nodes.
1161 blk
= mdoc_block_alloc(mdoc
, line
, ppos
, tok
, NULL
);
1162 rew_last(mdoc
, mdoc_head_alloc(mdoc
, line
, ppos
, tok
));
1165 * Open the body scope "on-demand", that is, after we've
1166 * processed all our the leading delimiters (open parenthesis,
1170 for (body
= NULL
; ; ) {
1172 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1173 if (ac
== ARGS_EOLN
|| ac
== ARGS_PUNCT
)
1176 if (body
== NULL
&& ac
!= ARGS_QWORD
&&
1177 mdoc_isdelim(p
) == DELIM_OPEN
) {
1178 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1183 body
= mdoc_body_alloc(mdoc
, line
, ppos
, tok
);
1185 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1189 body
= mdoc_body_alloc(mdoc
, line
, ppos
, tok
);
1191 if (find_pending(mdoc
, tok
, line
, ppos
, body
))
1194 rew_last(mdoc
, body
);
1196 append_delims(mdoc
, line
, pos
, buf
);
1197 rew_pending(mdoc
, blk
);
1199 /* Move trailing .Ns out of scope. */
1201 for (n
= body
->child
; n
&& n
->next
; n
= n
->next
)
1203 if (n
&& n
->tok
== MDOC_Ns
)
1204 mdoc_node_relink(mdoc
, n
);
1208 blk_part_exp(MACRO_PROT_ARGS
)
1212 struct roff_node
*head
; /* keep track of head */
1215 nl
= MDOC_NEWLINE
& mdoc
->flags
;
1218 * The opening of an explicit macro having zero or more leading
1219 * punctuation nodes; a head with optional single element (the
1220 * case of `Eo'); and a body that may be empty.
1223 mdoc_block_alloc(mdoc
, line
, ppos
, tok
, NULL
);
1227 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1228 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
)
1231 /* Flush out leading punctuation. */
1233 if (head
== NULL
&& ac
!= ARGS_QWORD
&&
1234 mdoc_isdelim(p
) == DELIM_OPEN
) {
1235 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1240 head
= mdoc_head_alloc(mdoc
, line
, ppos
, tok
);
1241 if (tok
== MDOC_Eo
) /* Not parsed. */
1242 dword(mdoc
, line
, la
, p
, DELIM_MAX
, 0);
1243 rew_last(mdoc
, head
);
1244 mdoc_body_alloc(mdoc
, line
, ppos
, tok
);
1249 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1253 /* Clean-up to leave in a consistent state. */
1256 rew_last(mdoc
, mdoc_head_alloc(mdoc
, line
, ppos
, tok
));
1257 mdoc_body_alloc(mdoc
, line
, ppos
, tok
);
1260 append_delims(mdoc
, line
, pos
, buf
);
1264 in_line_argn(MACRO_PROT_ARGS
)
1266 struct mdoc_arg
*arg
;
1270 int state
; /* arg#; -1: not yet open; -2: closed */
1271 int la
, maxargs
, nl
;
1273 nl
= mdoc
->flags
& MDOC_NEWLINE
;
1276 * A line macro that has a fixed number of arguments (maxargs).
1277 * Only open the scope once the first non-leading-punctuation is
1278 * found (unless MDOC_IGNDELIM is noted, like in `Pf'), then
1279 * keep it open until the maximum number of arguments are
1303 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1309 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1311 if (ac
== ARGS_WORD
&& state
== -1 &&
1312 ! (mdoc_macros
[tok
].flags
& MDOC_IGNDELIM
) &&
1313 mdoc_isdelim(p
) == DELIM_OPEN
) {
1314 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1318 if (state
== -1 && tok
!= MDOC_In
&&
1319 tok
!= MDOC_St
&& tok
!= MDOC_Xr
) {
1320 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1324 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
) {
1325 if (abs(state
) < 2 && tok
== MDOC_Pf
)
1326 mandoc_vmsg(MANDOCERR_PF_SKIP
,
1327 mdoc
->parse
, line
, ppos
, "Pf %s",
1328 p
== NULL
? "at eol" : p
);
1332 if (state
== maxargs
) {
1333 rew_elem(mdoc
, tok
);
1337 ntok
= (ac
== ARGS_QWORD
|| (tok
== MDOC_Pf
&& state
== 0)) ?
1338 MDOC_MAX
: lookup(mdoc
, tok
, line
, la
, p
);
1340 if (ntok
!= MDOC_MAX
) {
1342 rew_elem(mdoc
, tok
);
1345 mdoc_macro(mdoc
, ntok
, line
, la
, pos
, buf
);
1349 if (ac
== ARGS_QWORD
||
1350 mdoc_macros
[tok
].flags
& MDOC_IGNDELIM
||
1351 mdoc_isdelim(p
) == DELIM_NONE
) {
1353 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1355 } else if (state
>= 0)
1357 } else if (state
>= 0) {
1358 rew_elem(mdoc
, tok
);
1362 dword(mdoc
, line
, la
, p
, DELIM_MAX
,
1363 MDOC_JOIN
& mdoc_macros
[tok
].flags
);
1367 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
1368 line
, ppos
, mdoc_macronames
[tok
]);
1372 if (state
== 0 && tok
== MDOC_Pf
)
1373 append_delims(mdoc
, line
, pos
, buf
);
1375 rew_elem(mdoc
, tok
);
1377 append_delims(mdoc
, line
, pos
, buf
);
1381 in_line_eoln(MACRO_PROT_ARGS
)
1383 struct roff_node
*n
;
1384 struct mdoc_arg
*arg
;
1386 if ((tok
== MDOC_Pp
|| tok
== MDOC_Lp
) &&
1387 ! (mdoc
->flags
& MDOC_SYNOPSIS
)) {
1389 if (mdoc
->next
== MDOC_NEXT_SIBLING
)
1391 if (n
->tok
== MDOC_Nm
)
1392 rew_last(mdoc
, mdoc
->last
->parent
);
1395 if (buf
[*pos
] == '\0' &&
1396 (tok
== MDOC_Fd
|| mdoc_macronames
[tok
][0] == '%')) {
1397 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
1398 line
, ppos
, mdoc_macronames
[tok
]);
1402 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1403 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1404 if (parse_rest(mdoc
, tok
, line
, pos
, buf
))
1406 rew_elem(mdoc
, tok
);
1410 * The simplest argument parser available: Parse the remaining
1411 * words until the end of the phrase or line and return 0
1412 * or until the next macro, call that macro, and return 1.
1415 parse_rest(struct mdoc
*mdoc
, int tok
, int line
, int *pos
, char *buf
)
1421 if (mdoc_args(mdoc
, line
, pos
, buf
, tok
, NULL
) == ARGS_EOLN
)
1423 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1429 ctx_synopsis(MACRO_PROT_ARGS
)
1432 if (~mdoc
->flags
& (MDOC_SYNOPSIS
| MDOC_NEWLINE
))
1433 in_line(mdoc
, tok
, line
, ppos
, pos
, buf
);
1434 else if (tok
== MDOC_Nm
)
1435 blk_full(mdoc
, tok
, line
, ppos
, pos
, buf
);
1437 assert(tok
== MDOC_Vt
);
1438 blk_part_imp(mdoc
, tok
, line
, ppos
, pos
, buf
);
1443 * Phrases occur within `Bl -column' entries, separated by `Ta' or tabs.
1444 * They're unusual because they're basically free-form text until a
1445 * macro is encountered.
1448 phrase_ta(MACRO_PROT_ARGS
)
1450 struct roff_node
*body
, *n
;
1452 /* Make sure we are in a column list or ignore this macro. */
1455 for (n
= mdoc
->last
; n
!= NULL
; n
= n
->parent
) {
1456 if (n
->flags
& MDOC_ENDED
)
1458 if (n
->tok
== MDOC_It
&& n
->type
== ROFFT_BODY
)
1460 if (n
->tok
== MDOC_Bl
)
1464 if (n
== NULL
|| n
->norm
->Bl
.type
!= LIST_column
) {
1465 mandoc_msg(MANDOCERR_TA_STRAY
, mdoc
->parse
,
1470 /* Advance to the next column. */
1472 rew_last(mdoc
, body
);
1473 mdoc_body_alloc(mdoc
, line
, ppos
, MDOC_It
);
1474 parse_rest(mdoc
, MDOC_MAX
, line
, pos
, buf
);