]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_macro.c
1 /* $Id: mdoc_macro.c,v 1.101 2011/01/25 15:17:18 kristaps Exp $ */
3 * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2010 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 AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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.
31 #include "libmandoc.h"
33 enum rew
{ /* see rew_dohalt() */
42 static int blk_full(MACRO_PROT_ARGS
);
43 static int blk_exp_close(MACRO_PROT_ARGS
);
44 static int blk_part_exp(MACRO_PROT_ARGS
);
45 static int blk_part_imp(MACRO_PROT_ARGS
);
46 static int ctx_synopsis(MACRO_PROT_ARGS
);
47 static int in_line_eoln(MACRO_PROT_ARGS
);
48 static int in_line_argn(MACRO_PROT_ARGS
);
49 static int in_line(MACRO_PROT_ARGS
);
50 static int obsolete(MACRO_PROT_ARGS
);
51 static int phrase_ta(MACRO_PROT_ARGS
);
53 static int append_delims(struct mdoc
*,
55 static enum mdoct
lookup(enum mdoct
, const char *);
56 static enum mdoct
lookup_raw(const char *);
57 static int make_pending(struct mdoc_node
*, enum mdoct
,
58 struct mdoc
*, int, int);
59 static int phrase(struct mdoc
*, int, int, char *);
60 static enum mdoct
rew_alt(enum mdoct
);
61 static enum rew
rew_dohalt(enum mdoct
, enum mdoc_type
,
62 const struct mdoc_node
*);
63 static int rew_elem(struct mdoc
*, enum mdoct
);
64 static int rew_last(struct mdoc
*,
65 const struct mdoc_node
*);
66 static int rew_sub(enum mdoc_type
, struct mdoc
*,
67 enum mdoct
, int, int);
69 const struct mdoc_macro __mdoc_macros
[MDOC_MAX
] = {
70 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ap */
71 { in_line_eoln
, MDOC_PROLOGUE
}, /* Dd */
72 { in_line_eoln
, MDOC_PROLOGUE
}, /* Dt */
73 { in_line_eoln
, MDOC_PROLOGUE
}, /* Os */
74 { blk_full
, 0 }, /* Sh */
75 { blk_full
, 0 }, /* Ss */
76 { in_line_eoln
, 0 }, /* Pp */
77 { blk_part_imp
, MDOC_PARSED
}, /* D1 */
78 { blk_part_imp
, MDOC_PARSED
}, /* Dl */
79 { blk_full
, MDOC_EXPLICIT
}, /* Bd */
80 { blk_exp_close
, MDOC_EXPLICIT
}, /* Ed */
81 { blk_full
, MDOC_EXPLICIT
}, /* Bl */
82 { blk_exp_close
, MDOC_EXPLICIT
}, /* El */
83 { blk_full
, MDOC_PARSED
}, /* It */
84 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ad */
85 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* An */
86 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ar */
87 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Cd */
88 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Cm */
89 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dv */
90 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Er */
91 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ev */
92 { in_line_eoln
, 0 }, /* Ex */
93 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fa */
94 { in_line_eoln
, 0 }, /* Fd */
95 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fl */
96 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fn */
97 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ft */
98 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ic */
99 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* In */
100 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Li */
101 { blk_full
, 0 }, /* Nd */
102 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nm */
103 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Op */
104 { obsolete
, 0 }, /* Ot */
105 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Pa */
106 { in_line_eoln
, 0 }, /* Rv */
107 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* St */
108 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Va */
109 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Vt */
110 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Xr */
111 { in_line_eoln
, 0 }, /* %A */
112 { in_line_eoln
, 0 }, /* %B */
113 { in_line_eoln
, 0 }, /* %D */
114 { in_line_eoln
, 0 }, /* %I */
115 { in_line_eoln
, 0 }, /* %J */
116 { in_line_eoln
, 0 }, /* %N */
117 { in_line_eoln
, 0 }, /* %O */
118 { in_line_eoln
, 0 }, /* %P */
119 { in_line_eoln
, 0 }, /* %R */
120 { in_line_eoln
, 0 }, /* %T */
121 { in_line_eoln
, 0 }, /* %V */
122 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Ac */
123 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Ao */
124 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Aq */
125 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* At */
126 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Bc */
127 { blk_full
, MDOC_EXPLICIT
}, /* Bf */
128 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Bo */
129 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bq */
130 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bsx */
131 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bx */
132 { in_line_eoln
, 0 }, /* Db */
133 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Dc */
134 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Do */
135 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dq */
136 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Ec */
137 { blk_exp_close
, MDOC_EXPLICIT
}, /* Ef */
138 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Em */
139 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Eo */
140 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fx */
141 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ms */
142 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_IGNDELIM
}, /* No */
143 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_IGNDELIM
}, /* Ns */
144 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nx */
145 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ox */
146 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Pc */
147 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_IGNDELIM
}, /* Pf */
148 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Po */
149 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Pq */
150 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Qc */
151 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ql */
152 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Qo */
153 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Qq */
154 { blk_exp_close
, MDOC_EXPLICIT
}, /* Re */
155 { blk_full
, MDOC_EXPLICIT
}, /* Rs */
156 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Sc */
157 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* So */
158 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Sq */
159 { in_line_eoln
, 0 }, /* Sm */
160 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Sx */
161 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Sy */
162 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Tn */
163 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ux */
164 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Xc */
165 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Xo */
166 { blk_full
, MDOC_EXPLICIT
| MDOC_CALLABLE
}, /* Fo */
167 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Fc */
168 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Oo */
169 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Oc */
170 { blk_full
, MDOC_EXPLICIT
}, /* Bk */
171 { blk_exp_close
, MDOC_EXPLICIT
}, /* Ek */
172 { in_line_eoln
, 0 }, /* Bt */
173 { in_line_eoln
, 0 }, /* Hf */
174 { obsolete
, 0 }, /* Fr */
175 { in_line_eoln
, 0 }, /* Ud */
176 { in_line
, 0 }, /* Lb */
177 { in_line_eoln
, 0 }, /* Lp */
178 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Lk */
179 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Mt */
180 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Brq */
181 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Bro */
182 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Brc */
183 { in_line_eoln
, 0 }, /* %C */
184 { obsolete
, 0 }, /* Es */
185 { obsolete
, 0 }, /* En */
186 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dx */
187 { in_line_eoln
, 0 }, /* %Q */
188 { in_line_eoln
, 0 }, /* br */
189 { in_line_eoln
, 0 }, /* sp */
190 { in_line_eoln
, 0 }, /* %U */
191 { phrase_ta
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ta */
194 const struct mdoc_macro
* const mdoc_macros
= __mdoc_macros
;
198 * This is called at the end of parsing. It must traverse up the tree,
199 * closing out open [implicit] scopes. Obviously, open explicit scopes
203 mdoc_macroend(struct mdoc
*m
)
207 /* Scan for open explicit scopes. */
209 n
= MDOC_VALID
& m
->last
->flags
? m
->last
->parent
: m
->last
;
211 for ( ; n
; n
= n
->parent
)
212 if (MDOC_BLOCK
== n
->type
&&
213 MDOC_EXPLICIT
& mdoc_macros
[n
->tok
].flags
)
214 mdoc_nmsg(m
, n
, MANDOCERR_SCOPEEXIT
);
216 /* Rewind to the first. */
218 return(rew_last(m
, m
->first
));
223 * Look up a macro from within a subsequent context.
226 lookup(enum mdoct from
, const char *p
)
228 /* FIXME: make -diag lists be un-PARSED. */
230 if ( ! (MDOC_PARSED
& mdoc_macros
[from
].flags
))
232 return(lookup_raw(p
));
237 * Lookup a macro following the initial line macro.
240 lookup_raw(const char *p
)
244 if (MDOC_MAX
== (res
= mdoc_hash_find(p
)))
246 if (MDOC_CALLABLE
& mdoc_macros
[res
].flags
)
253 rew_last(struct mdoc
*mdoc
, const struct mdoc_node
*to
)
255 struct mdoc_node
*n
, *np
;
258 mdoc
->next
= MDOC_NEXT_SIBLING
;
261 while (mdoc
->last
!= to
) {
263 * Save the parent here, because we may delete the
264 * m->last node in the post-validation phase and reset
265 * it to m->last->parent, causing a step in the closing
268 np
= mdoc
->last
->parent
;
269 if ( ! mdoc_valid_post(mdoc
))
274 mdoc
->last
->last
= n
;
277 return(mdoc_valid_post(mdoc
));
282 * For a block closing macro, return the corresponding opening one.
283 * Otherwise, return the macro itself.
286 rew_alt(enum mdoct tok
)
329 * Rewinding to tok, how do we have to handle *p?
330 * REWIND_NONE: *p would delimit tok, but no tok scope is open
331 * inside *p, so there is no need to rewind anything at all.
332 * REWIND_THIS: *p matches tok, so rewind *p and nothing else.
333 * REWIND_MORE: *p is implicit, rewind it and keep searching for tok.
334 * REWIND_FORCE: *p is explicit, but tok is full, force rewinding *p.
335 * REWIND_LATER: *p is explicit and still open, postpone rewinding.
336 * REWIND_ERROR: No tok block is open at all.
339 rew_dohalt(enum mdoct tok
, enum mdoc_type type
,
340 const struct mdoc_node
*p
)
344 * No matching token, no delimiting block, no broken block.
345 * This can happen when full implicit macros are called for
346 * the first time but try to rewind their previous
349 if (MDOC_ROOT
== p
->type
)
350 return(MDOC_BLOCK
== type
&&
351 MDOC_EXPLICIT
& mdoc_macros
[tok
].flags
?
352 REWIND_ERROR
: REWIND_NONE
);
355 * When starting to rewind, skip plain text
356 * and nodes that have already been rewound.
358 if (MDOC_TEXT
== p
->type
|| MDOC_VALID
& p
->flags
)
362 * The easiest case: Found a matching token.
363 * This applies to both blocks and elements.
367 return(p
->end
? REWIND_NONE
:
368 type
== p
->type
? REWIND_THIS
: REWIND_MORE
);
371 * While elements do require rewinding for themselves,
372 * they never affect rewinding of other nodes.
374 if (MDOC_ELEM
== p
->type
)
378 * Blocks delimited by our target token get REWIND_MORE.
379 * Blocks delimiting our target token get REWIND_NONE.
383 if (MDOC_It
== p
->tok
)
387 if (MDOC_BODY
== p
->type
&& MDOC_Bl
== p
->tok
)
391 * XXX Badly nested block handling still fails badly
392 * when one block is breaking two blocks of the same type.
393 * This is an incomplete and extremely ugly workaround,
394 * required to let the OpenBSD tree build.
397 if (MDOC_Op
== p
->tok
)
405 if (MDOC_BODY
== p
->type
&& MDOC_Sh
== p
->tok
)
409 if (MDOC_Nd
== p
->tok
|| MDOC_Ss
== p
->tok
||
418 * Default block rewinding rules.
419 * In particular, always skip block end markers,
420 * and let all blocks rewind Nm children.
422 if (ENDBODY_NOT
!= p
->end
|| MDOC_Nm
== p
->tok
||
423 (MDOC_BLOCK
== p
->type
&&
424 ! (MDOC_EXPLICIT
& mdoc_macros
[tok
].flags
)))
428 * By default, closing out full blocks
429 * forces closing of broken explicit blocks,
430 * while closing out partial blocks
431 * allows delayed rewinding by default.
433 return (&blk_full
== mdoc_macros
[tok
].fp
?
434 REWIND_FORCE
: REWIND_LATER
);
439 rew_elem(struct mdoc
*mdoc
, enum mdoct tok
)
444 if (MDOC_ELEM
!= n
->type
)
446 assert(MDOC_ELEM
== n
->type
);
447 assert(tok
== n
->tok
);
449 return(rew_last(mdoc
, n
));
454 * We are trying to close a block identified by tok,
455 * but the child block *broken is still open.
456 * Thus, postpone closing the tok block
457 * until the rew_sub call closing *broken.
460 make_pending(struct mdoc_node
*broken
, enum mdoct tok
,
461 struct mdoc
*m
, int line
, int ppos
)
463 struct mdoc_node
*breaker
;
466 * Iterate backwards, searching for the block matching tok,
467 * that is, the block breaking the *broken block.
469 for (breaker
= broken
->parent
; breaker
; breaker
= breaker
->parent
) {
472 * If the *broken block had already been broken before
473 * and we encounter its breaker, make the tok block
474 * pending on the inner breaker.
475 * Graphically, "[A breaker=[B broken=[C->B B] tok=A] C]"
476 * becomes "[A broken=[B [C->B B] tok=A] C]"
477 * and finally "[A [B->A [C->B B] A] C]".
479 if (breaker
== broken
->pending
) {
484 if (REWIND_THIS
!= rew_dohalt(tok
, MDOC_BLOCK
, breaker
))
486 if (MDOC_BODY
== broken
->type
)
487 broken
= broken
->parent
;
491 * If another, outer breaker is already pending on
492 * the *broken block, we must not clobber the link
493 * to the outer breaker, but make it pending on the
494 * new, now inner breaker.
495 * Graphically, "[A breaker=[B broken=[C->A A] tok=B] C]"
496 * becomes "[A breaker=[B->A broken=[C A] tok=B] C]"
497 * and finally "[A [B->A [C->B A] B] C]".
499 if (broken
->pending
) {
500 struct mdoc_node
*taker
;
503 * If the breaker had also been broken before,
504 * it cannot take on the outer breaker itself,
505 * but must hand it on to its own breakers.
506 * Graphically, this is the following situation:
507 * "[A [B breaker=[C->B B] broken=[D->A A] tok=C] D]"
508 * "[A taker=[B->A breaker=[C->B B] [D->C A] C] D]"
511 while (taker
->pending
)
512 taker
= taker
->pending
;
513 taker
->pending
= broken
->pending
;
515 broken
->pending
= breaker
;
516 mdoc_vmsg(m
, MANDOCERR_SCOPENEST
, line
, ppos
,
517 "%s breaks %s", mdoc_macronames
[tok
],
518 mdoc_macronames
[broken
->tok
]);
523 * Found no matching block for tok.
524 * Are you trying to close a block that is not open?
531 rew_sub(enum mdoc_type t
, struct mdoc
*m
,
532 enum mdoct tok
, int line
, int ppos
)
538 switch (rew_dohalt(tok
, t
, n
)) {
544 mdoc_vmsg(m
, MANDOCERR_SCOPEBROKEN
, line
, ppos
,
545 "%s breaks %s", mdoc_macronames
[tok
],
546 mdoc_macronames
[n
->tok
]);
552 if (make_pending(n
, tok
, m
, line
, ppos
) ||
557 mdoc_pmsg(m
, line
, ppos
, MANDOCERR_NOSCOPE
);
564 if ( ! rew_last(m
, n
))
568 * The current block extends an enclosing block.
569 * Now that the current block ends, close the enclosing block, too.
571 while (NULL
!= (n
= n
->pending
)) {
572 if ( ! rew_last(m
, n
))
574 if (MDOC_HEAD
== n
->type
&&
575 ! mdoc_body_alloc(m
, n
->line
, n
->pos
, n
->tok
))
584 append_delims(struct mdoc
*m
, int line
, int *pos
, char *buf
)
590 if ('\0' == buf
[*pos
])
595 ac
= mdoc_zargs(m
, line
, pos
, buf
, ARGS_NOWARN
, &p
);
597 if (ARGS_ERROR
== ac
)
599 else if (ARGS_EOLN
== ac
)
602 assert(DELIM_NONE
!= mdoc_isdelim(p
));
603 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
607 * If we encounter end-of-sentence symbols, then trigger
610 * XXX: it's easy to allow this to propogate outward to
611 * the last symbol, such that `. )' will cause the
612 * correct double-spacing. However, (1) groff isn't
613 * smart enough to do this and (2) it would require
614 * knowing which symbols break this behaviour, for
615 * example, `. ;' shouldn't propogate the double-space.
617 if (mandoc_eos(p
, strlen(p
), 0))
618 m
->last
->flags
|= MDOC_EOS
;
626 * Close out block partial/full explicit.
629 blk_exp_close(MACRO_PROT_ARGS
)
631 struct mdoc_node
*body
; /* Our own body. */
632 struct mdoc_node
*later
; /* A sub-block starting later. */
633 struct mdoc_node
*n
; /* For searching backwards. */
635 int j
, lastarg
, maxargs
, flushed
, nl
;
637 enum mdoct atok
, ntok
;
640 nl
= MDOC_NEWLINE
& m
->flags
;
652 * Search backwards for beginnings of blocks,
653 * both of our own and of pending sub-blocks.
657 for (n
= m
->last
; n
; n
= n
->parent
) {
658 if (MDOC_VALID
& n
->flags
)
661 /* Remember the start of our own body. */
662 if (MDOC_BODY
== n
->type
&& atok
== n
->tok
) {
663 if (ENDBODY_NOT
== n
->end
)
668 if (MDOC_BLOCK
!= n
->type
|| MDOC_Nm
== n
->tok
)
670 if (atok
== n
->tok
) {
674 * Found the start of our own block.
675 * When there is no pending sub block,
676 * just proceed to closing out.
682 * When there is a pending sub block,
683 * postpone closing out the current block
684 * until the rew_sub() closing out the sub-block.
686 make_pending(later
, tok
, m
, line
, ppos
);
689 * Mark the place where the formatting - but not
690 * the scope - of the current block ends.
692 if ( ! mdoc_endbody_alloc(m
, line
, ppos
,
693 atok
, body
, ENDBODY_SPACE
))
699 * When finding an open sub block, remember the last
700 * open explicit block, or, in case there are only
701 * implicit ones, the first open implicit block.
704 MDOC_EXPLICIT
& mdoc_macros
[later
->tok
].flags
)
706 if (MDOC_CALLABLE
& mdoc_macros
[n
->tok
].flags
)
710 if ( ! (MDOC_CALLABLE
& mdoc_macros
[tok
].flags
)) {
711 /* FIXME: do this in validate */
713 if ( ! mdoc_pmsg(m
, line
, ppos
, MANDOCERR_ARGSLOST
))
716 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
718 return(rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
));
721 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
724 if (NULL
== later
&& maxargs
> 0)
725 if ( ! mdoc_tail_alloc(m
, line
, ppos
, rew_alt(tok
)))
728 for (flushed
= j
= 0; ; j
++) {
731 if (j
== maxargs
&& ! flushed
) {
732 if ( ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
737 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
739 if (ARGS_ERROR
== ac
)
741 if (ARGS_PUNCT
== ac
)
746 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
748 if (MDOC_MAX
== ntok
) {
749 if ( ! mdoc_word_alloc(m
, line
, lastarg
, p
))
755 if ( ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
759 if ( ! mdoc_macro(m
, ntok
, line
, lastarg
, pos
, buf
))
764 if ( ! flushed
&& ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
769 return(append_delims(m
, line
, pos
, buf
));
774 in_line(MACRO_PROT_ARGS
)
776 int la
, scope
, cnt
, nc
, nl
;
781 struct mdoc_arg
*arg
;
784 nl
= MDOC_NEWLINE
& m
->flags
;
787 * Whether we allow ignored elements (those without content,
788 * usually because of reserved words) to squeak by.
810 for (arg
= NULL
;; ) {
812 av
= mdoc_argv(m
, line
, tok
, &arg
, pos
, buf
);
814 if (ARGV_WORD
== av
) {
827 for (cnt
= scope
= 0;; ) {
829 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
831 if (ARGS_ERROR
== ac
)
835 if (ARGS_PUNCT
== ac
)
838 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
841 * In this case, we've located a submacro and must
842 * execute it. Close out scope, if open. If no
843 * elements have been generated, either create one (nc)
844 * or raise a warning.
847 if (MDOC_MAX
!= ntok
) {
848 if (scope
&& ! rew_elem(m
, tok
))
850 if (nc
&& 0 == cnt
) {
851 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
853 if ( ! rew_last(m
, m
->last
))
855 } else if ( ! nc
&& 0 == cnt
) {
857 if ( ! mdoc_pmsg(m
, line
, ppos
, MANDOCERR_MACROEMPTY
))
860 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
864 return(append_delims(m
, line
, pos
, buf
));
868 * Non-quote-enclosed punctuation. Set up our scope, if
869 * a word; rewind the scope, if a delimiter; then append
873 d
= ARGS_QWORD
== ac
? DELIM_NONE
: mdoc_isdelim(p
);
875 if (DELIM_NONE
!= d
) {
877 * If we encounter closing punctuation, no word
878 * has been omitted, no scope is open, and we're
879 * allowed to have an empty element, then start
880 * a new scope. `Ar', `Fl', and `Li', only do
881 * this once per invocation. There may be more
882 * of these (all of them?).
884 if (0 == cnt
&& (nc
|| MDOC_Li
== tok
) &&
885 DELIM_CLOSE
== d
&& ! scope
) {
886 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
888 if (MDOC_Ar
== tok
|| MDOC_Li
== tok
||
894 * Close out our scope, if one is open, before
897 if (scope
&& ! rew_elem(m
, tok
))
900 } else if ( ! scope
) {
901 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
908 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
912 * `Fl' macros have their scope re-opened with each new
913 * word so that the `-' can be added to each one without
914 * having to parse out spaces.
916 if (scope
&& MDOC_Fl
== tok
) {
917 if ( ! rew_elem(m
, tok
))
923 if (scope
&& ! rew_elem(m
, tok
))
927 * If no elements have been collected and we're allowed to have
928 * empties (nc), open a scope and close it out. Otherwise,
932 if (nc
&& 0 == cnt
) {
933 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
935 if ( ! rew_last(m
, m
->last
))
937 } else if ( ! nc
&& 0 == cnt
) {
939 if ( ! mdoc_pmsg(m
, line
, ppos
, MANDOCERR_MACROEMPTY
))
945 return(append_delims(m
, line
, pos
, buf
));
950 blk_full(MACRO_PROT_ARGS
)
953 struct mdoc_arg
*arg
;
954 struct mdoc_node
*head
; /* save of head macro */
955 struct mdoc_node
*body
; /* save of body macro */
959 enum margserr ac
, lac
;
963 nl
= MDOC_NEWLINE
& m
->flags
;
965 /* Close out prior implicit scope. */
967 if ( ! (MDOC_EXPLICIT
& mdoc_macros
[tok
].flags
)) {
968 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
970 if ( ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
975 * This routine accomodates implicitly- and explicitly-scoped
976 * macro openings. Implicit ones first close out prior scope
977 * (seen above). Delay opening the head until necessary to
978 * allow leading punctuation to print. Special consideration
979 * for `It -column', which has phrase-part syntax instead of
980 * regular child nodes.
983 for (arg
= NULL
;; ) {
985 av
= mdoc_argv(m
, line
, tok
, &arg
, pos
, buf
);
987 if (ARGV_WORD
== av
) {
1001 if ( ! mdoc_block_alloc(m
, line
, ppos
, tok
, arg
))
1007 * The `Nd' macro has all arguments in its body: it's a hybrid
1008 * of block partial-explicit and full-implicit. Stupid.
1011 if (MDOC_Nd
== tok
) {
1012 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1015 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1017 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1026 /* Initialise last-phrase-type with ARGS_PEND. */
1027 lac
= ARGS_ERROR
== ac
? ARGS_PEND
: ac
;
1028 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1030 if (ARGS_PUNCT
== ac
)
1033 if (ARGS_ERROR
== ac
)
1036 if (ARGS_EOLN
== ac
) {
1037 if (ARGS_PPHRASE
!= lac
&& ARGS_PHRASE
!= lac
)
1040 * This is necessary: if the last token on a
1041 * line is a `Ta' or tab, then we'll get
1042 * ARGS_EOLN, so we must be smart enough to
1043 * reopen our scope if the last parse was a
1044 * phrase or partial phrase.
1046 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
1048 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1055 * Emit leading punctuation (i.e., punctuation before
1056 * the MDOC_HEAD) for non-phrase types.
1061 ARGS_PHRASE
!= ac
&&
1062 ARGS_PPHRASE
!= ac
&&
1064 DELIM_OPEN
== mdoc_isdelim(p
)) {
1065 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1070 /* Open a head if one hasn't been opened. */
1073 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1078 if (ARGS_PHRASE
== ac
||
1080 ARGS_PPHRASE
== ac
) {
1082 * If we haven't opened a body yet, rewind the
1083 * head; if we have, rewind that instead.
1086 mtt
= body
? MDOC_BODY
: MDOC_HEAD
;
1087 if ( ! rew_sub(mtt
, m
, tok
, line
, ppos
))
1090 /* Then allocate our body context. */
1092 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1097 * Process phrases: set whether we're in a
1098 * partial-phrase (this effects line handling)
1099 * then call down into the phrase parser.
1102 if (ARGS_PPHRASE
== ac
)
1103 m
->flags
|= MDOC_PPHRASE
;
1104 if (ARGS_PEND
== ac
&& ARGS_PPHRASE
== lac
)
1105 m
->flags
|= MDOC_PPHRASE
;
1107 if ( ! phrase(m
, line
, la
, buf
))
1110 m
->flags
&= ~MDOC_PPHRASE
;
1114 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1116 if (MDOC_MAX
== ntok
) {
1117 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1122 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1128 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1133 if (nl
&& ! append_delims(m
, line
, pos
, buf
))
1136 /* If we've already opened our body, exit now. */
1142 * If there is an open (i.e., unvalidated) sub-block requiring
1143 * explicit close-out, postpone switching the current block from
1144 * head to body until the rew_sub() call closing out that
1147 for (n
= m
->last
; n
&& n
!= head
; n
= n
->parent
) {
1148 if (MDOC_BLOCK
== n
->type
&&
1149 MDOC_EXPLICIT
& mdoc_macros
[n
->tok
].flags
&&
1150 ! (MDOC_VALID
& n
->flags
)) {
1156 /* Close out scopes to remain in a consistent state. */
1158 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1160 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1164 if ( ! (MDOC_FREECOL
& m
->flags
))
1167 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
1169 if ( ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
1172 m
->flags
&= ~MDOC_FREECOL
;
1178 blk_part_imp(MACRO_PROT_ARGS
)
1184 struct mdoc_node
*blk
; /* saved block context */
1185 struct mdoc_node
*body
; /* saved body context */
1186 struct mdoc_node
*n
;
1188 nl
= MDOC_NEWLINE
& m
->flags
;
1191 * A macro that spans to the end of the line. This is generally
1192 * (but not necessarily) called as the first macro. The block
1193 * has a head as the immediate child, which is always empty,
1194 * followed by zero or more opening punctuation nodes, then the
1195 * body (which may be empty, depending on the macro), then zero
1196 * or more closing punctuation nodes.
1199 if ( ! mdoc_block_alloc(m
, line
, ppos
, tok
, NULL
))
1204 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1206 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1210 * Open the body scope "on-demand", that is, after we've
1211 * processed all our the leading delimiters (open parenthesis,
1215 for (body
= NULL
; ; ) {
1217 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1219 if (ARGS_ERROR
== ac
)
1221 if (ARGS_EOLN
== ac
)
1223 if (ARGS_PUNCT
== ac
)
1226 if (NULL
== body
&& ARGS_QWORD
!= ac
&&
1227 DELIM_OPEN
== mdoc_isdelim(p
)) {
1228 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1234 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1239 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1241 if (MDOC_MAX
== ntok
) {
1242 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1247 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1252 /* Clean-ups to leave in a consistent state. */
1255 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1260 for (n
= body
->child
; n
&& n
->next
; n
= n
->next
)
1264 * End of sentence spacing: if the last node is a text node and
1265 * has a trailing period, then mark it as being end-of-sentence.
1268 if (n
&& MDOC_TEXT
== n
->type
&& n
->string
)
1269 if (mandoc_eos(n
->string
, strlen(n
->string
), 1))
1270 n
->flags
|= MDOC_EOS
;
1272 /* Up-propogate the end-of-space flag. */
1274 if (n
&& (MDOC_EOS
& n
->flags
)) {
1275 body
->flags
|= MDOC_EOS
;
1276 body
->parent
->flags
|= MDOC_EOS
;
1280 * If there is an open sub-block requiring explicit close-out,
1281 * postpone closing out the current block
1282 * until the rew_sub() call closing out the sub-block.
1284 for (n
= m
->last
; n
&& n
!= body
&& n
!= blk
->parent
; n
= n
->parent
) {
1285 if (MDOC_BLOCK
== n
->type
&&
1286 MDOC_EXPLICIT
& mdoc_macros
[n
->tok
].flags
&&
1287 ! (MDOC_VALID
& n
->flags
)) {
1288 make_pending(n
, tok
, m
, line
, ppos
);
1289 if ( ! mdoc_endbody_alloc(m
, line
, ppos
,
1290 tok
, body
, ENDBODY_NOSPACE
))
1297 * If we can't rewind to our body, then our scope has already
1298 * been closed by another macro (like `Oc' closing `Op'). This
1299 * is ugly behaviour nodding its head to OpenBSD's overwhelming
1300 * crufty use of `Op' breakage.
1302 if (n
!= body
&& ! mdoc_vmsg(m
, MANDOCERR_SCOPENEST
,
1303 line
, ppos
, "%s broken", mdoc_macronames
[tok
]))
1306 if (n
&& ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
1309 /* Standard appending of delimiters. */
1311 if (nl
&& ! append_delims(m
, line
, pos
, buf
))
1314 /* Rewind scope, if applicable. */
1316 if (n
&& ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
1324 blk_part_exp(MACRO_PROT_ARGS
)
1328 struct mdoc_node
*head
; /* keep track of head */
1329 struct mdoc_node
*body
; /* keep track of body */
1333 nl
= MDOC_NEWLINE
& m
->flags
;
1336 * The opening of an explicit macro having zero or more leading
1337 * punctuation nodes; a head with optional single element (the
1338 * case of `Eo'); and a body that may be empty.
1341 if ( ! mdoc_block_alloc(m
, line
, ppos
, tok
, NULL
))
1344 for (head
= body
= NULL
; ; ) {
1346 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1348 if (ARGS_ERROR
== ac
)
1350 if (ARGS_PUNCT
== ac
)
1352 if (ARGS_EOLN
== ac
)
1355 /* Flush out leading punctuation. */
1357 if (NULL
== head
&& ARGS_QWORD
!= ac
&&
1358 DELIM_OPEN
== mdoc_isdelim(p
)) {
1359 assert(NULL
== body
);
1360 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1366 assert(NULL
== body
);
1367 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1373 * `Eo' gobbles any data into the head, but most other
1374 * macros just immediately close out and begin the body.
1379 /* No check whether it's a macro! */
1381 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1384 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1386 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1394 assert(NULL
!= head
&& NULL
!= body
);
1396 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1398 if (MDOC_MAX
== ntok
) {
1399 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1404 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1409 /* Clean-up to leave in a consistent state. */
1412 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1418 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1420 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1425 /* Standard appending of delimiters. */
1429 return(append_delims(m
, line
, pos
, buf
));
1435 in_line_argn(MACRO_PROT_ARGS
)
1437 int la
, flushed
, j
, maxargs
, nl
;
1440 struct mdoc_arg
*arg
;
1444 nl
= MDOC_NEWLINE
& m
->flags
;
1447 * A line macro that has a fixed number of arguments (maxargs).
1448 * Only open the scope once the first non-leading-punctuation is
1449 * found (unless MDOC_IGNDELIM is noted, like in `Pf'), then
1450 * keep it open until the maximum number of arguments are
1474 for (arg
= NULL
; ; ) {
1476 av
= mdoc_argv(m
, line
, tok
, &arg
, pos
, buf
);
1478 if (ARGV_WORD
== av
) {
1483 if (ARGV_EOLN
== av
)
1488 mdoc_argv_free(arg
);
1492 for (flushed
= j
= 0; ; ) {
1494 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1496 if (ARGS_ERROR
== ac
)
1498 if (ARGS_PUNCT
== ac
)
1500 if (ARGS_EOLN
== ac
)
1503 if ( ! (MDOC_IGNDELIM
& mdoc_macros
[tok
].flags
) &&
1505 0 == j
&& DELIM_OPEN
== mdoc_isdelim(p
)) {
1506 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1510 if ( ! mdoc_elem_alloc(m
, line
, la
, tok
, arg
))
1513 if (j
== maxargs
&& ! flushed
) {
1514 if ( ! rew_elem(m
, tok
))
1519 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1521 if (MDOC_MAX
!= ntok
) {
1522 if ( ! flushed
&& ! rew_elem(m
, tok
))
1525 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1531 if ( ! (MDOC_IGNDELIM
& mdoc_macros
[tok
].flags
) &&
1534 DELIM_NONE
!= mdoc_isdelim(p
)) {
1535 if ( ! rew_elem(m
, tok
))
1541 * XXX: this is a hack to work around groff's ugliness
1542 * as regards `Xr' and extraneous arguments. It should
1543 * ideally be deprecated behaviour, but because this is
1544 * code is no here, it's unlikely to be removed.
1548 if (MDOC_Xr
== tok
&& j
== maxargs
) {
1549 if ( ! mdoc_elem_alloc(m
, line
, la
, MDOC_Ns
, NULL
))
1551 if ( ! rew_elem(m
, MDOC_Ns
))
1556 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1561 if (0 == j
&& ! mdoc_elem_alloc(m
, line
, la
, tok
, arg
))
1564 /* Close out in a consistent state. */
1566 if ( ! flushed
&& ! rew_elem(m
, tok
))
1570 return(append_delims(m
, line
, pos
, buf
));
1575 in_line_eoln(MACRO_PROT_ARGS
)
1580 struct mdoc_arg
*arg
;
1584 assert( ! (MDOC_PARSED
& mdoc_macros
[tok
].flags
));
1587 rew_sub(MDOC_BLOCK
, m
, MDOC_Nm
, line
, ppos
);
1589 /* Parse macro arguments. */
1591 for (arg
= NULL
; ; ) {
1593 av
= mdoc_argv(m
, line
, tok
, &arg
, pos
, buf
);
1595 if (ARGV_WORD
== av
) {
1599 if (ARGV_EOLN
== av
)
1604 mdoc_argv_free(arg
);
1608 /* Open element scope. */
1610 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
1613 /* Parse argument terms. */
1617 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1619 if (ARGS_ERROR
== ac
)
1621 if (ARGS_EOLN
== ac
)
1624 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1626 if (MDOC_MAX
== ntok
) {
1627 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1632 if ( ! rew_elem(m
, tok
))
1634 return(mdoc_macro(m
, ntok
, line
, la
, pos
, buf
));
1637 /* Close out (no delimiters). */
1639 return(rew_elem(m
, tok
));
1645 ctx_synopsis(MACRO_PROT_ARGS
)
1649 nl
= MDOC_NEWLINE
& m
->flags
;
1651 /* If we're not in the SYNOPSIS, go straight to in-line. */
1652 if ( ! (MDOC_SYNOPSIS
& m
->flags
))
1653 return(in_line(m
, tok
, line
, ppos
, pos
, buf
));
1655 /* If we're a nested call, same place. */
1657 return(in_line(m
, tok
, line
, ppos
, pos
, buf
));
1660 * XXX: this will open a block scope; however, if later we end
1661 * up formatting the block scope, then child nodes will inherit
1662 * the formatting. Be careful.
1665 return(blk_full(m
, tok
, line
, ppos
, pos
, buf
));
1666 assert(MDOC_Vt
== tok
);
1667 return(blk_part_imp(m
, tok
, line
, ppos
, pos
, buf
));
1673 obsolete(MACRO_PROT_ARGS
)
1676 return(mdoc_pmsg(m
, line
, ppos
, MANDOCERR_MACROOBS
));
1681 * Phrases occur within `Bl -column' entries, separated by `Ta' or tabs.
1682 * They're unusual because they're basically free-form text until a
1683 * macro is encountered.
1686 phrase(struct mdoc
*m
, int line
, int ppos
, char *buf
)
1693 for (pos
= ppos
; ; ) {
1696 ac
= mdoc_zargs(m
, line
, &pos
, buf
, 0, &p
);
1698 if (ARGS_ERROR
== ac
)
1700 if (ARGS_EOLN
== ac
)
1703 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup_raw(p
);
1705 if (MDOC_MAX
== ntok
) {
1706 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1711 if ( ! mdoc_macro(m
, ntok
, line
, la
, &pos
, buf
))
1713 return(append_delims(m
, line
, &pos
, buf
));
1722 phrase_ta(MACRO_PROT_ARGS
)
1730 * FIXME: this is overly restrictive: if the `Ta' is unexpected,
1731 * it should simply error out with ARGSLOST.
1734 if ( ! rew_sub(MDOC_BODY
, m
, MDOC_It
, line
, ppos
))
1736 if ( ! mdoc_body_alloc(m
, line
, ppos
, MDOC_It
))
1741 ac
= mdoc_zargs(m
, line
, pos
, buf
, 0, &p
);
1743 if (ARGS_ERROR
== ac
)
1745 if (ARGS_EOLN
== ac
)
1748 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup_raw(p
);
1750 if (MDOC_MAX
== ntok
) {
1751 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1756 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1758 return(append_delims(m
, line
, pos
, buf
));