]>
git.cameronkatri.com Git - mandoc.git/blob - macro.c
1 /* $Id: macro.c,v 1.12 2008/12/29 19:25:29 kristaps Exp $ */
3 * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
30 /* FIXME: maxlineargs should be per LINE, no per TOKEN. */
32 #define _CC(p) ((const char **)p)
34 static int scope_rewind_exp(struct mdoc
*, int, int, int);
35 static int scope_rewind_imp(struct mdoc
*, int, int);
36 static int append_text(struct mdoc
*, int,
38 static int append_const(struct mdoc
*, int, int, int, char *[]);
39 static int append_scoped(struct mdoc
*, int, int, int,
40 const char *[], int, const struct mdoc_arg
*);
41 static int append_delims(struct mdoc
*, int, int *, char *);
45 append_delims(struct mdoc
*mdoc
, int tok
, int *pos
, char *buf
)
53 mdoc_msg(mdoc
, *pos
, "`%s' flushing punctuation",
54 mdoc_macronames
[tok
]);
58 c
= mdoc_args(mdoc
, tok
, pos
, buf
, 0, &p
);
61 else if (ARGS_EOLN
== c
)
63 assert(mdoc_isdelim(p
));
64 mdoc_word_alloc(mdoc
, lastarg
, p
);
72 scope_rewind_imp(struct mdoc
*mdoc
, int ppos
, int tok
)
77 n
= mdoc
->last
? mdoc
->last
->parent
: NULL
;
80 for ( ; n
; n
= n
->parent
) {
81 if (MDOC_BLOCK
!= n
->type
)
83 if (tok
== (t
= n
->data
.block
.tok
))
85 if ( ! (MDOC_EXPLICIT
& mdoc_macros
[t
].flags
))
87 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SCOPE_BREAK
));
92 mdoc_msg(mdoc
, ppos
, "scope: rewound implicit `%s'",
93 mdoc_macronames
[tok
]);
97 mdoc_msg(mdoc
, ppos
, "scope: new implicit `%s'",
98 mdoc_macronames
[tok
]);
104 scope_rewind_exp(struct mdoc
*mdoc
, int ppos
, int tok
, int dst
)
111 for (n
= mdoc
->last
->parent
; n
; n
= n
->parent
) {
112 if (MDOC_BLOCK
!= n
->type
)
114 if (dst
== n
->data
.block
.tok
)
116 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SCOPE_BREAK
));
119 if (NULL
== (mdoc
->last
= n
))
120 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SCOPE_NOCTX
));
122 mdoc_msg(mdoc
, ppos
, "scope: rewound explicit `%s' to `%s'",
123 mdoc_macronames
[tok
], mdoc_macronames
[dst
]);
130 append_scoped(struct mdoc
*mdoc
, int tok
, int pos
,
131 int sz
, const char *args
[],
132 int argc
, const struct mdoc_arg
*argv
)
135 struct mdoc_node
*node
;
138 /* ======= ADD MORE MACRO CHECKS BELOW. ======= */
141 return(mdoc_err(mdoc
, tok
, pos
, ERR_ARGS_GE1
));
143 sec
= mdoc_atosec((size_t)sz
, _CC(args
));
144 if (SEC_CUSTOM
!= sec
&& sec
< mdoc
->sec_lastn
)
145 if ( ! mdoc_warn(mdoc
, tok
, pos
, WARN_SEC_OO
))
148 if (SEC_BODY
== mdoc
->sec_last
&& SEC_NAME
!= sec
)
149 return(mdoc_err(mdoc
, tok
, pos
, ERR_SEC_NAME
));
151 if (SEC_CUSTOM
!= sec
)
152 mdoc
->sec_lastn
= sec
;
153 mdoc
->sec_last
= sec
;
158 return(mdoc_err(mdoc
, tok
, pos
, ERR_ARGS_GE1
));
163 node
= mdoc
->last
->parent
;
165 for ( ; node
; node
= node
->parent
) {
166 if (node
->type
!= MDOC_BLOCK
)
168 if (node
->data
.block
.tok
!= MDOC_Bd
)
170 return(mdoc_err(mdoc
, tok
, pos
, ERR_SCOPE_NONEST
));
177 /* ======= ADD MORE MACRO CHECKS ABOVE. ======= */
183 mdoc_block_alloc(mdoc
, pos
, tok
, (size_t)argc
, argv
);
184 mdoc_head_alloc(mdoc
, pos
, tok
, (size_t)sz
, _CC(args
));
185 mdoc_body_alloc(mdoc
, pos
, tok
);
191 append_const(struct mdoc
*mdoc
, int tok
,
192 int pos
, int sz
, char *args
[])
196 /* ======= ADD MORE MACRO CHECKS BELOW. ======= */
198 /* This needs special handling. */
202 return(mdoc_err(mdoc
, tok
, pos
, ERR_ARGS_LE2
));
204 if (ATT_DEFAULT
!= mdoc_atoatt(args
[0])) {
205 mdoc_elem_alloc(mdoc
, pos
, tok
, 0,
206 NULL
, 1, _CC(&args
[0]));
208 mdoc_elem_alloc(mdoc
, pos
, tok
,
210 if (mdoc_isdelim(args
[0]))
211 return(mdoc_err(mdoc
, tok
, pos
, ERR_SYNTAX_NOPUNCT
));
212 mdoc_word_alloc(mdoc
, pos
, args
[0]);
217 if (mdoc_isdelim(args
[1]))
218 return(mdoc_err(mdoc
, tok
, pos
, ERR_SYNTAX_NOPUNCT
));
219 mdoc_word_alloc(mdoc
, pos
, args
[1]);
225 if ( ! mdoc_warn(mdoc
, tok
, pos
, WARN_ARGS_GE1
))
232 return(mdoc_err(mdoc
, tok
, pos
, ERR_ARGS_EQ1
));
255 return(mdoc_err(mdoc
, tok
, pos
, ERR_ARGS_EQ0
));
257 /* ======= ADD MORE MACRO CHECKS ABOVE. ======= */
263 mdoc_elem_alloc(mdoc
, pos
, tok
, 0, NULL
, (size_t)sz
, _CC(args
));
269 append_text(struct mdoc
*mdoc
, int tok
,
270 int pos
, int sz
, char *args
[])
277 /* ======= ADD MORE MACRO CHECKS BELOW. ======= */
281 if ( ! mdoc_warn(mdoc
, tok
, pos
, WARN_ARGS_EQ0
))
296 if ( ! mdoc_warn(mdoc
, tok
, pos
, WARN_ARGS_GE1
))
305 /* These can have no arguments. */
331 return(mdoc_err(mdoc
, tok
, pos
, ERR_ARGS_GE1
));
332 /* ======= ADD MORE MACRO CHECKS ABOVE. ======= */
338 mdoc_elem_alloc(mdoc
, pos
, tok
, 0, NULL
, (size_t)sz
, _CC(args
));
344 macro_text(MACRO_PROT_ARGS
)
346 int lastarg
, lastpunct
, c
, j
;
347 char *args
[MDOC_LINEARG_MAX
], *p
;
349 if (SEC_PROLOGUE
== mdoc
->sec_lastn
)
350 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_PROLOGUE
));
352 /* Token pre-processing. */
356 /* `.Pp' ignored when following `.Sh' or `.Ss'. */
358 if (MDOC_BODY
!= mdoc
->last
->type
)
360 switch (mdoc
->last
->data
.body
.tok
) {
364 if ( ! mdoc_warn(mdoc
, tok
, ppos
, WARN_IGN_AFTER_BLK
))
375 /* Process line parameters. */
382 if (j
== MDOC_LINEARG_MAX
)
383 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_ARGS_MANY
));
386 * Parse out the next argument, unquoted and unescaped. If
387 * we're a word (which may be punctuation followed eventually by
388 * a real word), then fall into checking for callables. If
389 * only punctuation remains and we're the first, then flush
390 * arguments, punctuation and exit; else, return to the caller.
395 switch (mdoc_args(mdoc
, tok
, pos
, buf
, ARGS_DELIM
, &args
[j
])) {
401 if ( ! lastpunct
&& ! append_text(mdoc
, tok
, ppos
, j
, args
))
405 return(append_delims(mdoc
, tok
, pos
, buf
));
409 return(append_text(mdoc
, tok
, ppos
, j
, args
));
416 * Command found. First flush out arguments, then call the
417 * command. If we're the line macro when it exits, flush
418 * terminal punctuation.
421 if (MDOC_MAX
!= (c
= mdoc_find(mdoc
, args
[j
]))) {
422 if ( ! lastpunct
&& ! append_text(mdoc
, tok
, ppos
, j
, args
))
424 if ( ! mdoc_macro(mdoc
, c
, lastarg
, pos
, buf
))
428 return(append_delims(mdoc
, tok
, pos
, buf
));
431 /* Word/non-term-punctuation found. */
433 if ( ! mdoc_isdelim(args
[j
])) {
434 /* Words are appended to the array of arguments. */
441 * For punctuation, flush all collected words, then flush
442 * punctuation, then start collecting again. Of course, this
443 * is non-terminal punctuation.
447 if ( ! lastpunct
&& ! append_text(mdoc
, tok
, ppos
, j
, args
))
450 mdoc_word_alloc(mdoc
, lastarg
, p
);
460 macro_prologue_dtitle(MACRO_PROT_ARGS
)
463 char *args
[MDOC_LINEARG_MAX
];
465 if (SEC_PROLOGUE
!= mdoc
->sec_lastn
)
466 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_NPROLOGUE
));
467 if (0 == mdoc
->meta
.date
)
468 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_PROLOGUE_OO
));
469 if (mdoc
->meta
.title
[0])
470 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_PROLOGUE_REP
));
476 if (j
== MDOC_LINEARG_MAX
)
477 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_ARGS_MANY
));
481 switch (mdoc_args(mdoc
, tok
, pos
, buf
, 0, &args
[++j
])) {
483 if (mdoc
->meta
.title
)
485 if ( ! mdoc_warn(mdoc
, tok
, ppos
, WARN_ARGS_GE1
))
487 (void)xstrlcpy(mdoc
->meta
.title
,
488 "UNTITLED", META_TITLE_SZ
);
496 if (MDOC_MAX
!= mdoc_find(mdoc
, args
[j
]) && ! mdoc_warn
497 (mdoc
, tok
, lastarg
, WARN_SYNTAX_MACLIKE
))
501 if (xstrlcpy(mdoc
->meta
.title
, args
[0], META_TITLE_SZ
))
503 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_SYNTAX_ARGFORM
));
506 mdoc
->meta
.msec
= mdoc_atomsec(args
[1]);
507 if (MSEC_DEFAULT
!= mdoc
->meta
.msec
)
509 return(mdoc_err(mdoc
, tok
, -1, ERR_SYNTAX_ARGFORM
));
512 mdoc
->meta
.vol
= mdoc_atovol(args
[2]);
513 if (VOL_DEFAULT
!= mdoc
->meta
.vol
)
515 mdoc
->meta
.arch
= mdoc_atoarch(args
[2]);
516 if (ARCH_DEFAULT
!= mdoc
->meta
.arch
)
518 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_SYNTAX_ARGFORM
));
521 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_ARGS_MANY
));
526 macro_prologue_os(MACRO_PROT_ARGS
)
529 char *args
[MDOC_LINEARG_MAX
];
531 if (SEC_PROLOGUE
!= mdoc
->sec_lastn
)
532 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_NPROLOGUE
));
533 if (0 == mdoc
->meta
.title
[0])
534 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_PROLOGUE_OO
));
535 if (mdoc
->meta
.os
[0])
536 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_PROLOGUE_REP
));
542 if (j
== MDOC_LINEARG_MAX
)
543 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_ARGS_MANY
));
547 switch (mdoc_args(mdoc
, tok
, pos
, buf
,
548 ARGS_QUOTED
, &args
[++j
])) {
550 mdoc
->sec_lastn
= mdoc
->sec_last
= SEC_BODY
;
558 if ( ! xstrlcat(mdoc
->meta
.os
, args
[j
], sizeof(mdoc
->meta
.os
)))
559 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_SYNTAX_ARGFORM
));
560 if ( ! xstrlcat(mdoc
->meta
.os
, " ", sizeof(mdoc
->meta
.os
)))
561 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_SYNTAX_ARGFORM
));
569 macro_prologue_ddate(MACRO_PROT_ARGS
)
572 char *args
[MDOC_LINEARG_MAX
], date
[64];
574 if (SEC_PROLOGUE
!= mdoc
->sec_lastn
)
575 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_NPROLOGUE
));
576 if (mdoc
->meta
.title
[0])
577 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_PROLOGUE_OO
));
579 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_PROLOGUE_REP
));
586 if (j
== MDOC_LINEARG_MAX
)
587 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_ARGS_MANY
));
590 switch (mdoc_args(mdoc
, tok
, pos
, buf
, 0, &args
[++j
])) {
594 mdoc
->meta
.date
= mdoc_atotime(date
);
597 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SYNTAX_ARGFORM
));
604 if (MDOC_MAX
!= mdoc_find(mdoc
, args
[j
]) && ! mdoc_warn
605 (mdoc
, tok
, lastarg
, WARN_SYNTAX_MACLIKE
))
609 if (xstrcmp("$Mdocdate: December 29 2008 $", args
[j
])) {
610 mdoc
->meta
.date
= time(NULL
);
612 } else if (xstrcmp("$Mdocdate:", args
[j
]))
615 if ( ! xstrcmp("$", args
[j
]))
618 if ( ! xstrlcat(date
, args
[j
], sizeof(date
)))
619 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_SYNTAX_ARGFORM
));
620 if ( ! xstrlcat(date
, " ", sizeof(date
)))
621 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_SYNTAX_ARGFORM
));
629 macro_scoped_explicit(MACRO_PROT_ARGS
)
632 struct mdoc_arg argv
[MDOC_LINEARG_MAX
];
635 if (SEC_PROLOGUE
== mdoc
->sec_lastn
)
636 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_PROLOGUE
));
639 * First close out the explicit scope. The `end' tags (such as
640 * `.El' to `.Bl' don't cause anything to happen: we merely
641 * readjust our last parse point.
646 return(scope_rewind_exp(mdoc
, ppos
, tok
, MDOC_Bl
));
648 return(scope_rewind_exp(mdoc
, ppos
, tok
, MDOC_Bd
));
653 assert(MDOC_EXPLICIT
& mdoc_macros
[tok
].flags
);
655 /* Token pre-processing. */
661 /* `.Pp' ignored when preceding `.Bl' or `.Bd'. */
663 if (MDOC_ELEM
!= mdoc
->last
->type
)
665 if (MDOC_Pp
!= mdoc
->last
->data
.elem
.tok
)
667 if ( ! mdoc_warn(mdoc
, tok
, ppos
, WARN_IGN_BEFORE_BLK
))
669 assert(mdoc
->last
->prev
);
671 mdoc
->last
= mdoc
->last
->prev
;
672 mdoc
->last
->next
= NULL
;
681 for (j
= 0; j
< MDOC_LINEARG_MAX
; j
++) {
683 c
= mdoc_argv(mdoc
, tok
, &argv
[j
], pos
, buf
);
689 mdoc_argv_free(j
, argv
);
693 if (MDOC_LINEARG_MAX
== j
) {
694 mdoc_argv_free(j
, argv
);
695 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_ARGS_MANY
));
698 c
= append_scoped(mdoc
, tok
, ppos
, 0, NULL
, j
, argv
);
699 mdoc_argv_free(j
, argv
);
705 * Implicity-scoped macros, like `.Ss', have a scope that terminates
706 * with a subsequent call to the same macro. Implicit macros cannot
707 * break the scope of explicitly-scoped macros; however, they can break
708 * the scope of other implicit macros (so `.Sh' can break `.Ss'). This
709 * is ok with macros like `.It' because they exist only within an
712 * These macros put line arguments (which it's allowed to have) into the
713 * HEAD section and open a BODY scope to be used until the macro scope
717 macro_scoped_implicit(MACRO_PROT_ARGS
)
720 char *args
[MDOC_LINEARG_MAX
];
723 assert( ! (MDOC_EXPLICIT
& mdoc_macros
[tok
].flags
));
725 if (SEC_PROLOGUE
== mdoc
->sec_lastn
)
726 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_PROLOGUE
));
728 /* Token pre-processing. */
734 /* `.Pp' ignored when preceding `.Ss' or `.Sh'. */
735 if (NULL
== mdoc
->last
)
737 if (MDOC_ELEM
!= mdoc
->last
->type
)
739 if (MDOC_Pp
!= mdoc
->last
->data
.elem
.tok
)
741 if ( ! mdoc_warn(mdoc
, tok
, ppos
, WARN_IGN_BEFORE_BLK
))
743 assert(mdoc
->last
->prev
);
745 mdoc_msg(mdoc
, ppos
, "removing prior `Pp' macro");
746 mdoc
->last
= mdoc
->last
->prev
;
747 mdoc
->last
->next
= NULL
;
754 /* Rewind our scope. */
756 if ( ! scope_rewind_imp(mdoc
, ppos
, tok
))
763 * Process until we hit a line. Note that current implicit
764 * macros don't have any arguments, so we don't need to do any
765 * argument processing.
769 if (j
== MDOC_LINEARG_MAX
)
770 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_ARGS_MANY
));
774 switch (mdoc_args(mdoc
, tok
, pos
, buf
, 0, &args
[j
])) {
778 return(append_scoped(mdoc
, tok
, ppos
, j
, _CC(args
), 0, NULL
));
783 if (MDOC_MAX
!= mdoc_find(mdoc
, args
[j
]))
784 if ( ! mdoc_warn(mdoc
, tok
, lastarg
, WARN_SYNTAX_MACLIKE
))
794 * A line-scoped macro opens a scope for the contents of its line, which
795 * are placed under the HEAD node. Punctuation trailing the line is put
796 * as a sibling to the HEAD node, under the BLOCK node.
799 macro_scoped_line(MACRO_PROT_ARGS
)
805 if (SEC_PROLOGUE
== mdoc
->sec_lastn
)
806 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_PROLOGUE
));
810 /* Token pre-processing. */
816 /* These can't be nested in a display block. */
818 for (n
= mdoc
->last
->parent
; n
; n
= n
->parent
)
819 if (MDOC_BLOCK
!= n
->type
)
821 else if (MDOC_Bd
== n
->data
.block
.tok
)
825 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SCOPE_NONEST
));
831 * All line-scoped macros have a HEAD and optionally a BODY
832 * section. We open our scope here; when we exit this function,
833 * we'll rewind our scope appropriately.
836 mdoc_block_alloc(mdoc
, ppos
, tok
, 0, NULL
);
837 mdoc_head_alloc(mdoc
, ppos
, tok
, 0, NULL
);
839 /* Process line parameters. */
845 if (j
== MDOC_LINEARG_MAX
)
846 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_ARGS_MANY
));
849 c
= mdoc_args(mdoc
, tok
, pos
, buf
, ARGS_DELIM
, &p
);
857 if ( ! append_delims(mdoc
, tok
, pos
, buf
))
859 return(scope_rewind_imp(mdoc
, ppos
, tok
));
861 return(scope_rewind_imp(mdoc
, ppos
, tok
));
867 if (MDOC_MAX
!= (c
= mdoc_find(mdoc
, p
))) {
868 if ( ! mdoc_macro(mdoc
, c
, lastarg
, pos
, buf
))
870 if ( ! append_delims(mdoc
, tok
, pos
, buf
))
872 return(scope_rewind_imp(mdoc
, ppos
, tok
));
878 mdoc_word_alloc(mdoc
, lastarg
, p
);
885 * Partial-line scope is identical to line scope (macro_scoped_line())
886 * except that trailing punctuation is appended to the BLOCK, instead of
887 * contained within the HEAD.
890 macro_scoped_pline(MACRO_PROT_ARGS
)
895 if (SEC_PROLOGUE
== mdoc
->sec_lastn
)
896 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_PROLOGUE
));
898 /* Token pre-processing. */
902 if ( ! mdoc_warn(mdoc
, tok
, ppos
, WARN_COMPAT_TROFF
))
909 mdoc_block_alloc(mdoc
, ppos
, tok
, 0, NULL
);
910 mdoc_head_alloc(mdoc
, ppos
, tok
, 0, NULL
);
912 /* Process line parameters. */
918 if (j
== MDOC_LINEARG_MAX
)
919 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_ARGS_MANY
));
922 c
= mdoc_args(mdoc
, tok
, pos
, buf
, ARGS_DELIM
, &p
);
930 if ( ! scope_rewind_imp(mdoc
, ppos
, tok
))
934 return(append_delims(mdoc
, tok
, pos
, buf
));
936 return(scope_rewind_imp(mdoc
, ppos
, tok
));
942 if (MDOC_MAX
!= (c
= mdoc_find(mdoc
, p
))) {
943 if ( ! mdoc_macro(mdoc
, c
, lastarg
, pos
, buf
))
945 if ( ! scope_rewind_imp(mdoc
, ppos
, tok
))
949 return(append_delims(mdoc
, tok
, pos
, buf
));
955 mdoc_word_alloc(mdoc
, lastarg
, p
);
962 * A delimited-constant macro is similar to a general text macro: the
963 * macro is followed by a 0 or 1 arguments (possibly-unspecified) then
964 * terminating punctuation, other words, or another callable macro.
967 macro_constant_delimited(MACRO_PROT_ARGS
)
969 int lastarg
, flushed
, c
, maxargs
;
972 if (SEC_PROLOGUE
== mdoc
->sec_lastn
)
973 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_PROLOGUE
));
975 /* Process line parameters. */
980 /* Token pre-processing. */
994 switch (mdoc_args(mdoc
, tok
, pos
, buf
, ARGS_DELIM
, &p
)) {
1000 if ( ! flushed
&& ! append_const(mdoc
, tok
, ppos
, 0, &p
))
1004 return(append_delims(mdoc
, tok
, pos
, buf
));
1008 return(append_const(mdoc
, tok
, ppos
, 0, &p
));
1014 /* Accepts no arguments: flush out symbol and continue. */
1018 if ( ! append_const(mdoc
, tok
, ppos
, 0, &p
))
1024 if (MDOC_MAX
!= (c
= mdoc_find(mdoc
, p
))) {
1025 if ( ! flushed
&& ! append_const(mdoc
, tok
, ppos
, 0, &p
))
1027 if ( ! mdoc_macro(mdoc
, c
, lastarg
, pos
, buf
))
1031 return(append_delims(mdoc
, tok
, pos
, buf
));
1035 * We only accept one argument; subsequent tokens are considered
1036 * as literal words (until a macro).
1039 if ( ! flushed
&& ! mdoc_isdelim(p
)) {
1040 if ( ! append_const(mdoc
, tok
, ppos
, 1, &p
))
1044 } else if ( ! flushed
) {
1046 if ( ! append_const(mdoc
, tok
, ppos
, 0, &p
))
1052 mdoc_word_alloc(mdoc
, lastarg
, p
);
1059 macro_constant(MACRO_PROT_ARGS
)
1062 char *args
[MDOC_LINEARG_MAX
];
1064 if (SEC_PROLOGUE
== mdoc
->sec_lastn
)
1065 return(mdoc_err(mdoc
, tok
, ppos
, ERR_SEC_PROLOGUE
));
1070 if (j
== MDOC_LINEARG_MAX
)
1071 return(mdoc_err(mdoc
, tok
, lastarg
, ERR_ARGS_MANY
));
1075 switch (mdoc_args(mdoc
, tok
, pos
, buf
, 0, &args
[j
])) {
1081 return(append_const(mdoc
, tok
, ppos
, j
, args
));
1087 if (MDOC_MAX
!= mdoc_find(mdoc
, args
[j
]))
1088 if ( ! mdoc_warn(mdoc
, tok
, lastarg
, WARN_SYNTAX_MACLIKE
))