version 1.153, 2014/11/29 03:37:44 |
version 1.156, 2014/11/30 05:29:00 |
Line 53 static void phrase_ta(MACRO_PROT_ARGS); |
|
Line 53 static void phrase_ta(MACRO_PROT_ARGS); |
|
static void dword(struct mdoc *, int, int, const char *, |
static void dword(struct mdoc *, int, int, const char *, |
enum mdelim, int); |
enum mdelim, int); |
static void append_delims(struct mdoc *, int, int *, char *); |
static void append_delims(struct mdoc *, int, int *, char *); |
static enum mdoct lookup(enum mdoct, const char *); |
static enum mdoct lookup(struct mdoc *, enum mdoct, |
|
int, int, const char *); |
static int macro_or_word(MACRO_PROT_ARGS, int); |
static int macro_or_word(MACRO_PROT_ARGS, int); |
static int make_pending(struct mdoc_node *, enum mdoct, |
static int make_pending(struct mdoc_node *, enum mdoct, |
struct mdoc *, int, int); |
struct mdoc *, int, int); |
static void phrase(struct mdoc *, int, int *, char *); |
static int parse_rest(struct mdoc *, enum mdoct, |
|
int, int *, char *); |
static enum mdoct rew_alt(enum mdoct); |
static enum mdoct rew_alt(enum mdoct); |
static enum rew rew_dohalt(enum mdoct, enum mdoc_type, |
static enum rew rew_dohalt(enum mdoct, enum mdoc_type, |
const struct mdoc_node *); |
const struct mdoc_node *); |
Line 244 mdoc_macroend(struct mdoc *mdoc) |
|
Line 246 mdoc_macroend(struct mdoc *mdoc) |
|
* or as a line macro if from == MDOC_MAX. |
* or as a line macro if from == MDOC_MAX. |
*/ |
*/ |
static enum mdoct |
static enum mdoct |
lookup(enum mdoct from, const char *p) |
lookup(struct mdoc *mdoc, enum mdoct from, int line, int ppos, const char *p) |
{ |
{ |
enum mdoct res; |
enum mdoct res; |
|
|
if (from == MDOC_MAX || mdoc_macros[from].flags & MDOC_PARSED) { |
if (from == MDOC_MAX || mdoc_macros[from].flags & MDOC_PARSED) { |
res = mdoc_hash_find(p); |
res = mdoc_hash_find(p); |
if (res != MDOC_MAX && mdoc_macros[res].flags & MDOC_CALLABLE) |
if (res != MDOC_MAX) { |
return(res); |
if (mdoc_macros[res].flags & MDOC_CALLABLE) |
|
return(res); |
|
if (res != MDOC_br && res != MDOC_sp && res != MDOC_ll) |
|
mandoc_msg(MANDOCERR_MACRO_CALL, |
|
mdoc->parse, line, ppos, p); |
|
} |
} |
} |
return(MDOC_MAX); |
return(MDOC_MAX); |
} |
} |
Line 670 macro_or_word(MACRO_PROT_ARGS, int parsed) |
|
Line 677 macro_or_word(MACRO_PROT_ARGS, int parsed) |
|
else if (*p == '"') |
else if (*p == '"') |
p++; |
p++; |
else if (parsed) |
else if (parsed) |
ntok = lookup(tok, p); |
ntok = lookup(mdoc, tok, line, ppos, p); |
|
|
if (ntok == MDOC_MAX) { |
if (ntok == MDOC_MAX) { |
dword(mdoc, line, ppos, p, DELIM_MAX, tok == MDOC_MAX || |
dword(mdoc, line, ppos, p, DELIM_MAX, tok == MDOC_MAX || |
Line 831 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 838 blk_exp_close(MACRO_PROT_ARGS) |
|
if (ac == ARGS_PUNCT || ac == ARGS_EOLN) |
if (ac == ARGS_PUNCT || ac == ARGS_EOLN) |
break; |
break; |
|
|
ntok = ac == ARGS_QWORD ? MDOC_MAX : lookup(tok, p); |
ntok = ac == ARGS_QWORD ? MDOC_MAX : |
|
lookup(mdoc, tok, line, lastarg, p); |
|
|
if (ntok == MDOC_MAX) { |
if (ntok == MDOC_MAX) { |
dword(mdoc, line, lastarg, p, DELIM_MAX, |
dword(mdoc, line, lastarg, p, DELIM_MAX, |
Line 932 in_line(MACRO_PROT_ARGS) |
|
Line 940 in_line(MACRO_PROT_ARGS) |
|
} |
} |
|
|
ntok = (ac == ARGS_QWORD || (tok == MDOC_Fn && !cnt)) ? |
ntok = (ac == ARGS_QWORD || (tok == MDOC_Fn && !cnt)) ? |
MDOC_MAX : lookup(tok, p); |
MDOC_MAX : lookup(mdoc, tok, line, la, p); |
|
|
/* |
/* |
* In this case, we've located a submacro and must |
* In this case, we've located a submacro and must |
Line 1181 blk_full(MACRO_PROT_ARGS) |
|
Line 1189 blk_full(MACRO_PROT_ARGS) |
|
mdoc->flags |= MDOC_PPHRASE; |
mdoc->flags |= MDOC_PPHRASE; |
if (ac == ARGS_PEND && lac == ARGS_PPHRASE) |
if (ac == ARGS_PEND && lac == ARGS_PPHRASE) |
mdoc->flags |= MDOC_PPHRASE; |
mdoc->flags |= MDOC_PPHRASE; |
phrase(mdoc, line, &la, buf); |
parse_rest(mdoc, MDOC_MAX, line, &la, buf); |
mdoc->flags &= ~MDOC_PPHRASE; |
mdoc->flags &= ~MDOC_PPHRASE; |
continue; |
continue; |
} |
} |
Line 1388 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1396 in_line_argn(MACRO_PROT_ARGS) |
|
char *p; |
char *p; |
enum mdoct ntok; |
enum mdoct ntok; |
|
|
nl = MDOC_NEWLINE & mdoc->flags; |
nl = mdoc->flags & MDOC_NEWLINE; |
|
|
/* |
/* |
* A line macro that has a fixed number of arguments (maxargs). |
* A line macro that has a fixed number of arguments (maxargs). |
Line 1420 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1428 in_line_argn(MACRO_PROT_ARGS) |
|
|
|
mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
|
|
for (flushed = j = 0; ; ) { |
p = NULL; |
|
flushed = j = 0; |
|
for (;;) { |
la = *pos; |
la = *pos; |
ac = mdoc_args(mdoc, line, pos, buf, tok, &p); |
ac = mdoc_args(mdoc, line, pos, buf, tok, &p); |
if (ac == ARGS_PUNCT || ac == ARGS_EOLN) |
if (ac == ARGS_PUNCT || ac == ARGS_EOLN) { |
|
if (j < 2 && tok == MDOC_Pf) |
|
mandoc_vmsg(MANDOCERR_PF_SKIP, |
|
mdoc->parse, line, ppos, "Pf %s", |
|
p == NULL ? "at eol" : p); |
break; |
break; |
|
} |
|
|
if ( ! (mdoc_macros[tok].flags & MDOC_IGNDELIM) && |
if ( ! (mdoc_macros[tok].flags & MDOC_IGNDELIM) && |
ac != ARGS_QWORD && j == 0 && |
ac != ARGS_QWORD && j == 0 && |
Line 1439 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1454 in_line_argn(MACRO_PROT_ARGS) |
|
flushed = 1; |
flushed = 1; |
} |
} |
|
|
ntok = ac == ARGS_QWORD ? MDOC_MAX : lookup(tok, p); |
ntok = (ac == ARGS_QWORD || (tok == MDOC_Pf && j == 0)) ? |
|
MDOC_MAX : lookup(mdoc, tok, line, la, p); |
|
|
if (ntok != MDOC_MAX) { |
if (ntok != MDOC_MAX) { |
if ( ! flushed) |
if ( ! flushed) |
Line 1462 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1478 in_line_argn(MACRO_PROT_ARGS) |
|
j++; |
j++; |
} |
} |
|
|
if (j == 0) |
if (j == 0) { |
mdoc_elem_alloc(mdoc, line, ppos, tok, arg); |
mdoc_elem_alloc(mdoc, line, ppos, tok, arg); |
|
if (ac == ARGS_PUNCT && tok == MDOC_Pf) |
|
append_delims(mdoc, line, pos, buf); |
|
} |
if ( ! flushed) |
if ( ! flushed) |
rew_elem(mdoc, tok); |
rew_elem(mdoc, tok); |
if (nl) |
if (nl) |
Line 1473 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1492 in_line_argn(MACRO_PROT_ARGS) |
|
static void |
static void |
in_line_eoln(MACRO_PROT_ARGS) |
in_line_eoln(MACRO_PROT_ARGS) |
{ |
{ |
int la; |
|
struct mdoc_arg *arg; |
struct mdoc_arg *arg; |
|
|
if (tok == MDOC_Pp) |
if (tok == MDOC_Pp) |
Line 1481 in_line_eoln(MACRO_PROT_ARGS) |
|
Line 1499 in_line_eoln(MACRO_PROT_ARGS) |
|
|
|
mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
mdoc_argv(mdoc, line, tok, &arg, pos, buf); |
mdoc_elem_alloc(mdoc, line, ppos, tok, arg); |
mdoc_elem_alloc(mdoc, line, ppos, tok, arg); |
|
if (parse_rest(mdoc, tok, line, pos, buf)) |
|
return; |
|
rew_elem(mdoc, tok); |
|
} |
|
|
|
/* |
|
* The simplest argument parser available: Parse the remaining |
|
* words until the end of the phrase or line and return 0 |
|
* or until the next macro, call that macro, and return 1. |
|
*/ |
|
static int |
|
parse_rest(struct mdoc *mdoc, enum mdoct tok, int line, int *pos, char *buf) |
|
{ |
|
int la; |
|
|
for (;;) { |
for (;;) { |
la = *pos; |
la = *pos; |
if (mdoc_args(mdoc, line, pos, buf, tok, NULL) == ARGS_EOLN) |
if (mdoc_args(mdoc, line, pos, buf, tok, NULL) == ARGS_EOLN) |
break; |
return(0); |
if (macro_or_word(mdoc, tok, line, la, pos, buf, 1)) |
if (macro_or_word(mdoc, tok, line, la, pos, buf, 1)) |
return; |
return(1); |
} |
} |
rew_elem(mdoc, tok); |
|
} |
} |
|
|
static void |
static void |
Line 1512 ctx_synopsis(MACRO_PROT_ARGS) |
|
Line 1543 ctx_synopsis(MACRO_PROT_ARGS) |
|
* macro is encountered. |
* macro is encountered. |
*/ |
*/ |
static void |
static void |
phrase(struct mdoc *mdoc, int line, int *pos, char *buf) |
|
{ |
|
int la; |
|
|
|
do |
|
la = *pos; |
|
while (mdoc_args(mdoc, line, pos, buf, MDOC_MAX, NULL) != ARGS_EOLN && |
|
!macro_or_word(mdoc, MDOC_MAX, line, la, pos, buf, 1)); |
|
} |
|
|
|
static void |
|
phrase_ta(MACRO_PROT_ARGS) |
phrase_ta(MACRO_PROT_ARGS) |
{ |
{ |
struct mdoc_node *n; |
struct mdoc_node *n; |
Line 1542 phrase_ta(MACRO_PROT_ARGS) |
|
Line 1562 phrase_ta(MACRO_PROT_ARGS) |
|
|
|
rew_sub(MDOC_BODY, mdoc, MDOC_It, line, ppos); |
rew_sub(MDOC_BODY, mdoc, MDOC_It, line, ppos); |
mdoc_body_alloc(mdoc, line, ppos, MDOC_It); |
mdoc_body_alloc(mdoc, line, ppos, MDOC_It); |
phrase(mdoc, line, pos, buf); |
parse_rest(mdoc, MDOC_MAX, line, pos, buf); |
} |
} |