summaryrefslogtreecommitdiffstats
path: root/mdoc_macro.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-04-19 14:00:19 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-04-19 14:00:19 +0000
commiteed5e7f1fb85805f1b324c5a4501ed30467ae2a0 (patch)
tree78f09c634d1cfc1b83be85f07be7ee909cbd6d30 /mdoc_macro.c
parent344327def21ee64357a9cdf57c5352f1c5575708 (diff)
downloadmandoc-eed5e7f1fb85805f1b324c5a4501ed30467ae2a0.tar.gz
Decouple the token code for "no request or macro" from the individual
high-level parsers to allow further unification of functions that only need to recognize this code, but that don't care about different high-level macrosets beyond that.
Diffstat (limited to 'mdoc_macro.c')
-rw-r--r--mdoc_macro.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/mdoc_macro.c b/mdoc_macro.c
index e904a6eb..fcfd517c 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -232,16 +232,16 @@ mdoc_macroend(struct roff_man *mdoc)
/*
* Look up the macro at *p called by "from",
- * or as a line macro if from == MDOC_MAX.
+ * or as a line macro if from == TOKEN_NONE.
*/
static int
lookup(struct roff_man *mdoc, int from, int line, int ppos, const char *p)
{
int res;
- if (from == MDOC_MAX || mdoc_macros[from].flags & MDOC_PARSED) {
+ if (from == TOKEN_NONE || mdoc_macros[from].flags & MDOC_PARSED) {
res = mdoc_hash_find(p);
- if (res != MDOC_MAX) {
+ if (res != TOKEN_NONE) {
if (mdoc_macros[res].flags & MDOC_CALLABLE)
return(res);
if (res != MDOC_br && res != MDOC_sp && res != MDOC_ll)
@@ -249,7 +249,7 @@ lookup(struct roff_man *mdoc, int from, int line, int ppos, const char *p)
mdoc->parse, line, ppos, p);
}
}
- return(MDOC_MAX);
+ return(TOKEN_NONE);
}
/*
@@ -465,7 +465,8 @@ append_delims(struct roff_man *mdoc, int line, int *pos, char *buf)
for (;;) {
la = *pos;
- if (mdoc_args(mdoc, line, pos, buf, MDOC_MAX, &p) == ARGS_EOLN)
+ if (mdoc_args(mdoc, line, pos, buf, TOKEN_NONE, &p) ==
+ ARGS_EOLN)
break;
dword(mdoc, line, la, p, DELIM_MAX, 1);
@@ -498,21 +499,21 @@ macro_or_word(MACRO_PROT_ARGS, int parsed)
int ntok;
p = buf + ppos;
- ntok = MDOC_MAX;
+ ntok = TOKEN_NONE;
if (*p == '"')
p++;
else if (parsed && ! (mdoc->flags & MDOC_PHRASELIT))
ntok = lookup(mdoc, tok, line, ppos, p);
- if (ntok == MDOC_MAX) {
- dword(mdoc, line, ppos, p, DELIM_MAX, tok == MDOC_MAX ||
+ if (ntok == TOKEN_NONE) {
+ dword(mdoc, line, ppos, p, DELIM_MAX, tok == TOKEN_NONE ||
mdoc_macros[tok].flags & MDOC_JOIN);
return(0);
} else {
if (mdoc_macros[tok].fp == in_line_eoln)
rew_elem(mdoc, tok);
mdoc_macro(mdoc, ntok, line, ppos, pos, buf);
- if (tok == MDOC_MAX)
+ if (tok == TOKEN_NONE)
append_delims(mdoc, line, pos, buf);
return(1);
}
@@ -677,10 +678,10 @@ blk_exp_close(MACRO_PROT_ARGS)
if (ac == ARGS_PUNCT || ac == ARGS_EOLN)
break;
- ntok = ac == ARGS_QWORD ? MDOC_MAX :
+ ntok = ac == ARGS_QWORD ? TOKEN_NONE :
lookup(mdoc, tok, line, lastarg, p);
- if (ntok == MDOC_MAX) {
+ if (ntok == TOKEN_NONE) {
dword(mdoc, line, lastarg, p, DELIM_MAX,
MDOC_JOIN & mdoc_macros[tok].flags);
continue;
@@ -781,7 +782,7 @@ in_line(MACRO_PROT_ARGS)
}
ntok = (ac == ARGS_QWORD || (tok == MDOC_Fn && !cnt)) ?
- MDOC_MAX : lookup(mdoc, tok, line, la, p);
+ TOKEN_NONE : lookup(mdoc, tok, line, la, p);
/*
* In this case, we've located a submacro and must
@@ -790,7 +791,7 @@ in_line(MACRO_PROT_ARGS)
* or raise a warning.
*/
- if (ntok != MDOC_MAX) {
+ if (ntok != TOKEN_NONE) {
if (scope)
rew_elem(mdoc, tok);
if (nc && ! cnt) {
@@ -1107,7 +1108,7 @@ blk_full(MACRO_PROT_ARGS)
mdoc->flags |= MDOC_PPHRASE;
if (ac == ARGS_PEND && lac == ARGS_PPHRASE)
mdoc->flags |= MDOC_PPHRASE;
- parse_rest(mdoc, MDOC_MAX, line, &la, buf);
+ parse_rest(mdoc, TOKEN_NONE, line, &la, buf);
mdoc->flags &= ~MDOC_PPHRASE;
continue;
}
@@ -1337,9 +1338,9 @@ in_line_argn(MACRO_PROT_ARGS)
}
ntok = (ac == ARGS_QWORD || (tok == MDOC_Pf && state == 0)) ?
- MDOC_MAX : lookup(mdoc, tok, line, la, p);
+ TOKEN_NONE : lookup(mdoc, tok, line, la, p);
- if (ntok != MDOC_MAX) {
+ if (ntok != TOKEN_NONE) {
if (state >= 0) {
rew_elem(mdoc, tok);
state = -2;
@@ -1473,5 +1474,5 @@ phrase_ta(MACRO_PROT_ARGS)
rew_last(mdoc, body);
roff_body_alloc(mdoc, line, ppos, MDOC_It);
- parse_rest(mdoc, MDOC_MAX, line, pos, buf);
+ parse_rest(mdoc, TOKEN_NONE, line, pos, buf);
}