version 1.58, 2015/03/04 12:19:49 |
version 1.59, 2015/10/06 18:32:19 |
Line 302 eqn_read(struct eqn_node **epp, int ln, |
|
Line 302 eqn_read(struct eqn_node **epp, int ln, |
|
while (' ' == *p || '\t' == *p) |
while (' ' == *p || '\t' == *p) |
p++; |
p++; |
if ('\0' == *p) |
if ('\0' == *p) |
return(er); |
return er; |
mandoc_vmsg(MANDOCERR_ARG_SKIP, ep->parse, |
mandoc_vmsg(MANDOCERR_ARG_SKIP, ep->parse, |
ln, pos, "EN %s", p); |
ln, pos, "EN %s", p); |
return(er); |
return er; |
} |
} |
|
|
/* |
/* |
Line 324 eqn_read(struct eqn_node **epp, int ln, |
|
Line 324 eqn_read(struct eqn_node **epp, int ln, |
|
ep->sz += sz; |
ep->sz += sz; |
strlcat(ep->data, p + pos, ep->sz + 1); |
strlcat(ep->data, p + pos, ep->sz + 1); |
strlcat(ep->data, " ", ep->sz + 1); |
strlcat(ep->data, " ", ep->sz + 1); |
return(ROFF_IGN); |
return ROFF_IGN; |
} |
} |
|
|
struct eqn_node * |
struct eqn_node * |
Line 339 eqn_alloc(int pos, int line, struct mparse *parse) |
|
Line 339 eqn_alloc(int pos, int line, struct mparse *parse) |
|
p->eqn.pos = pos; |
p->eqn.pos = pos; |
p->gsize = EQN_DEFSIZE; |
p->gsize = EQN_DEFSIZE; |
|
|
return(p); |
return p; |
} |
} |
|
|
/* |
/* |
Line 353 eqn_def_find(struct eqn_node *ep, const char *key, siz |
|
Line 353 eqn_def_find(struct eqn_node *ep, const char *key, siz |
|
for (i = 0; i < (int)ep->defsz; i++) |
for (i = 0; i < (int)ep->defsz; i++) |
if (ep->defs[i].keysz && STRNEQ(ep->defs[i].key, |
if (ep->defs[i].keysz && STRNEQ(ep->defs[i].key, |
ep->defs[i].keysz, key, sz)) |
ep->defs[i].keysz, key, sz)) |
return(&ep->defs[i]); |
return &ep->defs[i]; |
|
|
return(NULL); |
return NULL; |
} |
} |
|
|
/* |
/* |
|
|
if (lim >= EQN_NEST_MAX) { |
if (lim >= EQN_NEST_MAX) { |
mandoc_msg(MANDOCERR_ROFFLOOP, ep->parse, |
mandoc_msg(MANDOCERR_ROFFLOOP, ep->parse, |
ep->eqn.ln, ep->eqn.pos, NULL); |
ep->eqn.ln, ep->eqn.pos, NULL); |
return(NULL); |
return NULL; |
} |
} |
|
|
ep->cur = ep->rew; |
ep->cur = ep->rew; |
|
|
q = 0; |
q = 0; |
|
|
if ('\0' == *start) |
if ('\0' == *start) |
return(NULL); |
return NULL; |
|
|
if (quote == *start) { |
if (quote == *start) { |
ep->cur++; |
ep->cur++; |
|
|
/* Quotes aren't expanded for values. */ |
/* Quotes aren't expanded for values. */ |
|
|
if (q || ! repl) |
if (q || ! repl) |
return(start); |
return start; |
|
|
if (NULL != (def = eqn_def_find(ep, start, *sz))) { |
if (NULL != (def = eqn_def_find(ep, start, *sz))) { |
diff = def->valsz - *sz; |
diff = def->valsz - *sz; |
|
|
goto again; |
goto again; |
} |
} |
|
|
return(start); |
return start; |
} |
} |
|
|
/* |
/* |
Line 462 static const char * |
|
Line 462 static const char * |
|
eqn_nexttok(struct eqn_node *ep, size_t *sz) |
eqn_nexttok(struct eqn_node *ep, size_t *sz) |
{ |
{ |
|
|
return(eqn_next(ep, '"', sz, 1)); |
return eqn_next(ep, '"', sz, 1); |
} |
} |
|
|
/* |
/* |
Line 472 static const char * |
|
Line 472 static const char * |
|
eqn_nextrawtok(struct eqn_node *ep, size_t *sz) |
eqn_nextrawtok(struct eqn_node *ep, size_t *sz) |
{ |
{ |
|
|
return(eqn_next(ep, '"', sz, 0)); |
return eqn_next(ep, '"', sz, 0); |
} |
} |
|
|
/* |
/* |
Line 498 eqn_tok_parse(struct eqn_node *ep, char **p) |
|
Line 498 eqn_tok_parse(struct eqn_node *ep, char **p) |
|
quoted = ep->data[ep->cur] == '"'; |
quoted = ep->data[ep->cur] == '"'; |
|
|
if (NULL == (start = eqn_nexttok(ep, &sz))) |
if (NULL == (start = eqn_nexttok(ep, &sz))) |
return(EQN_TOK_EOF); |
return EQN_TOK_EOF; |
|
|
if (quoted) { |
if (quoted) { |
if (p != NULL) |
if (p != NULL) |
*p = mandoc_strndup(start, sz); |
*p = mandoc_strndup(start, sz); |
return(EQN_TOK__MAX); |
return EQN_TOK__MAX; |
} |
} |
|
|
for (i = 0; i < EQN_TOK__MAX; i++) { |
for (i = 0; i < EQN_TOK__MAX; i++) { |
Line 516 eqn_tok_parse(struct eqn_node *ep, char **p) |
|
Line 516 eqn_tok_parse(struct eqn_node *ep, char **p) |
|
if (i == EQN_TOK__MAX && NULL != p) |
if (i == EQN_TOK__MAX && NULL != p) |
*p = mandoc_strndup(start, sz); |
*p = mandoc_strndup(start, sz); |
|
|
return(i); |
return i; |
} |
} |
|
|
static void |
static void |
Line 557 eqn_box_alloc(struct eqn_node *ep, struct eqn_box *par |
|
Line 557 eqn_box_alloc(struct eqn_node *ep, struct eqn_box *par |
|
parent->first = bp; |
parent->first = bp; |
|
|
parent->last = bp; |
parent->last = bp; |
return(bp); |
return bp; |
} |
} |
|
|
/* |
/* |
Line 587 eqn_box_makebinary(struct eqn_node *ep, |
|
Line 587 eqn_box_makebinary(struct eqn_node *ep, |
|
newb->first = newb->last = b; |
newb->first = newb->last = b; |
newb->first->next = NULL; |
newb->first->next = NULL; |
b->parent = newb; |
b->parent = newb; |
return(newb); |
return newb; |
} |
} |
|
|
/* |
/* |
Line 712 eqn_parse(struct eqn_node *ep, struct eqn_box *parent) |
|
Line 712 eqn_parse(struct eqn_node *ep, struct eqn_box *parent) |
|
*/ |
*/ |
|
|
if (ep->data == NULL) |
if (ep->data == NULL) |
return(ROFF_IGN); |
return ROFF_IGN; |
|
|
next_tok: |
next_tok: |
tok = eqn_tok_parse(ep, &p); |
tok = eqn_tok_parse(ep, &p); |
|
|
* End of file! |
* End of file! |
* TODO: make sure we're not in an open subexpression. |
* TODO: make sure we're not in an open subexpression. |
*/ |
*/ |
return(ROFF_EQN); |
return ROFF_EQN; |
default: |
default: |
assert(tok == EQN_TOK__MAX); |
assert(tok == EQN_TOK__MAX); |
assert(NULL != p); |
assert(NULL != p); |
Line 1104 eqn_end(struct eqn_node **epp) |
|
Line 1104 eqn_end(struct eqn_node **epp) |
|
|
|
ep->eqn.root = mandoc_calloc(1, sizeof(struct eqn_box)); |
ep->eqn.root = mandoc_calloc(1, sizeof(struct eqn_box)); |
ep->eqn.root->expectargs = UINT_MAX; |
ep->eqn.root->expectargs = UINT_MAX; |
return(eqn_parse(ep, ep->eqn.root)); |
return eqn_parse(ep, ep->eqn.root); |
} |
} |
|
|
void |
void |