version 1.227, 2018/12/14 05:18:02 |
version 1.228, 2018/12/21 17:15:19 |
Line 49 static void dword(struct roff_man *, int, int, const |
|
Line 49 static void dword(struct roff_man *, int, int, const |
|
static int find_pending(struct roff_man *, enum roff_tok, |
static int find_pending(struct roff_man *, enum roff_tok, |
int, int, struct roff_node *); |
int, int, struct roff_node *); |
static int lookup(struct roff_man *, int, int, int, const char *); |
static int lookup(struct roff_man *, int, int, int, const char *); |
static int macro_or_word(MACRO_PROT_ARGS, int); |
static int macro_or_word(MACRO_PROT_ARGS, char *, int); |
static void break_intermediate(struct roff_node *, |
static void break_intermediate(struct roff_node *, |
struct roff_node *); |
struct roff_node *); |
static int parse_rest(struct roff_man *, enum roff_tok, |
static int parse_rest(struct roff_man *, enum roff_tok, |
Line 474 append_delims(struct roff_man *mdoc, int line, int *po |
|
Line 474 append_delims(struct roff_man *mdoc, int line, int *po |
|
{ |
{ |
char *p; |
char *p; |
int la; |
int la; |
|
enum margserr ac; |
|
|
if (buf[*pos] == '\0') |
if (buf[*pos] == '\0') |
return; |
return; |
|
|
for (;;) { |
for (;;) { |
la = *pos; |
la = *pos; |
if (mdoc_args(mdoc, line, pos, buf, TOKEN_NONE, &p) == |
ac = mdoc_args(mdoc, line, pos, buf, TOKEN_NONE, &p); |
ARGS_EOLN) |
if (ac == ARGS_EOLN) |
break; |
break; |
dword(mdoc, line, la, p, DELIM_MAX, 1); |
dword(mdoc, line, la, p, DELIM_MAX, 1); |
|
|
Line 499 append_delims(struct roff_man *mdoc, int line, int *po |
|
Line 500 append_delims(struct roff_man *mdoc, int line, int *po |
|
|
|
if (mandoc_eos(p, strlen(p))) |
if (mandoc_eos(p, strlen(p))) |
mdoc->last->flags |= NODE_EOS; |
mdoc->last->flags |= NODE_EOS; |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
} |
} |
} |
} |
|
|
Line 508 append_delims(struct roff_man *mdoc, int line, int *po |
|
Line 511 append_delims(struct roff_man *mdoc, int line, int *po |
|
* Otherwise, allocate it and return 0. |
* Otherwise, allocate it and return 0. |
*/ |
*/ |
static int |
static int |
macro_or_word(MACRO_PROT_ARGS, int parsed) |
macro_or_word(MACRO_PROT_ARGS, char *p, int parsed) |
{ |
{ |
char *p; |
|
int ntok; |
int ntok; |
|
|
p = buf + ppos; |
ntok = buf[ppos] == '"' || parsed == 0 || |
ntok = TOKEN_NONE; |
mdoc->flags & MDOC_PHRASELIT ? TOKEN_NONE : |
if (*p == '"') |
lookup(mdoc, tok, line, ppos, p); |
p++; |
|
else if (parsed && ! (mdoc->flags & MDOC_PHRASELIT)) |
|
ntok = lookup(mdoc, tok, line, ppos, p); |
|
|
|
if (ntok == TOKEN_NONE) { |
if (ntok == TOKEN_NONE) { |
dword(mdoc, line, ppos, p, DELIM_MAX, tok == TOKEN_NONE || |
dword(mdoc, line, ppos, p, DELIM_MAX, tok == TOKEN_NONE || |
Line 720 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 719 blk_exp_close(MACRO_PROT_ARGS) |
|
if (ntok == TOKEN_NONE) { |
if (ntok == TOKEN_NONE) { |
dword(mdoc, line, lastarg, p, DELIM_MAX, |
dword(mdoc, line, lastarg, p, DELIM_MAX, |
mdoc_macro(tok)->flags & MDOC_JOIN); |
mdoc_macro(tok)->flags & MDOC_JOIN); |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
continue; |
continue; |
} |
} |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
|
|
if (n != NULL) |
if (n != NULL) |
rew_last(mdoc, n); |
rew_last(mdoc, n); |
Line 836 in_line(MACRO_PROT_ARGS) |
|
Line 839 in_line(MACRO_PROT_ARGS) |
|
line, la, pos, buf); |
line, la, pos, buf); |
if (nl) |
if (nl) |
append_delims(mdoc, line, pos, buf); |
append_delims(mdoc, line, pos, buf); |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
return; |
return; |
} |
} |
|
|
Line 879 in_line(MACRO_PROT_ARGS) |
|
Line 884 in_line(MACRO_PROT_ARGS) |
|
dword(mdoc, line, la, p, d, |
dword(mdoc, line, la, p, d, |
mdoc_macro(tok)->flags & MDOC_JOIN); |
mdoc_macro(tok)->flags & MDOC_JOIN); |
|
|
|
if (ac == ARGS_ALLOC) |
|
free(p); |
|
|
/* |
/* |
* If the first argument is a closing delimiter, |
* If the first argument is a closing delimiter, |
* do not suppress spacing before it. |
* do not suppress spacing before it. |
Line 929 in_line(MACRO_PROT_ARGS) |
|
Line 937 in_line(MACRO_PROT_ARGS) |
|
static void |
static void |
blk_full(MACRO_PROT_ARGS) |
blk_full(MACRO_PROT_ARGS) |
{ |
{ |
int la, nl, parsed; |
int done, la, nl, parsed; |
struct mdoc_arg *arg; |
struct mdoc_arg *arg; |
struct roff_node *blk; /* Our own or a broken block. */ |
struct roff_node *blk; /* Our own or a broken block. */ |
struct roff_node *head; /* Our own head. */ |
struct roff_node *head; /* Our own head. */ |
Line 1095 blk_full(MACRO_PROT_ARGS) |
|
Line 1103 blk_full(MACRO_PROT_ARGS) |
|
if (tok == MDOC_Bd || tok == MDOC_Bk) { |
if (tok == MDOC_Bd || tok == MDOC_Bk) { |
mandoc_msg(MANDOCERR_ARG_EXCESS, line, la, |
mandoc_msg(MANDOCERR_ARG_EXCESS, line, la, |
"%s ... %s", roff_name[tok], buf + la); |
"%s ... %s", roff_name[tok], buf + la); |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
break; |
break; |
} |
} |
if (tok == MDOC_Rs) { |
if (tok == MDOC_Rs) { |
mandoc_msg(MANDOCERR_ARG_SKIP, |
mandoc_msg(MANDOCERR_ARG_SKIP, |
line, la, "Rs %s", buf + la); |
line, la, "Rs %s", buf + la); |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
break; |
break; |
} |
} |
if (ac == ARGS_PUNCT) |
if (ac == ARGS_PUNCT) |
Line 1114 blk_full(MACRO_PROT_ARGS) |
|
Line 1126 blk_full(MACRO_PROT_ARGS) |
|
ac != ARGS_PHRASE && |
ac != ARGS_PHRASE && |
mdoc_isdelim(p) == DELIM_OPEN) { |
mdoc_isdelim(p) == DELIM_OPEN) { |
dword(mdoc, line, la, p, DELIM_OPEN, 0); |
dword(mdoc, line, la, p, DELIM_OPEN, 0); |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
continue; |
continue; |
} |
} |
|
|
Line 1145 blk_full(MACRO_PROT_ARGS) |
|
Line 1159 blk_full(MACRO_PROT_ARGS) |
|
continue; |
continue; |
} |
} |
|
|
if (macro_or_word(mdoc, tok, line, la, pos, buf, parsed)) |
done = macro_or_word(mdoc, tok, line, la, pos, buf, p, parsed); |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
|
if (done) |
break; |
break; |
} |
} |
|
|
|
|
static void |
static void |
blk_part_imp(MACRO_PROT_ARGS) |
blk_part_imp(MACRO_PROT_ARGS) |
{ |
{ |
int la, nl; |
int done, la, nl; |
enum margserr ac; |
enum margserr ac; |
char *p; |
char *p; |
struct roff_node *blk; /* saved block context */ |
struct roff_node *blk; /* saved block context */ |
Line 1210 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1227 blk_part_imp(MACRO_PROT_ARGS) |
|
|
|
if (body == NULL && mdoc_isdelim(p) == DELIM_OPEN) { |
if (body == NULL && mdoc_isdelim(p) == DELIM_OPEN) { |
dword(mdoc, line, la, p, DELIM_OPEN, 0); |
dword(mdoc, line, la, p, DELIM_OPEN, 0); |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
continue; |
continue; |
} |
} |
|
|
if (body == NULL) |
if (body == NULL) |
body = roff_body_alloc(mdoc, line, ppos, tok); |
body = roff_body_alloc(mdoc, line, ppos, tok); |
|
|
if (macro_or_word(mdoc, tok, line, la, pos, buf, 1)) |
done = macro_or_word(mdoc, tok, line, la, pos, buf, p, 1); |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
|
if (done) |
break; |
break; |
} |
} |
if (body == NULL) |
if (body == NULL) |
Line 1241 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1263 blk_part_imp(MACRO_PROT_ARGS) |
|
static void |
static void |
blk_part_exp(MACRO_PROT_ARGS) |
blk_part_exp(MACRO_PROT_ARGS) |
{ |
{ |
int la, nl; |
int done, la, nl; |
enum margserr ac; |
enum margserr ac; |
struct roff_node *head; /* keep track of head */ |
struct roff_node *head; /* keep track of head */ |
char *p; |
char *p; |
Line 1266 blk_part_exp(MACRO_PROT_ARGS) |
|
Line 1288 blk_part_exp(MACRO_PROT_ARGS) |
|
|
|
if (head == NULL && mdoc_isdelim(p) == DELIM_OPEN) { |
if (head == NULL && mdoc_isdelim(p) == DELIM_OPEN) { |
dword(mdoc, line, la, p, DELIM_OPEN, 0); |
dword(mdoc, line, la, p, DELIM_OPEN, 0); |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
continue; |
continue; |
} |
} |
|
|
Line 1275 blk_part_exp(MACRO_PROT_ARGS) |
|
Line 1299 blk_part_exp(MACRO_PROT_ARGS) |
|
dword(mdoc, line, la, p, DELIM_MAX, 0); |
dword(mdoc, line, la, p, DELIM_MAX, 0); |
rew_last(mdoc, head); |
rew_last(mdoc, head); |
roff_body_alloc(mdoc, line, ppos, tok); |
roff_body_alloc(mdoc, line, ppos, tok); |
if (tok == MDOC_Eo) |
if (tok == MDOC_Eo) { |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
continue; |
continue; |
|
} |
} |
} |
|
|
if (macro_or_word(mdoc, tok, line, la, pos, buf, 1)) |
done = macro_or_word(mdoc, tok, line, la, pos, buf, p, 1); |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
|
if (done) |
break; |
break; |
} |
} |
|
|
Line 1337 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1367 in_line_argn(MACRO_PROT_ARGS) |
|
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_WORD && state == -1 && |
if ((ac == ARGS_WORD || ac == ARGS_ALLOC) && state == -1 && |
(mdoc_macro(tok)->flags & MDOC_IGNDELIM) == 0 && |
(mdoc_macro(tok)->flags & MDOC_IGNDELIM) == 0 && |
mdoc_isdelim(p) == DELIM_OPEN) { |
mdoc_isdelim(p) == DELIM_OPEN) { |
dword(mdoc, line, la, p, DELIM_OPEN, 0); |
dword(mdoc, line, la, p, DELIM_OPEN, 0); |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
continue; |
continue; |
} |
} |
|
|
Line 1373 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1405 in_line_argn(MACRO_PROT_ARGS) |
|
} |
} |
(*mdoc_macro(ntok)->fp)(mdoc, ntok, |
(*mdoc_macro(ntok)->fp)(mdoc, ntok, |
line, la, pos, buf); |
line, la, pos, buf); |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
break; |
break; |
} |
} |
|
|
Line 1390 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1424 in_line_argn(MACRO_PROT_ARGS) |
|
|
|
dword(mdoc, line, la, p, DELIM_MAX, |
dword(mdoc, line, la, p, DELIM_MAX, |
mdoc_macro(tok)->flags & MDOC_JOIN); |
mdoc_macro(tok)->flags & MDOC_JOIN); |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
|
p = mdoc->last->string; |
} |
} |
|
|
if (state == -1) { |
if (state == -1) { |
|
|
parse_rest(struct roff_man *mdoc, enum roff_tok tok, |
parse_rest(struct roff_man *mdoc, enum roff_tok tok, |
int line, int *pos, char *buf) |
int line, int *pos, char *buf) |
{ |
{ |
int la; |
char *p; |
|
int done, la; |
|
enum margserr ac; |
|
|
for (;;) { |
for (;;) { |
la = *pos; |
la = *pos; |
if (mdoc_args(mdoc, line, pos, buf, tok, NULL) == ARGS_EOLN) |
ac = mdoc_args(mdoc, line, pos, buf, tok, &p); |
|
if (ac == ARGS_EOLN) |
return 0; |
return 0; |
if (macro_or_word(mdoc, tok, line, la, pos, buf, 1)) |
done = macro_or_word(mdoc, tok, line, la, pos, buf, p, 1); |
|
if (ac == ARGS_ALLOC) |
|
free(p); |
|
if (done) |
return 1; |
return 1; |
} |
} |
} |
} |