version 1.24, 2009/07/19 21:26:27 |
version 1.28, 2009/07/29 08:46:06 |
Line 47 static int rew_subblock(enum mdoc_type, |
|
Line 47 static int rew_subblock(enum mdoc_type, |
|
struct mdoc *, int, int, int); |
struct mdoc *, int, int, int); |
static int rew_last(struct mdoc *, struct mdoc_node *); |
static int rew_last(struct mdoc *, struct mdoc_node *); |
static int append_delims(struct mdoc *, int, int *, char *); |
static int append_delims(struct mdoc *, int, int *, char *); |
static int lookup(struct mdoc *, int, int, int, const char *); |
static int lookup(struct mdoc *, int, const char *); |
|
static int lookup_raw(struct mdoc *, const char *); |
static int swarn(struct mdoc *, enum mdoc_type, int, int, |
static int swarn(struct mdoc *, enum mdoc_type, int, int, |
const struct mdoc_node *); |
const struct mdoc_node *); |
|
|
Line 253 mdoc_macroend(struct mdoc *mdoc) |
|
Line 254 mdoc_macroend(struct mdoc *mdoc) |
|
} |
} |
|
|
static int |
static int |
lookup(struct mdoc *mdoc, int line, int pos, int from, const char *p) |
lookup(struct mdoc *mdoc, int from, const char *p) |
{ |
{ |
|
|
|
if ( ! (MDOC_PARSED & mdoc_macros[from].flags)) |
|
return(MDOC_MAX); |
|
return(lookup_raw(mdoc, p)); |
|
} |
|
|
|
|
|
static int |
|
lookup_raw(struct mdoc *mdoc, const char *p) |
|
{ |
int res; |
int res; |
|
|
res = mdoc_hash_find(mdoc->htab, p); |
if (MDOC_MAX == (res = mdoc_hash_find(mdoc->htab, p))) |
if (MDOC_PARSED & mdoc_macros[from].flags) |
return(MDOC_MAX); |
|
if (MDOC_CALLABLE & mdoc_macros[res].flags) |
return(res); |
return(res); |
if (MDOC_MAX == res) |
|
return(res); |
|
if ( ! mdoc_pwarn(mdoc, line, pos, EMACPARM)) |
|
return(-1); |
|
return(MDOC_MAX); |
return(MDOC_MAX); |
} |
} |
|
|
Line 681 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 689 blk_exp_close(MACRO_PROT_ARGS) |
|
mdoc->next = MDOC_NEXT_CHILD; |
mdoc->next = MDOC_NEXT_CHILD; |
} |
} |
|
|
for (lastarg = ppos, flushed = j = 0; ; j++) { |
for (flushed = j = 0; ; j++) { |
lastarg = *pos; |
lastarg = *pos; |
|
|
if (j == maxargs && ! flushed) { |
if (j == maxargs && ! flushed) { |
Line 699 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 707 blk_exp_close(MACRO_PROT_ARGS) |
|
if (ARGS_EOLN == c) |
if (ARGS_EOLN == c) |
break; |
break; |
|
|
if (-1 == (c = lookup(mdoc, line, lastarg, tok, p))) |
if (-1 == (c = lookup(mdoc, tok, p))) |
return(0); |
return(0); |
else if (MDOC_MAX != c) { |
else if (MDOC_MAX != c) { |
if ( ! flushed) { |
if ( ! flushed) { |
Line 742 in_line(MACRO_PROT_ARGS) |
|
Line 750 in_line(MACRO_PROT_ARGS) |
|
* usually because of reserved words) to squeak by. |
* usually because of reserved words) to squeak by. |
*/ |
*/ |
switch (tok) { |
switch (tok) { |
case (MDOC_Nm): |
case (MDOC_An): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
|
case (MDOC_Ar): |
|
/* FALLTHROUGH */ |
case (MDOC_Fl): |
case (MDOC_Fl): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Lk): |
case (MDOC_Lk): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Ar): |
case (MDOC_Nm): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Pa): |
nc = 1; |
nc = 1; |
break; |
break; |
default: |
default: |
Line 756 in_line(MACRO_PROT_ARGS) |
|
Line 768 in_line(MACRO_PROT_ARGS) |
|
break; |
break; |
} |
} |
|
|
for (la = ppos, arg = NULL;; ) { |
for (arg = NULL;; ) { |
la = *pos; |
la = *pos; |
c = mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
c = mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
|
|
Line 786 in_line(MACRO_PROT_ARGS) |
|
Line 798 in_line(MACRO_PROT_ARGS) |
|
|
|
/* Quoted words shouldn't be looked-up. */ |
/* Quoted words shouldn't be looked-up. */ |
|
|
c = ARGS_QWORD == w ? MDOC_MAX : |
c = ARGS_QWORD == w ? MDOC_MAX : lookup(mdoc, tok, p); |
lookup(mdoc, line, la, tok, p); |
|
|
|
/* |
/* |
* In this case, we've located a submacro and must |
* In this case, we've located a submacro and must |
Line 984 blk_full(MACRO_PROT_ARGS) |
|
Line 995 blk_full(MACRO_PROT_ARGS) |
|
continue; |
continue; |
} |
} |
|
|
if (-1 == (c = lookup(mdoc, line, lastarg, tok, p))) |
if (-1 == (c = lookup(mdoc, tok, p))) |
return(0); |
return(0); |
|
|
if (MDOC_MAX == c) { |
if (MDOC_MAX == c) { |
Line 1042 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1053 blk_part_imp(MACRO_PROT_ARGS) |
|
|
|
/* XXX - no known argument macros. */ |
/* XXX - no known argument macros. */ |
|
|
for (lastarg = ppos;; ) { |
for (;;) { |
lastarg = *pos; |
lastarg = *pos; |
c = mdoc_args(mdoc, line, pos, buf, tok, &p); |
c = mdoc_args(mdoc, line, pos, buf, tok, &p); |
assert(ARGS_PHRASE != c); |
assert(ARGS_PHRASE != c); |
Line 1054 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1065 blk_part_imp(MACRO_PROT_ARGS) |
|
if (ARGS_EOLN == c) |
if (ARGS_EOLN == c) |
break; |
break; |
|
|
if (-1 == (c = lookup(mdoc, line, lastarg, tok, p))) |
if (-1 == (c = lookup(mdoc, tok, p))) |
return(0); |
return(0); |
else if (MDOC_MAX == c) { |
else if (MDOC_MAX == c) { |
if ( ! mdoc_word_alloc(mdoc, line, lastarg, p)) |
if ( ! mdoc_word_alloc(mdoc, line, lastarg, p)) |
Line 1103 blk_part_exp(MACRO_PROT_ARGS) |
|
Line 1114 blk_part_exp(MACRO_PROT_ARGS) |
|
int lastarg, flushed, j, c, maxargs; |
int lastarg, flushed, j, c, maxargs; |
char *p; |
char *p; |
|
|
lastarg = ppos; |
|
flushed = 0; |
flushed = 0; |
|
|
/* |
/* |
Line 1159 blk_part_exp(MACRO_PROT_ARGS) |
|
Line 1169 blk_part_exp(MACRO_PROT_ARGS) |
|
if (ARGS_EOLN == c) |
if (ARGS_EOLN == c) |
break; |
break; |
|
|
if (-1 == (c = lookup(mdoc, line, lastarg, tok, p))) |
if (-1 == (c = lookup(mdoc, tok, p))) |
return(0); |
return(0); |
else if (MDOC_MAX != c) { |
else if (MDOC_MAX != c) { |
if ( ! flushed) { |
if ( ! flushed) { |
Line 1239 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1249 in_line_argn(MACRO_PROT_ARGS) |
|
break; |
break; |
} |
} |
|
|
for (lastarg = ppos, arg = NULL;; ) { |
for (arg = NULL;; ) { |
lastarg = *pos; |
lastarg = *pos; |
c = mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
c = mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
|
|
Line 1279 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1289 in_line_argn(MACRO_PROT_ARGS) |
|
if (ARGS_EOLN == c) |
if (ARGS_EOLN == c) |
break; |
break; |
|
|
if (-1 == (c = lookup(mdoc, line, lastarg, tok, p))) |
if (-1 == (c = lookup(mdoc, tok, p))) |
return(0); |
return(0); |
else if (MDOC_MAX != c) { |
else if (MDOC_MAX != c) { |
if ( ! flushed && ! rew_elem(mdoc, tok)) |
if ( ! flushed && ! rew_elem(mdoc, tok)) |
Line 1357 in_line_eoln(MACRO_PROT_ARGS) |
|
Line 1367 in_line_eoln(MACRO_PROT_ARGS) |
|
if (ARGS_EOLN == w) |
if (ARGS_EOLN == w) |
break; |
break; |
|
|
c = ARGS_QWORD == w ? MDOC_MAX : |
c = ARGS_QWORD == w ? MDOC_MAX : lookup(mdoc, tok, p); |
lookup(mdoc, line, la, tok, p); |
|
|
|
if (MDOC_MAX != c && -1 != c) { |
if (MDOC_MAX != c && -1 != c) { |
if ( ! rew_elem(mdoc, tok)) |
if ( ! rew_elem(mdoc, tok)) |