]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_macro.c
1 /* $Id: mdoc_macro.c,v 1.214 2017/02/11 14:11:17 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 void break_intermediate(struct roff_node
*,
55 static int parse_rest(struct roff_man
*, int, int, int *, char *);
56 static int rew_alt(int);
57 static void rew_elem(struct roff_man
*, int);
58 static void rew_last(struct roff_man
*, const struct roff_node
*);
59 static void rew_pending(struct roff_man
*,
60 const struct roff_node
*);
62 const struct mdoc_macro __mdoc_macros
[MDOC_MAX
] = {
63 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ap */
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
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ar */
80 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Cd */
81 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Cm */
82 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dv */
83 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Er */
84 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ev */
85 { in_line_eoln
, 0 }, /* Ex */
86 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fa */
87 { in_line_eoln
, 0 }, /* Fd */
88 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fl */
89 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fn */
90 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ft */
91 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ic */
92 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* In */
93 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Li */
94 { blk_full
, MDOC_JOIN
}, /* Nd */
95 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nm */
96 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Op */
97 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ot */
98 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Pa */
99 { in_line_eoln
, 0 }, /* Rv */
100 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* St */
101 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Va */
102 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Vt */
103 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Xr */
104 { in_line_eoln
, MDOC_JOIN
}, /* %A */
105 { in_line_eoln
, MDOC_JOIN
}, /* %B */
106 { in_line_eoln
, MDOC_JOIN
}, /* %D */
107 { in_line_eoln
, MDOC_JOIN
}, /* %I */
108 { in_line_eoln
, MDOC_JOIN
}, /* %J */
109 { in_line_eoln
, 0 }, /* %N */
110 { in_line_eoln
, MDOC_JOIN
}, /* %O */
111 { in_line_eoln
, 0 }, /* %P */
112 { in_line_eoln
, MDOC_JOIN
}, /* %R */
113 { in_line_eoln
, MDOC_JOIN
}, /* %T */
114 { in_line_eoln
, 0 }, /* %V */
115 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
116 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ac */
117 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
118 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ao */
119 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Aq */
120 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* At */
121 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
122 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bc */
123 { blk_full
, MDOC_EXPLICIT
}, /* Bf */
124 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
125 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bo */
126 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Bq */
127 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bsx */
128 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bx */
129 { in_line_eoln
, 0 }, /* Db */
130 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
131 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Dc */
132 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
133 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Do */
134 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Dq */
135 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Ec */
136 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ef */
137 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Em */
138 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Eo */
139 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fx */
140 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ms */
141 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* No */
142 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
|
143 MDOC_IGNDELIM
| MDOC_JOIN
}, /* Ns */
144 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nx */
145 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ox */
146 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
147 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Pc */
148 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_IGNDELIM
}, /* Pf */
149 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
150 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Po */
151 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Pq */
152 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
153 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Qc */
154 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ql */
155 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
156 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Qo */
157 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Qq */
158 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Re */
159 { blk_full
, MDOC_EXPLICIT
}, /* Rs */
160 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
161 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Sc */
162 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
163 MDOC_EXPLICIT
| MDOC_JOIN
}, /* So */
164 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sq */
165 { in_line_argn
, 0 }, /* Sm */
166 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sx */
167 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Sy */
168 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Tn */
169 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ux */
170 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Xc */
171 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Xo */
172 { blk_full
, MDOC_EXPLICIT
| MDOC_CALLABLE
}, /* Fo */
173 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
174 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Fc */
175 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
176 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Oo */
177 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
178 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Oc */
179 { blk_full
, MDOC_EXPLICIT
}, /* Bk */
180 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_JOIN
}, /* Ek */
181 { in_line_eoln
, 0 }, /* Bt */
182 { in_line_eoln
, 0 }, /* Hf */
183 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fr */
184 { in_line_eoln
, 0 }, /* Ud */
185 { in_line
, 0 }, /* Lb */
186 { in_line_eoln
, 0 }, /* Lp */
187 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Lk */
188 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Mt */
189 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Brq */
190 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
|
191 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Bro */
192 { blk_exp_close
, MDOC_CALLABLE
| MDOC_PARSED
|
193 MDOC_EXPLICIT
| MDOC_JOIN
}, /* Brc */
194 { in_line_eoln
, MDOC_JOIN
}, /* %C */
195 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Es */
196 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* En */
197 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dx */
198 { in_line_eoln
, MDOC_JOIN
}, /* %Q */
199 { in_line_eoln
, 0 }, /* br */
200 { in_line_eoln
, 0 }, /* sp */
201 { in_line_eoln
, 0 }, /* %U */
202 { phrase_ta
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_JOIN
}, /* Ta */
203 { in_line_eoln
, MDOC_PROLOGUE
}, /* ll */
206 const struct mdoc_macro
* const mdoc_macros
= __mdoc_macros
;
210 * This is called at the end of parsing. It must traverse up the tree,
211 * closing out open [implicit] scopes. Obviously, open explicit scopes
215 mdoc_endparse(struct roff_man
*mdoc
)
219 /* Scan for open explicit scopes. */
221 n
= mdoc
->last
->flags
& NODE_VALID
?
222 mdoc
->last
->parent
: mdoc
->last
;
224 for ( ; n
; n
= n
->parent
)
225 if (n
->type
== ROFFT_BLOCK
&&
226 mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
)
227 mandoc_msg(MANDOCERR_BLK_NOEND
, mdoc
->parse
,
228 n
->line
, n
->pos
, mdoc_macronames
[n
->tok
]);
230 /* Rewind to the first. */
232 rew_last(mdoc
, mdoc
->first
);
233 mdoc_state_reset(mdoc
);
237 * Look up the macro at *p called by "from",
238 * or as a line macro if from == TOKEN_NONE.
241 lookup(struct roff_man
*mdoc
, int from
, int line
, int ppos
, const char *p
)
245 if (mdoc
->flags
& MDOC_PHRASEQF
) {
246 mdoc
->flags
&= ~MDOC_PHRASEQF
;
249 if (from
== TOKEN_NONE
|| mdoc_macros
[from
].flags
& MDOC_PARSED
) {
250 res
= mdoc_hash_find(p
);
251 if (res
!= TOKEN_NONE
) {
252 if (mdoc_macros
[res
].flags
& MDOC_CALLABLE
)
254 if (res
!= MDOC_br
&& res
!= MDOC_sp
&& res
!= MDOC_ll
)
255 mandoc_msg(MANDOCERR_MACRO_CALL
,
256 mdoc
->parse
, line
, ppos
, p
);
263 * Rewind up to and including a specific node.
266 rew_last(struct roff_man
*mdoc
, const struct roff_node
*to
)
269 if (to
->flags
& NODE_VALID
)
272 while (mdoc
->last
!= to
) {
273 mdoc_state(mdoc
, mdoc
->last
);
274 mdoc
->last
->flags
|= NODE_VALID
| NODE_ENDED
;
275 mdoc
->last
= mdoc
->last
->parent
;
277 mdoc_state(mdoc
, mdoc
->last
);
278 mdoc
->last
->flags
|= NODE_VALID
| NODE_ENDED
;
279 mdoc
->next
= ROFF_NEXT_SIBLING
;
283 * Rewind up to a specific block, including all blocks that broke it.
286 rew_pending(struct roff_man
*mdoc
, const struct roff_node
*n
)
292 if (mdoc
->last
== n
) {
295 roff_body_alloc(mdoc
, n
->line
, n
->pos
,
303 if ( ! (n
->flags
& NODE_BROKEN
))
309 if ((n
= n
->parent
) == NULL
)
312 if (n
->type
== ROFFT_BLOCK
||
313 n
->type
== ROFFT_HEAD
) {
314 if (n
->flags
& NODE_ENDED
)
324 * For a block closing macro, return the corresponding opening one.
325 * Otherwise, return the macro itself.
369 rew_elem(struct roff_man
*mdoc
, int tok
)
374 if (n
->type
!= ROFFT_ELEM
)
376 assert(n
->type
== ROFFT_ELEM
);
377 assert(tok
== n
->tok
);
382 break_intermediate(struct roff_node
*n
, struct roff_node
*breaker
)
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
, int tok
, int line
, int ppos
,
398 struct roff_node
*target
)
404 for (n
= mdoc
->last
; n
!= NULL
&& n
!= target
; n
= n
->parent
) {
405 if (n
->flags
& NODE_ENDED
)
407 if (n
->type
== ROFFT_BLOCK
&&
408 mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
) {
410 break_intermediate(mdoc
->last
, n
);
411 n
->flags
|= NODE_BROKEN
;
412 if (target
->type
== ROFFT_HEAD
)
413 target
->flags
|= NODE_ENDED
;
414 else if ( ! (target
->flags
& NODE_ENDED
)) {
415 mandoc_vmsg(MANDOCERR_BLK_NEST
,
416 mdoc
->parse
, line
, ppos
,
417 "%s breaks %s", mdoc_macronames
[tok
],
418 mdoc_macronames
[n
->tok
]);
419 mdoc_endbody_alloc(mdoc
, line
, ppos
,
420 tok
, target
, ENDBODY_NOSPACE
);
428 * Allocate a word and check whether it's punctuation or not.
429 * Punctuation consists of those tokens found in mdoc_isdelim().
432 dword(struct roff_man
*mdoc
, int line
, int col
, const char *p
,
433 enum mdelim d
, int may_append
)
440 ! (mdoc
->flags
& (MDOC_SYNOPSIS
| MDOC_KEEP
| MDOC_SMOFF
)) &&
441 d
== DELIM_NONE
&& mdoc
->last
->type
== ROFFT_TEXT
&&
442 mdoc_isdelim(mdoc
->last
->string
) == DELIM_NONE
) {
443 roff_word_append(mdoc
, p
);
447 roff_word_alloc(mdoc
, line
, col
, p
);
450 * If the word consists of a bare delimiter,
451 * flag the new node accordingly,
452 * unless doing so was vetoed by the invoking macro.
453 * Always clear the veto, it is only valid for one word.
457 mdoc
->last
->flags
|= NODE_DELIMO
;
458 else if (d
== DELIM_CLOSE
&&
459 ! (mdoc
->flags
& MDOC_NODELIMC
) &&
460 mdoc
->last
->parent
->tok
!= MDOC_Fd
)
461 mdoc
->last
->flags
|= NODE_DELIMC
;
462 mdoc
->flags
&= ~MDOC_NODELIMC
;
466 append_delims(struct roff_man
*mdoc
, int line
, int *pos
, char *buf
)
471 if (buf
[*pos
] == '\0')
476 if (mdoc_args(mdoc
, line
, pos
, buf
, TOKEN_NONE
, &p
) ==
479 dword(mdoc
, line
, la
, p
, DELIM_MAX
, 1);
482 * If we encounter end-of-sentence symbols, then trigger
485 * XXX: it's easy to allow this to propagate outward to
486 * the last symbol, such that `. )' will cause the
487 * correct double-spacing. However, (1) groff isn't
488 * smart enough to do this and (2) it would require
489 * knowing which symbols break this behaviour, for
490 * example, `. ;' shouldn't propagate the double-space.
493 if (mandoc_eos(p
, strlen(p
)))
494 mdoc
->last
->flags
|= NODE_EOS
;
500 * If it is a macro, call it and return 1.
501 * Otherwise, allocate it and return 0.
504 macro_or_word(MACRO_PROT_ARGS
, int parsed
)
513 else if (parsed
&& ! (mdoc
->flags
& MDOC_PHRASELIT
))
514 ntok
= lookup(mdoc
, tok
, line
, ppos
, p
);
516 if (ntok
== TOKEN_NONE
) {
517 dword(mdoc
, line
, ppos
, p
, DELIM_MAX
, tok
== TOKEN_NONE
||
518 mdoc_macros
[tok
].flags
& MDOC_JOIN
);
521 if (mdoc_macros
[tok
].fp
== in_line_eoln
)
523 mdoc_macro(mdoc
, ntok
, line
, ppos
, pos
, buf
);
524 if (tok
== TOKEN_NONE
)
525 append_delims(mdoc
, line
, pos
, buf
);
531 * Close out block partial/full explicit.
534 blk_exp_close(MACRO_PROT_ARGS
)
536 struct roff_node
*body
; /* Our own body. */
537 struct roff_node
*endbody
; /* Our own end marker. */
538 struct roff_node
*itblk
; /* An It block starting later. */
539 struct roff_node
*later
; /* A sub-block starting later. */
540 struct roff_node
*n
; /* Search back to our block. */
541 struct roff_node
*target
; /* For find_pending(). */
543 int j
, lastarg
, maxargs
, nl
, pending
;
548 nl
= MDOC_NEWLINE
& mdoc
->flags
;
555 mdoc
->flags
&= ~MDOC_KEEP
;
562 /* Search backwards for the beginning of our own body. */
566 for (n
= mdoc
->last
; n
; n
= n
->parent
) {
567 if (n
->flags
& NODE_ENDED
|| n
->tok
!= atok
||
568 n
->type
!= ROFFT_BODY
|| n
->end
!= ENDBODY_NOT
)
575 * Search backwards for beginnings of blocks,
576 * both of our own and of pending sub-blocks.
579 endbody
= itblk
= later
= NULL
;
580 for (n
= mdoc
->last
; n
; n
= n
->parent
) {
581 if (n
->flags
& NODE_ENDED
)
585 * Mismatching end macros can never break anything
586 * and we only care about the breaking of BLOCKs.
589 if (body
== NULL
|| n
->type
!= ROFFT_BLOCK
)
593 * SYNOPSIS name blocks can not be broken themselves,
594 * but they do get broken together with a broken child.
597 if (n
->tok
== MDOC_Nm
) {
599 n
->flags
|= NODE_BROKEN
| NODE_ENDED
;
603 if (n
->tok
== MDOC_It
) {
608 if (atok
== n
->tok
) {
611 * Found the start of our own block.
612 * When there is no pending sub block,
613 * just proceed to closing out.
617 (tok
== MDOC_El
&& itblk
== NULL
))
621 * When there is a pending sub block, postpone
622 * closing out the current block until the
623 * rew_pending() closing out the sub-block.
624 * Mark the place where the formatting - but not
625 * the scope - of the current block ends.
628 mandoc_vmsg(MANDOCERR_BLK_NEST
, mdoc
->parse
,
629 line
, ppos
, "%s breaks %s",
630 mdoc_macronames
[atok
],
631 mdoc_macronames
[later
->tok
]);
633 endbody
= mdoc_endbody_alloc(mdoc
, line
, ppos
,
634 atok
, body
, ENDBODY_SPACE
);
637 itblk
->flags
|= NODE_ENDED
| NODE_BROKEN
;
640 * If a block closing macro taking arguments
641 * breaks another block, put the arguments
642 * into the end marker.
646 mdoc
->next
= ROFF_NEXT_CHILD
;
651 * Explicit blocks close out description lines, but
652 * even those can get broken together with a child.
655 if (n
->tok
== MDOC_Nd
) {
657 n
->flags
|= NODE_BROKEN
| NODE_ENDED
;
663 /* Breaking an open sub block. */
665 break_intermediate(mdoc
->last
, body
);
666 n
->flags
|= NODE_BROKEN
;
672 mandoc_msg(MANDOCERR_BLK_NOTOPEN
, mdoc
->parse
,
673 line
, ppos
, mdoc_macronames
[tok
]);
674 if (maxargs
&& endbody
== NULL
) {
676 * Stray .Ec without previous .Eo:
677 * Break the output line, keep the arguments.
679 roff_elem_alloc(mdoc
, line
, ppos
, MDOC_br
);
680 rew_elem(mdoc
, MDOC_br
);
682 } else if (endbody
== NULL
) {
683 rew_last(mdoc
, body
);
685 mdoc_tail_alloc(mdoc
, line
, ppos
, atok
);
688 if ( ! (mdoc_macros
[tok
].flags
& MDOC_PARSED
)) {
689 if (buf
[*pos
] != '\0')
690 mandoc_vmsg(MANDOCERR_ARG_SKIP
,
691 mdoc
->parse
, line
, ppos
,
692 "%s %s", mdoc_macronames
[tok
],
694 if (endbody
== NULL
&& n
!= NULL
)
695 rew_pending(mdoc
, n
);
706 if (j
== maxargs
&& n
!= NULL
)
709 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
710 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
)
713 ntok
= ac
== ARGS_QWORD
? TOKEN_NONE
:
714 lookup(mdoc
, tok
, line
, lastarg
, p
);
716 if (ntok
== TOKEN_NONE
) {
717 dword(mdoc
, line
, lastarg
, p
, DELIM_MAX
,
718 MDOC_JOIN
& mdoc_macros
[tok
].flags
);
724 mdoc
->flags
&= ~MDOC_NEWLINE
;
725 mdoc_macro(mdoc
, ntok
, line
, lastarg
, pos
, buf
);
731 if (ntok
!= TOKEN_NONE
&& n
->flags
& NODE_BROKEN
) {
734 target
= target
->parent
;
735 while ( ! (target
->flags
& NODE_ENDED
));
736 if ( ! (target
->flags
& NODE_VALID
))
737 pending
= find_pending(mdoc
, ntok
,
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
,
832 mdoc_macronames
[tok
]);
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_JOIN
& mdoc_macros
[tok
].flags
);
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
) {
906 * If no elements have been collected and we're allowed to have
907 * empties (nc), open a scope and close it out. Otherwise,
913 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
914 rew_last(mdoc
, mdoc
->last
);
917 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
918 line
, ppos
, mdoc_macronames
[tok
]);
922 append_delims(mdoc
, line
, pos
, buf
);
926 blk_full(MACRO_PROT_ARGS
)
929 struct mdoc_arg
*arg
;
930 struct roff_node
*blk
; /* Our own or a broken block. */
931 struct roff_node
*head
; /* Our own head. */
932 struct roff_node
*body
; /* Our own body. */
934 enum margserr ac
, lac
;
937 nl
= MDOC_NEWLINE
& mdoc
->flags
;
939 if (buf
[*pos
] == '\0' && (tok
== MDOC_Sh
|| tok
== MDOC_Ss
)) {
940 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
941 line
, ppos
, mdoc_macronames
[tok
]);
945 if ( ! (mdoc_macros
[tok
].flags
& MDOC_EXPLICIT
)) {
947 /* Here, tok is one of Sh Ss Nm Nd It. */
950 for (n
= mdoc
->last
; n
!= NULL
; n
= n
->parent
) {
951 if (n
->flags
& NODE_ENDED
) {
952 if ( ! (n
->flags
& NODE_VALID
))
953 n
->flags
|= NODE_BROKEN
;
956 if (n
->type
!= ROFFT_BLOCK
)
959 if (tok
== MDOC_It
&& n
->tok
== MDOC_Bl
) {
961 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
962 mdoc
->parse
, line
, ppos
,
964 mdoc_macronames
[blk
->tok
]);
965 rew_pending(mdoc
, blk
);
970 if (mdoc_macros
[n
->tok
].flags
& MDOC_EXPLICIT
) {
974 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
975 mdoc
->parse
, line
, ppos
,
977 mdoc_macronames
[tok
],
978 mdoc_macronames
[n
->tok
]);
979 rew_pending(mdoc
, n
);
983 /* Delay in case it's astray. */
992 /* Here, n is one of Sh Ss Nm Nd It. */
994 if (tok
!= MDOC_Sh
&& (n
->tok
== MDOC_Sh
||
995 (tok
!= MDOC_Ss
&& (n
->tok
== MDOC_Ss
||
996 (tok
!= MDOC_It
&& n
->tok
== MDOC_It
)))))
999 /* Item breaking an explicit block. */
1002 mandoc_vmsg(MANDOCERR_BLK_BROKEN
,
1003 mdoc
->parse
, line
, ppos
,
1005 mdoc_macronames
[blk
->tok
]);
1006 rew_pending(mdoc
, blk
);
1010 /* Close out prior implicit scopes. */
1012 rew_pending(mdoc
, n
);
1015 /* Skip items outside lists. */
1017 if (tok
== MDOC_It
&& (n
== NULL
|| n
->tok
!= MDOC_Bl
)) {
1018 mandoc_vmsg(MANDOCERR_IT_STRAY
, mdoc
->parse
,
1019 line
, ppos
, "It %s", buf
+ *pos
);
1020 roff_elem_alloc(mdoc
, line
, ppos
, MDOC_br
);
1021 rew_elem(mdoc
, MDOC_br
);
1027 * This routine accommodates implicitly- and explicitly-scoped
1028 * macro openings. Implicit ones first close out prior scope
1029 * (seen above). Delay opening the head until necessary to
1030 * allow leading punctuation to print. Special consideration
1031 * for `It -column', which has phrase-part syntax instead of
1032 * regular child nodes.
1035 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1036 blk
= mdoc_block_alloc(mdoc
, line
, ppos
, tok
, arg
);
1040 * Exception: Heads of `It' macros in `-diag' lists are not
1041 * parsed, even though `It' macros in general are parsed.
1044 parsed
= tok
!= MDOC_It
||
1045 mdoc
->last
->parent
->tok
!= MDOC_Bl
||
1046 mdoc
->last
->parent
->norm
->Bl
.type
!= LIST_diag
;
1049 * The `Nd' macro has all arguments in its body: it's a hybrid
1050 * of block partial-explicit and full-implicit. Stupid.
1053 if (tok
== MDOC_Nd
) {
1054 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1055 rew_last(mdoc
, head
);
1056 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1060 mdoc
->flags
|= MDOC_KEEP
;
1066 * If we are right after a tab character,
1067 * do not parse the first word for macros.
1070 if (mdoc
->flags
& MDOC_PHRASEQN
) {
1071 mdoc
->flags
&= ~MDOC_PHRASEQN
;
1072 mdoc
->flags
|= MDOC_PHRASEQF
;
1077 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1078 if (ac
== ARGS_EOLN
) {
1079 if (lac
!= ARGS_PHRASE
||
1080 ! (mdoc
->flags
& MDOC_PHRASEQF
))
1084 * This line ends in a tab; start the next
1085 * column now, with a leading blank.
1089 rew_last(mdoc
, body
);
1090 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1091 roff_word_alloc(mdoc
, line
, ppos
, "\\&");
1095 if (tok
== MDOC_Bd
|| tok
== MDOC_Bk
) {
1096 mandoc_vmsg(MANDOCERR_ARG_EXCESS
,
1097 mdoc
->parse
, line
, la
, "%s ... %s",
1098 mdoc_macronames
[tok
], buf
+ la
);
1101 if (tok
== MDOC_Rs
) {
1102 mandoc_vmsg(MANDOCERR_ARG_SKIP
, mdoc
->parse
,
1103 line
, la
, "Rs %s", buf
+ la
);
1106 if (ac
== ARGS_PUNCT
)
1110 * Emit leading punctuation (i.e., punctuation before
1111 * the ROFFT_HEAD) for non-phrase types.
1115 ac
!= ARGS_PHRASE
&&
1117 mdoc_isdelim(p
) == DELIM_OPEN
) {
1118 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1122 /* Open a head if one hasn't been opened. */
1125 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1127 if (ac
== ARGS_PHRASE
) {
1130 * If we haven't opened a body yet, rewind the
1131 * head; if we have, rewind that instead.
1134 rew_last(mdoc
, body
== NULL
? head
: body
);
1135 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1137 /* Process to the tab or to the end of the line. */
1139 mdoc
->flags
|= MDOC_PHRASE
;
1140 parse_rest(mdoc
, TOKEN_NONE
, line
, &la
, buf
);
1141 mdoc
->flags
&= ~MDOC_PHRASE
;
1143 /* There may have been `Ta' macros. */
1145 while (body
->next
!= NULL
)
1150 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, parsed
))
1154 if (blk
->flags
& NODE_VALID
)
1157 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1158 if (nl
&& tok
!= MDOC_Bd
&& tok
!= MDOC_Bl
&& tok
!= MDOC_Rs
)
1159 append_delims(mdoc
, line
, pos
, buf
);
1162 if (find_pending(mdoc
, tok
, line
, ppos
, head
))
1165 /* Close out scopes to remain in a consistent state. */
1167 rew_last(mdoc
, head
);
1168 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1170 if (mdoc
->flags
& MDOC_FREECOL
) {
1171 rew_last(mdoc
, body
);
1172 rew_last(mdoc
, blk
);
1173 mdoc
->flags
&= ~MDOC_FREECOL
;
1178 blk_part_imp(MACRO_PROT_ARGS
)
1183 struct roff_node
*blk
; /* saved block context */
1184 struct roff_node
*body
; /* saved body context */
1185 struct roff_node
*n
;
1187 nl
= MDOC_NEWLINE
& mdoc
->flags
;
1190 * A macro that spans to the end of the line. This is generally
1191 * (but not necessarily) called as the first macro. The block
1192 * has a head as the immediate child, which is always empty,
1193 * followed by zero or more opening punctuation nodes, then the
1194 * body (which may be empty, depending on the macro), then zero
1195 * or more closing punctuation nodes.
1198 blk
= mdoc_block_alloc(mdoc
, line
, ppos
, tok
, NULL
);
1199 rew_last(mdoc
, roff_head_alloc(mdoc
, line
, ppos
, tok
));
1202 * Open the body scope "on-demand", that is, after we've
1203 * processed all our the leading delimiters (open parenthesis,
1207 for (body
= NULL
; ; ) {
1209 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1210 if (ac
== ARGS_EOLN
|| ac
== ARGS_PUNCT
)
1213 if (body
== NULL
&& ac
!= ARGS_QWORD
&&
1214 mdoc_isdelim(p
) == DELIM_OPEN
) {
1215 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1220 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1222 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1226 body
= roff_body_alloc(mdoc
, line
, ppos
, tok
);
1228 if (find_pending(mdoc
, tok
, line
, ppos
, body
))
1231 rew_last(mdoc
, body
);
1233 append_delims(mdoc
, line
, pos
, buf
);
1234 rew_pending(mdoc
, blk
);
1236 /* Move trailing .Ns out of scope. */
1238 for (n
= body
->child
; n
&& n
->next
; n
= n
->next
)
1240 if (n
&& n
->tok
== MDOC_Ns
)
1241 mdoc_node_relink(mdoc
, n
);
1245 blk_part_exp(MACRO_PROT_ARGS
)
1249 struct roff_node
*head
; /* keep track of head */
1252 nl
= MDOC_NEWLINE
& mdoc
->flags
;
1255 * The opening of an explicit macro having zero or more leading
1256 * punctuation nodes; a head with optional single element (the
1257 * case of `Eo'); and a body that may be empty.
1260 roff_block_alloc(mdoc
, line
, ppos
, tok
);
1264 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1265 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
)
1268 /* Flush out leading punctuation. */
1270 if (head
== NULL
&& ac
!= ARGS_QWORD
&&
1271 mdoc_isdelim(p
) == DELIM_OPEN
) {
1272 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1277 head
= roff_head_alloc(mdoc
, line
, ppos
, tok
);
1278 if (tok
== MDOC_Eo
) /* Not parsed. */
1279 dword(mdoc
, line
, la
, p
, DELIM_MAX
, 0);
1280 rew_last(mdoc
, head
);
1281 roff_body_alloc(mdoc
, line
, ppos
, tok
);
1286 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1290 /* Clean-up to leave in a consistent state. */
1293 rew_last(mdoc
, roff_head_alloc(mdoc
, line
, ppos
, tok
));
1294 roff_body_alloc(mdoc
, line
, ppos
, tok
);
1297 append_delims(mdoc
, line
, pos
, buf
);
1301 in_line_argn(MACRO_PROT_ARGS
)
1303 struct mdoc_arg
*arg
;
1307 int state
; /* arg#; -1: not yet open; -2: closed */
1308 int la
, maxargs
, nl
;
1310 nl
= mdoc
->flags
& MDOC_NEWLINE
;
1313 * A line macro that has a fixed number of arguments (maxargs).
1314 * Only open the scope once the first non-leading-punctuation is
1315 * found (unless MDOC_IGNDELIM is noted, like in `Pf'), then
1316 * keep it open until the maximum number of arguments are
1336 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1342 ac
= mdoc_args(mdoc
, line
, pos
, buf
, tok
, &p
);
1344 if (ac
== ARGS_WORD
&& state
== -1 &&
1345 ! (mdoc_macros
[tok
].flags
& MDOC_IGNDELIM
) &&
1346 mdoc_isdelim(p
) == DELIM_OPEN
) {
1347 dword(mdoc
, line
, la
, p
, DELIM_OPEN
, 0);
1351 if (state
== -1 && tok
!= MDOC_In
&&
1352 tok
!= MDOC_St
&& tok
!= MDOC_Xr
) {
1353 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1357 if (ac
== ARGS_PUNCT
|| ac
== ARGS_EOLN
) {
1358 if (abs(state
) < 2 && tok
== MDOC_Pf
)
1359 mandoc_vmsg(MANDOCERR_PF_SKIP
,
1360 mdoc
->parse
, line
, ppos
, "Pf %s",
1361 p
== NULL
? "at eol" : p
);
1365 if (state
== maxargs
) {
1366 rew_elem(mdoc
, tok
);
1370 ntok
= (ac
== ARGS_QWORD
|| (tok
== MDOC_Pf
&& state
== 0)) ?
1371 TOKEN_NONE
: lookup(mdoc
, tok
, line
, la
, p
);
1373 if (ntok
!= TOKEN_NONE
) {
1375 rew_elem(mdoc
, tok
);
1378 mdoc_macro(mdoc
, ntok
, line
, la
, pos
, buf
);
1382 if (ac
== ARGS_QWORD
||
1383 mdoc_macros
[tok
].flags
& MDOC_IGNDELIM
||
1384 mdoc_isdelim(p
) == DELIM_NONE
) {
1386 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1388 } else if (state
>= 0)
1390 } else if (state
>= 0) {
1391 rew_elem(mdoc
, tok
);
1395 dword(mdoc
, line
, la
, p
, DELIM_MAX
,
1396 MDOC_JOIN
& mdoc_macros
[tok
].flags
);
1400 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
1401 line
, ppos
, mdoc_macronames
[tok
]);
1405 if (state
== 0 && tok
== MDOC_Pf
)
1406 append_delims(mdoc
, line
, pos
, buf
);
1408 rew_elem(mdoc
, tok
);
1410 append_delims(mdoc
, line
, pos
, buf
);
1414 in_line_eoln(MACRO_PROT_ARGS
)
1416 struct roff_node
*n
;
1417 struct mdoc_arg
*arg
;
1419 if ((tok
== MDOC_Pp
|| tok
== MDOC_Lp
) &&
1420 ! (mdoc
->flags
& MDOC_SYNOPSIS
)) {
1422 if (mdoc
->next
== ROFF_NEXT_SIBLING
)
1424 if (n
->tok
== MDOC_Nm
)
1425 rew_last(mdoc
, n
->parent
);
1428 if (buf
[*pos
] == '\0' &&
1429 (tok
== MDOC_Fd
|| mdoc_macronames
[tok
][0] == '%')) {
1430 mandoc_msg(MANDOCERR_MACRO_EMPTY
, mdoc
->parse
,
1431 line
, ppos
, mdoc_macronames
[tok
]);
1435 mdoc_argv(mdoc
, line
, tok
, &arg
, pos
, buf
);
1436 mdoc_elem_alloc(mdoc
, line
, ppos
, tok
, arg
);
1437 if (parse_rest(mdoc
, tok
, line
, pos
, buf
))
1439 rew_elem(mdoc
, tok
);
1443 * The simplest argument parser available: Parse the remaining
1444 * words until the end of the phrase or line and return 0
1445 * or until the next macro, call that macro, and return 1.
1448 parse_rest(struct roff_man
*mdoc
, int tok
, int line
, int *pos
, char *buf
)
1454 if (mdoc_args(mdoc
, line
, pos
, buf
, tok
, NULL
) == ARGS_EOLN
)
1456 if (macro_or_word(mdoc
, tok
, line
, la
, pos
, buf
, 1))
1462 ctx_synopsis(MACRO_PROT_ARGS
)
1465 if (~mdoc
->flags
& (MDOC_SYNOPSIS
| MDOC_NEWLINE
))
1466 in_line(mdoc
, tok
, line
, ppos
, pos
, buf
);
1467 else if (tok
== MDOC_Nm
)
1468 blk_full(mdoc
, tok
, line
, ppos
, pos
, buf
);
1470 assert(tok
== MDOC_Vt
);
1471 blk_part_imp(mdoc
, tok
, line
, ppos
, pos
, buf
);
1476 * Phrases occur within `Bl -column' entries, separated by `Ta' or tabs.
1477 * They're unusual because they're basically free-form text until a
1478 * macro is encountered.
1481 phrase_ta(MACRO_PROT_ARGS
)
1483 struct roff_node
*body
, *n
;
1485 /* Make sure we are in a column list or ignore this macro. */
1488 for (n
= mdoc
->last
; n
!= NULL
; n
= n
->parent
) {
1489 if (n
->flags
& NODE_ENDED
)
1491 if (n
->tok
== MDOC_It
&& n
->type
== ROFFT_BODY
)
1493 if (n
->tok
== MDOC_Bl
&& n
->end
== ENDBODY_NOT
)
1497 if (n
== NULL
|| n
->norm
->Bl
.type
!= LIST_column
) {
1498 mandoc_msg(MANDOCERR_TA_STRAY
, mdoc
->parse
,
1503 /* Advance to the next column. */
1505 rew_last(mdoc
, body
);
1506 roff_body_alloc(mdoc
, line
, ppos
, MDOC_It
);
1507 parse_rest(mdoc
, TOKEN_NONE
, line
, pos
, buf
);