-/* $Id: eqn.c,v 1.57 2015/01/28 21:11:53 schwarze Exp $ */
+/* $Id: eqn.c,v 1.61 2016/01/08 00:50:45 schwarze Exp $ */
/*
* Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
EQNSYM_equiv,
EQNSYM_lessequal,
EQNSYM_moreequal,
+ EQNSYM_minus,
EQNSYM__MAX
};
{ "cdot", "pc" }, /* EQNSYM_cdot */
{ "nothing", "&" }, /* EQNSYM_nothing */
{ "approx", "~~" }, /* EQNSYM_approx */
- { "prime", "aq" }, /* EQNSYM_prime */
+ { "prime", "fm" }, /* EQNSYM_prime */
{ "half", "12" }, /* EQNSYM_half */
{ "partial", "pd" }, /* EQNSYM_partial */
{ "inf", "if" }, /* EQNSYM_inf */
{ "==", "==" }, /* EQNSYM_equiv */
{ "<=", "<=" }, /* EQNSYM_lessequal */
{ ">=", ">=" }, /* EQNSYM_moreequal */
+ { "-", "mi" }, /* EQNSYM_minus */
};
static struct eqn_box *eqn_box_alloc(struct eqn_node *, struct eqn_box *);
while (' ' == *p || '\t' == *p)
p++;
if ('\0' == *p)
- return(er);
+ return er;
mandoc_vmsg(MANDOCERR_ARG_SKIP, ep->parse,
ln, pos, "EN %s", p);
- return(er);
+ return er;
}
/*
ep->sz += sz;
strlcat(ep->data, p + pos, ep->sz + 1);
strlcat(ep->data, " ", ep->sz + 1);
- return(ROFF_IGN);
+ return ROFF_IGN;
}
struct eqn_node *
p->eqn.pos = pos;
p->gsize = EQN_DEFSIZE;
- return(p);
+ return p;
}
/*
for (i = 0; i < (int)ep->defsz; i++)
if (ep->defs[i].keysz && STRNEQ(ep->defs[i].key,
ep->defs[i].keysz, key, sz))
- return(&ep->defs[i]);
+ return &ep->defs[i];
- return(NULL);
+ return NULL;
}
/*
if (lim >= EQN_NEST_MAX) {
mandoc_msg(MANDOCERR_ROFFLOOP, ep->parse,
ep->eqn.ln, ep->eqn.pos, NULL);
- return(NULL);
+ return NULL;
}
ep->cur = ep->rew;
q = 0;
if ('\0' == *start)
- return(NULL);
+ return NULL;
if (quote == *start) {
ep->cur++;
/* Quotes aren't expanded for values. */
if (q || ! repl)
- return(start);
+ return start;
if (NULL != (def = eqn_def_find(ep, start, *sz))) {
diff = def->valsz - *sz;
memmove(start + *sz + diff, start + *sz,
(strlen(start) - *sz) + 1);
memcpy(start, def->val, def->valsz);
+ lim++;
goto again;
}
- return(start);
+ return start;
}
/*
eqn_nexttok(struct eqn_node *ep, size_t *sz)
{
- return(eqn_next(ep, '"', sz, 1));
+ return eqn_next(ep, '"', sz, 1);
}
/*
eqn_nextrawtok(struct eqn_node *ep, size_t *sz)
{
- return(eqn_next(ep, '"', sz, 0));
+ return eqn_next(ep, '"', sz, 0);
}
/*
quoted = ep->data[ep->cur] == '"';
if (NULL == (start = eqn_nexttok(ep, &sz)))
- return(EQN_TOK_EOF);
+ return EQN_TOK_EOF;
if (quoted) {
if (p != NULL)
*p = mandoc_strndup(start, sz);
- return(EQN_TOK__MAX);
+ return EQN_TOK__MAX;
}
for (i = 0; i < EQN_TOK__MAX; i++) {
if (i == EQN_TOK__MAX && NULL != p)
*p = mandoc_strndup(start, sz);
- return(i);
+ return i;
}
static void
parent->first = bp;
parent->last = bp;
- return(bp);
+ return bp;
}
/*
newb->first = newb->last = b;
newb->first->next = NULL;
b->parent = newb;
- return(newb);
+ return newb;
}
/*
*/
if (ep->data == NULL)
- return(ROFF_IGN);
+ return ROFF_IGN;
next_tok:
tok = eqn_tok_parse(ep, &p);
parent->right = mandoc_strndup(start, sz);
}
parent = parent->parent;
- if (EQN_TOK_BRACE_CLOSE == tok && parent &&
+ if (tok == EQN_TOK_BRACE_CLOSE &&
(parent->type == EQN_PILE ||
parent->type == EQN_MATRIX))
parent = parent->parent;
* End of file!
* TODO: make sure we're not in an open subexpression.
*/
- return(ROFF_EQN);
+ return ROFF_EQN;
default:
assert(tok == EQN_TOK__MAX);
assert(NULL != p);
ep->eqn.root = mandoc_calloc(1, sizeof(struct eqn_box));
ep->eqn.root->expectargs = UINT_MAX;
- return(eqn_parse(ep, ep->eqn.root));
+ return eqn_parse(ep, ep->eqn.root);
}
void