]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc_macro.c
1 /* $Id: mdoc_macro.c,v 1.86 2010/06/30 04:05:02 schwarze Exp $ */
3 * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30 #include "libmandoc.h"
32 enum rew
{ /* see rew_dohalt() */
40 static int blk_full(MACRO_PROT_ARGS
);
41 static int blk_exp_close(MACRO_PROT_ARGS
);
42 static int blk_part_exp(MACRO_PROT_ARGS
);
43 static int blk_part_imp(MACRO_PROT_ARGS
);
44 static int ctx_synopsis(MACRO_PROT_ARGS
);
45 static int in_line_eoln(MACRO_PROT_ARGS
);
46 static int in_line_argn(MACRO_PROT_ARGS
);
47 static int in_line(MACRO_PROT_ARGS
);
48 static int obsolete(MACRO_PROT_ARGS
);
49 static int phrase_ta(MACRO_PROT_ARGS
);
51 static int append_delims(struct mdoc
*,
53 static enum mdoct
lookup(enum mdoct
, const char *);
54 static enum mdoct
lookup_raw(const char *);
55 static int make_pending(struct mdoc_node
*, enum mdoct
,
56 struct mdoc
*, int, int);
57 static int phrase(struct mdoc
*, int, int, char *);
58 static enum mdoct
rew_alt(enum mdoct
);
59 static enum rew
rew_dohalt(enum mdoct
, enum mdoc_type
,
60 const struct mdoc_node
*);
61 static int rew_elem(struct mdoc
*, enum mdoct
);
62 static int rew_last(struct mdoc
*,
63 const struct mdoc_node
*);
64 static int rew_sub(enum mdoc_type
, struct mdoc
*,
65 enum mdoct
, int, int);
67 const struct mdoc_macro __mdoc_macros
[MDOC_MAX
] = {
68 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ap */
69 { in_line_eoln
, MDOC_PROLOGUE
}, /* Dd */
70 { in_line_eoln
, MDOC_PROLOGUE
}, /* Dt */
71 { in_line_eoln
, MDOC_PROLOGUE
}, /* Os */
72 { blk_full
, 0 }, /* Sh */
73 { blk_full
, 0 }, /* Ss */
74 { in_line_eoln
, 0 }, /* Pp */
75 { blk_part_imp
, MDOC_PARSED
}, /* D1 */
76 { blk_part_imp
, MDOC_PARSED
}, /* Dl */
77 { blk_full
, MDOC_EXPLICIT
}, /* Bd */
78 { blk_exp_close
, MDOC_EXPLICIT
}, /* Ed */
79 { blk_full
, MDOC_EXPLICIT
}, /* Bl */
80 { blk_exp_close
, MDOC_EXPLICIT
}, /* El */
81 { blk_full
, MDOC_PARSED
}, /* It */
82 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ad */
83 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* An */
84 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ar */
85 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Cd */
86 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Cm */
87 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dv */
88 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Er */
89 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ev */
90 { in_line_eoln
, 0 }, /* Ex */
91 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fa */
92 { in_line_eoln
, 0 }, /* Fd */
93 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fl */
94 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fn */
95 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ft */
96 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ic */
97 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* In */
98 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Li */
99 { blk_full
, 0 }, /* Nd */
100 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nm */
101 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Op */
102 { obsolete
, 0 }, /* Ot */
103 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Pa */
104 { in_line_eoln
, 0 }, /* Rv */
105 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* St */
106 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Va */
107 { ctx_synopsis
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Vt */
108 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Xr */
109 { in_line_eoln
, 0 }, /* %A */
110 { in_line_eoln
, 0 }, /* %B */
111 { in_line_eoln
, 0 }, /* %D */
112 { in_line_eoln
, 0 }, /* %I */
113 { in_line_eoln
, 0 }, /* %J */
114 { in_line_eoln
, 0 }, /* %N */
115 { in_line_eoln
, 0 }, /* %O */
116 { in_line_eoln
, 0 }, /* %P */
117 { in_line_eoln
, 0 }, /* %R */
118 { in_line_eoln
, 0 }, /* %T */
119 { in_line_eoln
, 0 }, /* %V */
120 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Ac */
121 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Ao */
122 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Aq */
123 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* At */
124 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Bc */
125 { blk_full
, MDOC_EXPLICIT
}, /* Bf */
126 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Bo */
127 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bq */
128 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bsx */
129 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Bx */
130 { in_line_eoln
, 0 }, /* Db */
131 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Dc */
132 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Do */
133 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dq */
134 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Ec */
135 { blk_exp_close
, MDOC_EXPLICIT
}, /* Ef */
136 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Em */
137 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Eo */
138 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Fx */
139 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ms */
140 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* No */
141 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ns */
142 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Nx */
143 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ox */
144 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Pc */
145 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_IGNDELIM
}, /* Pf */
146 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Po */
147 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Pq */
148 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Qc */
149 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ql */
150 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Qo */
151 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Qq */
152 { blk_exp_close
, MDOC_EXPLICIT
}, /* Re */
153 { blk_full
, MDOC_EXPLICIT
}, /* Rs */
154 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Sc */
155 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* So */
156 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Sq */
157 { in_line_eoln
, 0 }, /* Sm */
158 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Sx */
159 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Sy */
160 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Tn */
161 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ux */
162 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Xc */
163 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Xo */
164 { blk_full
, MDOC_EXPLICIT
| MDOC_CALLABLE
}, /* Fo */
165 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Fc */
166 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Oo */
167 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Oc */
168 { blk_full
, MDOC_EXPLICIT
}, /* Bk */
169 { blk_exp_close
, MDOC_EXPLICIT
}, /* Ek */
170 { in_line_eoln
, 0 }, /* Bt */
171 { in_line_eoln
, 0 }, /* Hf */
172 { obsolete
, 0 }, /* Fr */
173 { in_line_eoln
, 0 }, /* Ud */
174 { in_line
, 0 }, /* Lb */
175 { in_line_eoln
, 0 }, /* Lp */
176 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Lk */
177 { in_line
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Mt */
178 { blk_part_imp
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Brq */
179 { blk_part_exp
, MDOC_CALLABLE
| MDOC_PARSED
| MDOC_EXPLICIT
}, /* Bro */
180 { blk_exp_close
, MDOC_EXPLICIT
| MDOC_CALLABLE
| MDOC_PARSED
}, /* Brc */
181 { in_line_eoln
, 0 }, /* %C */
182 { obsolete
, 0 }, /* Es */
183 { obsolete
, 0 }, /* En */
184 { in_line_argn
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Dx */
185 { in_line_eoln
, 0 }, /* %Q */
186 { in_line_eoln
, 0 }, /* br */
187 { in_line_eoln
, 0 }, /* sp */
188 { in_line_eoln
, 0 }, /* %U */
189 { phrase_ta
, MDOC_CALLABLE
| MDOC_PARSED
}, /* Ta */
192 const struct mdoc_macro
* const mdoc_macros
= __mdoc_macros
;
196 * This is called at the end of parsing. It must traverse up the tree,
197 * closing out open [implicit] scopes. Obviously, open explicit scopes
201 mdoc_macroend(struct mdoc
*m
)
205 /* Scan for open explicit scopes. */
207 n
= MDOC_VALID
& m
->last
->flags
? m
->last
->parent
: m
->last
;
209 for ( ; n
; n
= n
->parent
) {
210 if (MDOC_BLOCK
!= n
->type
)
212 if ( ! (MDOC_EXPLICIT
& mdoc_macros
[n
->tok
].flags
))
214 mdoc_nmsg(m
, n
, MANDOCERR_SYNTSCOPE
);
218 /* Rewind to the first. */
220 return(rew_last(m
, m
->first
));
225 * Look up a macro from within a subsequent context.
228 lookup(enum mdoct from
, const char *p
)
230 /* FIXME: make -diag lists be un-PARSED. */
232 if ( ! (MDOC_PARSED
& mdoc_macros
[from
].flags
))
234 return(lookup_raw(p
));
239 * Lookup a macro following the initial line macro.
242 lookup_raw(const char *p
)
246 if (MDOC_MAX
== (res
= mdoc_hash_find(p
)))
248 if (MDOC_CALLABLE
& mdoc_macros
[res
].flags
)
255 rew_last(struct mdoc
*mdoc
, const struct mdoc_node
*to
)
259 mdoc
->next
= MDOC_NEXT_SIBLING
;
262 while (mdoc
->last
!= to
) {
263 if ( ! mdoc_valid_post(mdoc
))
265 if ( ! mdoc_action_post(mdoc
))
267 mdoc
->last
= mdoc
->last
->parent
;
271 if ( ! mdoc_valid_post(mdoc
))
273 return(mdoc_action_post(mdoc
));
278 * For a block closing macro, return the corresponding opening one.
279 * Otherwise, return the macro itself.
282 rew_alt(enum mdoct tok
)
325 * Rewinding to tok, how do we have to handle *p?
326 * REWIND_NONE: *p would delimit tok, but no tok scope is open
327 * inside *p, so there is no need to rewind anything at all.
328 * REWIND_THIS: *p matches tok, so rewind *p and nothing else.
329 * REWIND_MORE: *p is implicit, rewind it and keep searching for tok.
330 * REWIND_LATER: *p is explicit and still open, postpone rewinding.
331 * REWIND_ERROR: No tok block is open at all.
334 rew_dohalt(enum mdoct tok
, enum mdoc_type type
,
335 const struct mdoc_node
*p
)
339 * No matching token, no delimiting block, no broken block.
340 * This can happen when full implicit macros are called for
341 * the first time but try to rewind their previous
344 if (MDOC_ROOT
== p
->type
)
345 return(MDOC_BLOCK
== type
&&
346 MDOC_EXPLICIT
& mdoc_macros
[tok
].flags
?
347 REWIND_ERROR
: REWIND_NONE
);
350 * When starting to rewind, skip plain text
351 * and nodes that have already been rewound.
353 if (MDOC_TEXT
== p
->type
|| MDOC_VALID
& p
->flags
)
357 * The easiest case: Found a matching token.
358 * This applies to both blocks and elements.
362 return(p
->end
? REWIND_NONE
:
363 type
== p
->type
? REWIND_THIS
: REWIND_MORE
);
366 * While elements do require rewinding for themselves,
367 * they never affect rewinding of other nodes.
369 if (MDOC_ELEM
== p
->type
)
373 * Blocks delimited by our target token get REWIND_MORE.
374 * Blocks delimiting our target token get REWIND_NONE.
378 if (MDOC_It
== p
->tok
)
382 if (MDOC_BODY
== p
->type
&& MDOC_Bl
== p
->tok
)
386 * XXX Badly nested block handling still fails badly
387 * when one block is breaking two blocks of the same type.
388 * This is an incomplete and extremely ugly workaround,
389 * required to let the OpenBSD tree build.
392 if (MDOC_Op
== p
->tok
)
398 if (MDOC_BODY
== p
->type
&& MDOC_Sh
== p
->tok
)
402 if (MDOC_Nd
== p
->tok
|| MDOC_Ss
== p
->tok
||
411 * Default block rewinding rules.
412 * In particular, always skip block end markers.
414 if (p
->end
|| (MDOC_BLOCK
== p
->type
&&
415 ! (MDOC_EXPLICIT
& mdoc_macros
[tok
].flags
)))
419 * Partial blocks allow delayed rewinding by default.
421 if (&blk_full
!= mdoc_macros
[tok
].fp
)
422 return (REWIND_LATER
);
425 * Full blocks can only be rewound when matching
426 * or when there is an explicit rule.
428 return(REWIND_ERROR
);
433 rew_elem(struct mdoc
*mdoc
, enum mdoct tok
)
438 if (MDOC_ELEM
!= n
->type
)
440 assert(MDOC_ELEM
== n
->type
);
441 assert(tok
== n
->tok
);
443 return(rew_last(mdoc
, n
));
448 * We are trying to close a block identified by tok,
449 * but the child block *broken is still open.
450 * Thus, postpone closing the tok block
451 * until the rew_sub call closing *broken.
454 make_pending(struct mdoc_node
*broken
, enum mdoct tok
,
455 struct mdoc
*m
, int line
, int ppos
)
457 struct mdoc_node
*breaker
;
460 * Iterate backwards, searching for the block matching tok,
461 * that is, the block breaking the *broken block.
463 for (breaker
= broken
->parent
; breaker
; breaker
= breaker
->parent
) {
466 * If the *broken block had already been broken before
467 * and we encounter its breaker, make the tok block
468 * pending on the inner breaker.
469 * Graphically, "[A breaker=[B broken=[C->B B] tok=A] C]"
470 * becomes "[A broken=[B [C->B B] tok=A] C]"
471 * and finally "[A [B->A [C->B B] A] C]".
473 if (breaker
== broken
->pending
) {
478 if (REWIND_THIS
!= rew_dohalt(tok
, MDOC_BLOCK
, breaker
))
480 if (MDOC_BODY
== broken
->type
)
481 broken
= broken
->parent
;
485 * If another, outer breaker is already pending on
486 * the *broken block, we must not clobber the link
487 * to the outer breaker, but make it pending on the
488 * new, now inner breaker.
489 * Graphically, "[A breaker=[B broken=[C->A A] tok=B] C]"
490 * becomes "[A breaker=[B->A broken=[C A] tok=B] C]"
491 * and finally "[A [B->A [C->B A] B] C]".
493 if (broken
->pending
) {
494 struct mdoc_node
*taker
;
497 * If the breaker had also been broken before,
498 * it cannot take on the outer breaker itself,
499 * but must hand it on to its own breakers.
500 * Graphically, this is the following situation:
501 * "[A [B breaker=[C->B B] broken=[D->A A] tok=C] D]"
502 * "[A taker=[B->A breaker=[C->B B] [D->C A] C] D]"
505 while (taker
->pending
)
506 taker
= taker
->pending
;
507 taker
->pending
= broken
->pending
;
509 broken
->pending
= breaker
;
510 mdoc_vmsg(m
, MANDOCERR_SCOPE
, line
, ppos
, "%s breaks %s",
511 mdoc_macronames
[tok
], mdoc_macronames
[broken
->tok
]);
516 * Found no matching block for tok.
517 * Are you trying to close a block that is not open?
518 * XXX Make this non-fatal.
520 mdoc_pmsg(m
, line
, ppos
, MANDOCERR_SYNTNOSCOPE
);
526 rew_sub(enum mdoc_type t
, struct mdoc
*m
,
527 enum mdoct tok
, int line
, int ppos
)
533 switch (rew_dohalt(tok
, t
, n
)) {
542 return(make_pending(n
, tok
, m
, line
, ppos
));
544 /* XXX Make this non-fatal. */
545 mdoc_pmsg(m
, line
, ppos
, MANDOCERR_SYNTNOSCOPE
);
552 if ( ! rew_last(m
, n
))
556 * The current block extends an enclosing block.
557 * Now that the current block ends, close the enclosing block, too.
559 while (NULL
!= (n
= n
->pending
)) {
560 if ( ! rew_last(m
, n
))
562 if (MDOC_HEAD
== n
->type
&&
563 ! mdoc_body_alloc(m
, n
->line
, n
->pos
, n
->tok
))
572 append_delims(struct mdoc
*m
, int line
, int *pos
, char *buf
)
578 if ('\0' == buf
[*pos
])
583 ac
= mdoc_zargs(m
, line
, pos
, buf
, ARGS_NOWARN
, &p
);
585 if (ARGS_ERROR
== ac
)
587 else if (ARGS_EOLN
== ac
)
590 assert(DELIM_NONE
!= mdoc_isdelim(p
));
591 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
595 * If we encounter end-of-sentence symbols, then trigger
598 * XXX: it's easy to allow this to propogate outward to
599 * the last symbol, such that `. )' will cause the
600 * correct double-spacing. However, (1) groff isn't
601 * smart enough to do this and (2) it would require
602 * knowing which symbols break this behaviour, for
603 * example, `. ;' shouldn't propogate the double-space.
605 if (mandoc_eos(p
, strlen(p
)))
606 m
->last
->flags
|= MDOC_EOS
;
614 * Close out block partial/full explicit.
617 blk_exp_close(MACRO_PROT_ARGS
)
619 struct mdoc_node
*body
; /* Our own body. */
620 struct mdoc_node
*later
; /* A sub-block starting later. */
621 struct mdoc_node
*n
; /* For searching backwards. */
623 int j
, lastarg
, maxargs
, flushed
, nl
;
625 enum mdoct atok
, ntok
;
628 nl
= MDOC_NEWLINE
& m
->flags
;
640 * Search backwards for beginnings of blocks,
641 * both of our own and of pending sub-blocks.
645 for (n
= m
->last
; n
; n
= n
->parent
) {
646 if (MDOC_VALID
& n
->flags
)
649 /* Remember the start of our own body. */
650 if (MDOC_BODY
== n
->type
&& atok
== n
->tok
) {
656 if (MDOC_BLOCK
!= n
->type
)
658 if (atok
== n
->tok
) {
662 * Found the start of our own block.
663 * When there is no pending sub block,
664 * just proceed to closing out.
670 * When there is a pending sub block,
671 * postpone closing out the current block
672 * until the rew_sub() closing out the sub-block.
674 if ( ! make_pending(later
, tok
, m
, line
, ppos
))
678 * Mark the place where the formatting - but not
679 * the scope - of the current block ends.
681 if ( ! mdoc_endbody_alloc(m
, line
, ppos
,
682 atok
, body
, ENDBODY_SPACE
))
688 * When finding an open sub block, remember the last
689 * open explicit block, or, in case there are only
690 * implicit ones, the first open implicit block.
693 MDOC_EXPLICIT
& mdoc_macros
[later
->tok
].flags
)
695 if (MDOC_CALLABLE
& mdoc_macros
[n
->tok
].flags
) {
696 assert( ! (MDOC_ACTED
& n
->flags
));
701 if ( ! (MDOC_CALLABLE
& mdoc_macros
[tok
].flags
)) {
702 /* FIXME: do this in validate */
704 if ( ! mdoc_pmsg(m
, line
, ppos
, MANDOCERR_ARGSLOST
))
707 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
709 return(rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
));
712 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
715 if (NULL
== later
&& maxargs
> 0)
716 if ( ! mdoc_tail_alloc(m
, line
, ppos
, rew_alt(tok
)))
719 for (flushed
= j
= 0; ; j
++) {
722 if (j
== maxargs
&& ! flushed
) {
723 if ( ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
728 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
730 if (ARGS_ERROR
== ac
)
732 if (ARGS_PUNCT
== ac
)
737 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
739 if (MDOC_MAX
== ntok
) {
740 if ( ! mdoc_word_alloc(m
, line
, lastarg
, p
))
746 if ( ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
750 if ( ! mdoc_macro(m
, ntok
, line
, lastarg
, pos
, buf
))
755 if ( ! flushed
&& ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
760 return(append_delims(m
, line
, pos
, buf
));
765 in_line(MACRO_PROT_ARGS
)
767 int la
, scope
, cnt
, nc
, nl
;
772 struct mdoc_arg
*arg
;
775 nl
= MDOC_NEWLINE
& m
->flags
;
778 * Whether we allow ignored elements (those without content,
779 * usually because of reserved words) to squeak by.
801 for (arg
= NULL
;; ) {
803 av
= mdoc_argv(m
, line
, tok
, &arg
, pos
, buf
);
805 if (ARGV_WORD
== av
) {
818 for (cnt
= scope
= 0;; ) {
820 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
822 if (ARGS_ERROR
== ac
)
826 if (ARGS_PUNCT
== ac
)
829 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
832 * In this case, we've located a submacro and must
833 * execute it. Close out scope, if open. If no
834 * elements have been generated, either create one (nc)
835 * or raise a warning.
838 if (MDOC_MAX
!= ntok
) {
839 if (scope
&& ! rew_elem(m
, tok
))
841 if (nc
&& 0 == cnt
) {
842 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
844 if ( ! rew_last(m
, m
->last
))
846 } else if ( ! nc
&& 0 == cnt
) {
848 if ( ! mdoc_pmsg(m
, line
, ppos
, MANDOCERR_MACROEMPTY
))
851 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
855 return(append_delims(m
, line
, pos
, buf
));
859 * Non-quote-enclosed punctuation. Set up our scope, if
860 * a word; rewind the scope, if a delimiter; then append
864 d
= ARGS_QWORD
== ac
? DELIM_NONE
: mdoc_isdelim(p
);
866 if (DELIM_NONE
!= d
) {
868 * If we encounter closing punctuation, no word
869 * has been omitted, no scope is open, and we're
870 * allowed to have an empty element, then start
871 * a new scope. `Ar', `Fl', and `Li', only do
872 * this once per invocation. There may be more
873 * of these (all of them?).
875 if (0 == cnt
&& (nc
|| MDOC_Li
== tok
) &&
876 DELIM_CLOSE
== d
&& ! scope
) {
877 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
879 if (MDOC_Ar
== tok
|| MDOC_Li
== tok
||
885 * Close out our scope, if one is open, before
888 if (scope
&& ! rew_elem(m
, tok
))
891 } else if ( ! scope
) {
892 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
899 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
903 * `Fl' macros have their scope re-opened with each new
904 * word so that the `-' can be added to each one without
905 * having to parse out spaces.
907 if (scope
&& MDOC_Fl
== tok
) {
908 if ( ! rew_elem(m
, tok
))
914 if (scope
&& ! rew_elem(m
, tok
))
918 * If no elements have been collected and we're allowed to have
919 * empties (nc), open a scope and close it out. Otherwise,
923 if (nc
&& 0 == cnt
) {
924 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
926 if ( ! rew_last(m
, m
->last
))
928 } else if ( ! nc
&& 0 == cnt
) {
930 if ( ! mdoc_pmsg(m
, line
, ppos
, MANDOCERR_MACROEMPTY
))
936 return(append_delims(m
, line
, pos
, buf
));
941 blk_full(MACRO_PROT_ARGS
)
944 struct mdoc_arg
*arg
;
945 struct mdoc_node
*head
; /* save of head macro */
946 struct mdoc_node
*body
; /* save of body macro */
950 enum margserr ac
, lac
;
954 nl
= MDOC_NEWLINE
& m
->flags
;
956 /* Close out prior implicit scope. */
958 if ( ! (MDOC_EXPLICIT
& mdoc_macros
[tok
].flags
)) {
959 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
961 if ( ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
966 * This routine accomodates implicitly- and explicitly-scoped
967 * macro openings. Implicit ones first close out prior scope
968 * (seen above). Delay opening the head until necessary to
969 * allow leading punctuation to print. Special consideration
970 * for `It -column', which has phrase-part syntax instead of
971 * regular child nodes.
974 for (arg
= NULL
;; ) {
976 av
= mdoc_argv(m
, line
, tok
, &arg
, pos
, buf
);
978 if (ARGV_WORD
== av
) {
992 if ( ! mdoc_block_alloc(m
, line
, ppos
, tok
, arg
))
998 * The `Nd' macro has all arguments in its body: it's a hybrid
999 * of block partial-explicit and full-implicit. Stupid.
1002 if (MDOC_Nd
== tok
) {
1003 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1006 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1008 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1017 /* Initialise last-phrase-type with ARGS_PEND. */
1018 lac
= ARGS_ERROR
== ac
? ARGS_PEND
: ac
;
1019 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1021 if (ARGS_ERROR
== ac
)
1024 if (ARGS_EOLN
== ac
) {
1025 if (ARGS_PPHRASE
!= lac
&& ARGS_PHRASE
!= lac
)
1028 * This is necessary: if the last token on a
1029 * line is a `Ta' or tab, then we'll get
1030 * ARGS_EOLN, so we must be smart enough to
1031 * reopen our scope if the last parse was a
1032 * phrase or partial phrase.
1034 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
1036 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1043 * Emit leading punctuation (i.e., punctuation before
1044 * the MDOC_HEAD) for non-phrase types.
1049 ARGS_PHRASE
!= ac
&&
1050 ARGS_PPHRASE
!= ac
&&
1052 DELIM_OPEN
== mdoc_isdelim(p
)) {
1053 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1058 /* Open a head if one hasn't been opened. */
1061 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1066 if (ARGS_PHRASE
== ac
||
1068 ARGS_PPHRASE
== ac
) {
1070 * If we haven't opened a body yet, rewind the
1071 * head; if we have, rewind that instead.
1074 mtt
= body
? MDOC_BODY
: MDOC_HEAD
;
1075 if ( ! rew_sub(mtt
, m
, tok
, line
, ppos
))
1078 /* Then allocate our body context. */
1080 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1085 * Process phrases: set whether we're in a
1086 * partial-phrase (this effects line handling)
1087 * then call down into the phrase parser.
1090 if (ARGS_PPHRASE
== ac
)
1091 m
->flags
|= MDOC_PPHRASE
;
1092 if (ARGS_PEND
== ac
&& ARGS_PPHRASE
== lac
)
1093 m
->flags
|= MDOC_PPHRASE
;
1095 if ( ! phrase(m
, line
, la
, buf
))
1098 m
->flags
&= ~MDOC_PPHRASE
;
1102 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1104 if (MDOC_MAX
== ntok
) {
1105 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1110 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1116 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1121 if (nl
&& ! append_delims(m
, line
, pos
, buf
))
1124 /* If we've already opened our body, exit now. */
1130 * If there is an open (i.e., unvalidated) sub-block requiring
1131 * explicit close-out, postpone switching the current block from
1132 * head to body until the rew_sub() call closing out that
1135 for (n
= m
->last
; n
&& n
!= head
; n
= n
->parent
) {
1136 if (MDOC_BLOCK
== n
->type
&&
1137 MDOC_EXPLICIT
& mdoc_macros
[n
->tok
].flags
&&
1138 ! (MDOC_VALID
& n
->flags
)) {
1139 assert( ! (MDOC_ACTED
& n
->flags
));
1145 /* Close out scopes to remain in a consistent state. */
1147 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1149 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1153 if ( ! (MDOC_FREECOL
& m
->flags
))
1156 if ( ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
1158 if ( ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
1161 m
->flags
&= ~MDOC_FREECOL
;
1167 blk_part_imp(MACRO_PROT_ARGS
)
1173 struct mdoc_node
*blk
; /* saved block context */
1174 struct mdoc_node
*body
; /* saved body context */
1175 struct mdoc_node
*n
;
1177 nl
= MDOC_NEWLINE
& m
->flags
;
1180 * A macro that spans to the end of the line. This is generally
1181 * (but not necessarily) called as the first macro. The block
1182 * has a head as the immediate child, which is always empty,
1183 * followed by zero or more opening punctuation nodes, then the
1184 * body (which may be empty, depending on the macro), then zero
1185 * or more closing punctuation nodes.
1188 if ( ! mdoc_block_alloc(m
, line
, ppos
, tok
, NULL
))
1193 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1195 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1199 * Open the body scope "on-demand", that is, after we've
1200 * processed all our the leading delimiters (open parenthesis,
1204 for (body
= NULL
; ; ) {
1206 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1208 if (ARGS_ERROR
== ac
)
1210 if (ARGS_EOLN
== ac
)
1212 if (ARGS_PUNCT
== ac
)
1215 if (NULL
== body
&& ARGS_QWORD
!= ac
&&
1216 DELIM_OPEN
== mdoc_isdelim(p
)) {
1217 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1223 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1228 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1230 if (MDOC_MAX
== ntok
) {
1231 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1236 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1241 /* Clean-ups to leave in a consistent state. */
1244 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1249 for (n
= body
->child
; n
&& n
->next
; n
= n
->next
)
1253 * End of sentence spacing: if the last node is a text node and
1254 * has a trailing period, then mark it as being end-of-sentence.
1257 if (n
&& MDOC_TEXT
== n
->type
&& n
->string
)
1258 if (mandoc_eos(n
->string
, strlen(n
->string
)))
1259 n
->flags
|= MDOC_EOS
;
1261 /* Up-propogate the end-of-space flag. */
1263 if (n
&& (MDOC_EOS
& n
->flags
)) {
1264 body
->flags
|= MDOC_EOS
;
1265 body
->parent
->flags
|= MDOC_EOS
;
1269 * If there is an open sub-block requiring explicit close-out,
1270 * postpone closing out the current block
1271 * until the rew_sub() call closing out the sub-block.
1273 for (n
= m
->last
; n
&& n
!= body
&& n
!= blk
->parent
; n
= n
->parent
) {
1274 if (MDOC_BLOCK
== n
->type
&&
1275 MDOC_EXPLICIT
& mdoc_macros
[n
->tok
].flags
&&
1276 ! (MDOC_VALID
& n
->flags
)) {
1277 assert( ! (MDOC_ACTED
& n
->flags
));
1278 if ( ! make_pending(n
, tok
, m
, line
, ppos
))
1280 if ( ! mdoc_endbody_alloc(m
, line
, ppos
,
1281 tok
, body
, ENDBODY_NOSPACE
))
1288 * If we can't rewind to our body, then our scope has already
1289 * been closed by another macro (like `Oc' closing `Op'). This
1290 * is ugly behaviour nodding its head to OpenBSD's overwhelming
1291 * crufty use of `Op' breakage.
1293 if (n
!= body
&& ! mdoc_vmsg(m
, MANDOCERR_SCOPE
, line
, ppos
,
1294 "%s broken", mdoc_macronames
[tok
]))
1297 if (n
&& ! rew_sub(MDOC_BODY
, m
, tok
, line
, ppos
))
1300 /* Standard appending of delimiters. */
1302 if (nl
&& ! append_delims(m
, line
, pos
, buf
))
1305 /* Rewind scope, if applicable. */
1307 if (n
&& ! rew_sub(MDOC_BLOCK
, m
, tok
, line
, ppos
))
1315 blk_part_exp(MACRO_PROT_ARGS
)
1319 struct mdoc_node
*head
; /* keep track of head */
1320 struct mdoc_node
*body
; /* keep track of body */
1324 nl
= MDOC_NEWLINE
& m
->flags
;
1327 * The opening of an explicit macro having zero or more leading
1328 * punctuation nodes; a head with optional single element (the
1329 * case of `Eo'); and a body that may be empty.
1332 if ( ! mdoc_block_alloc(m
, line
, ppos
, tok
, NULL
))
1335 for (head
= body
= NULL
; ; ) {
1337 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1339 if (ARGS_ERROR
== ac
)
1341 if (ARGS_PUNCT
== ac
)
1343 if (ARGS_EOLN
== ac
)
1346 /* Flush out leading punctuation. */
1348 if (NULL
== head
&& ARGS_QWORD
!= ac
&&
1349 DELIM_OPEN
== mdoc_isdelim(p
)) {
1350 assert(NULL
== body
);
1351 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1357 assert(NULL
== body
);
1358 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1364 * `Eo' gobbles any data into the head, but most other
1365 * macros just immediately close out and begin the body.
1370 /* No check whether it's a macro! */
1372 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1375 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1377 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1385 assert(NULL
!= head
&& NULL
!= body
);
1387 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1389 if (MDOC_MAX
== ntok
) {
1390 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1395 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1400 /* Clean-up to leave in a consistent state. */
1403 if ( ! mdoc_head_alloc(m
, line
, ppos
, tok
))
1409 if ( ! rew_sub(MDOC_HEAD
, m
, tok
, line
, ppos
))
1411 if ( ! mdoc_body_alloc(m
, line
, ppos
, tok
))
1416 /* Standard appending of delimiters. */
1420 return(append_delims(m
, line
, pos
, buf
));
1426 in_line_argn(MACRO_PROT_ARGS
)
1428 int la
, flushed
, j
, maxargs
, nl
;
1431 struct mdoc_arg
*arg
;
1435 nl
= MDOC_NEWLINE
& m
->flags
;
1438 * A line macro that has a fixed number of arguments (maxargs).
1439 * Only open the scope once the first non-leading-punctuation is
1440 * found (unless MDOC_IGNDELIM is noted, like in `Pf'), then
1441 * keep it open until the maximum number of arguments are
1463 for (arg
= NULL
; ; ) {
1465 av
= mdoc_argv(m
, line
, tok
, &arg
, pos
, buf
);
1467 if (ARGV_WORD
== av
) {
1472 if (ARGV_EOLN
== av
)
1477 mdoc_argv_free(arg
);
1481 for (flushed
= j
= 0; ; ) {
1483 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1485 if (ARGS_ERROR
== ac
)
1487 if (ARGS_PUNCT
== ac
)
1489 if (ARGS_EOLN
== ac
)
1492 if ( ! (MDOC_IGNDELIM
& mdoc_macros
[tok
].flags
) &&
1494 0 == j
&& DELIM_OPEN
== mdoc_isdelim(p
)) {
1495 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1499 if ( ! mdoc_elem_alloc(m
, line
, la
, tok
, arg
))
1502 if (j
== maxargs
&& ! flushed
) {
1503 if ( ! rew_elem(m
, tok
))
1508 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1510 if (MDOC_MAX
!= ntok
) {
1511 if ( ! flushed
&& ! rew_elem(m
, tok
))
1514 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1520 if ( ! (MDOC_IGNDELIM
& mdoc_macros
[tok
].flags
) &&
1523 DELIM_NONE
!= mdoc_isdelim(p
)) {
1524 if ( ! rew_elem(m
, tok
))
1530 * XXX: this is a hack to work around groff's ugliness
1531 * as regards `Xr' and extraneous arguments. It should
1532 * ideally be deprecated behaviour, but because this is
1533 * code is no here, it's unlikely to be removed.
1537 if (MDOC_Xr
== tok
&& j
== maxargs
) {
1538 if ( ! mdoc_elem_alloc(m
, line
, la
, MDOC_Ns
, NULL
))
1540 if ( ! rew_elem(m
, MDOC_Ns
))
1545 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1550 if (0 == j
&& ! mdoc_elem_alloc(m
, line
, la
, tok
, arg
))
1553 /* Close out in a consistent state. */
1555 if ( ! flushed
&& ! rew_elem(m
, tok
))
1559 return(append_delims(m
, line
, pos
, buf
));
1564 in_line_eoln(MACRO_PROT_ARGS
)
1569 struct mdoc_arg
*arg
;
1573 assert( ! (MDOC_PARSED
& mdoc_macros
[tok
].flags
));
1575 /* Parse macro arguments. */
1577 for (arg
= NULL
; ; ) {
1579 av
= mdoc_argv(m
, line
, tok
, &arg
, pos
, buf
);
1581 if (ARGV_WORD
== av
) {
1585 if (ARGV_EOLN
== av
)
1590 mdoc_argv_free(arg
);
1594 /* Open element scope. */
1596 if ( ! mdoc_elem_alloc(m
, line
, ppos
, tok
, arg
))
1599 /* Parse argument terms. */
1603 ac
= mdoc_args(m
, line
, pos
, buf
, tok
, &p
);
1605 if (ARGS_ERROR
== ac
)
1607 if (ARGS_EOLN
== ac
)
1610 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup(tok
, p
);
1612 if (MDOC_MAX
== ntok
) {
1613 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1618 if ( ! rew_elem(m
, tok
))
1620 return(mdoc_macro(m
, ntok
, line
, la
, pos
, buf
));
1623 /* Close out (no delimiters). */
1625 return(rew_elem(m
, tok
));
1631 ctx_synopsis(MACRO_PROT_ARGS
)
1635 nl
= MDOC_NEWLINE
& m
->flags
;
1637 /* If we're not in the SYNOPSIS, go straight to in-line. */
1638 if (SEC_SYNOPSIS
!= m
->lastsec
)
1639 return(in_line(m
, tok
, line
, ppos
, pos
, buf
));
1641 /* If we're a nested call, same place. */
1643 return(in_line(m
, tok
, line
, ppos
, pos
, buf
));
1646 * XXX: this will open a block scope; however, if later we end
1647 * up formatting the block scope, then child nodes will inherit
1648 * the formatting. Be careful.
1651 return(blk_part_imp(m
, tok
, line
, ppos
, pos
, buf
));
1657 obsolete(MACRO_PROT_ARGS
)
1660 return(mdoc_pmsg(m
, line
, ppos
, MANDOCERR_MACROOBS
));
1665 * Phrases occur within `Bl -column' entries, separated by `Ta' or tabs.
1666 * They're unusual because they're basically free-form text until a
1667 * macro is encountered.
1670 phrase(struct mdoc
*m
, int line
, int ppos
, char *buf
)
1677 for (pos
= ppos
; ; ) {
1680 ac
= mdoc_zargs(m
, line
, &pos
, buf
, 0, &p
);
1682 if (ARGS_ERROR
== ac
)
1684 if (ARGS_EOLN
== ac
)
1687 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup_raw(p
);
1689 if (MDOC_MAX
== ntok
) {
1690 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1695 if ( ! mdoc_macro(m
, ntok
, line
, la
, &pos
, buf
))
1697 return(append_delims(m
, line
, &pos
, buf
));
1706 phrase_ta(MACRO_PROT_ARGS
)
1714 * FIXME: this is overly restrictive: if the `Ta' is unexpected,
1715 * it should simply error out with ARGSLOST.
1718 if ( ! rew_sub(MDOC_BODY
, m
, MDOC_It
, line
, ppos
))
1720 if ( ! mdoc_body_alloc(m
, line
, ppos
, MDOC_It
))
1725 ac
= mdoc_zargs(m
, line
, pos
, buf
, 0, &p
);
1727 if (ARGS_ERROR
== ac
)
1729 if (ARGS_EOLN
== ac
)
1732 ntok
= ARGS_QWORD
== ac
? MDOC_MAX
: lookup_raw(p
);
1734 if (MDOC_MAX
== ntok
) {
1735 if ( ! mdoc_word_alloc(m
, line
, la
, p
))
1740 if ( ! mdoc_macro(m
, ntok
, line
, la
, pos
, buf
))
1742 return(append_delims(m
, line
, pos
, buf
));