version 1.52, 2014/10/12 19:31:41 |
version 1.54, 2014/10/16 01:11:20 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> |
|
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
Line 486 eqn_tok_parse(struct eqn_node *ep, char **p) |
|
Line 487 eqn_tok_parse(struct eqn_node *ep, char **p) |
|
{ |
{ |
const char *start; |
const char *start; |
size_t i, sz; |
size_t i, sz; |
|
int quoted; |
|
|
if (NULL != p) |
if (NULL != p) |
*p = NULL; |
*p = NULL; |
|
|
|
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 (p != NULL) |
|
*p = mandoc_strndup(start, sz); |
|
return(EQN_TOK__MAX); |
|
} |
|
|
for (i = 0; i < EQN_TOK__MAX; i++) { |
for (i = 0; i < EQN_TOK__MAX; i++) { |
if (NULL == eqn_toks[i]) |
if (NULL == eqn_toks[i]) |
continue; |
continue; |
Line 578 eqn_box_makebinary(struct eqn_node *ep, |
|
Line 588 eqn_box_makebinary(struct eqn_node *ep, |
|
} |
} |
|
|
/* |
/* |
|
* Parse the "delim" control statement. |
|
*/ |
|
static void |
|
eqn_delim(struct eqn_node *ep) |
|
{ |
|
const char *start; |
|
size_t sz; |
|
|
|
if ((start = eqn_nextrawtok(ep, &sz)) == NULL) |
|
mandoc_msg(MANDOCERR_REQ_EMPTY, ep->parse, |
|
ep->eqn.ln, ep->eqn.pos, "delim"); |
|
else if (strncmp(start, "off", 3) == 0) |
|
ep->delim = 0; |
|
else if (strncmp(start, "on", 2) == 0) { |
|
if (ep->odelim && ep->cdelim) |
|
ep->delim = 1; |
|
} else if (start[1] != '\0') { |
|
ep->odelim = start[0]; |
|
ep->cdelim = start[1]; |
|
ep->delim = 1; |
|
} |
|
} |
|
|
|
/* |
* Undefine a previously-defined string. |
* Undefine a previously-defined string. |
*/ |
*/ |
static int |
static int |
|
|
EQN_MSG(MANDOCERR_EQNEOF, ep); |
EQN_MSG(MANDOCERR_EQNEOF, ep); |
break; |
break; |
case (EQN_TOK_DELIM): |
case (EQN_TOK_DELIM): |
|
eqn_delim(ep); |
|
break; |
case (EQN_TOK_GFONT): |
case (EQN_TOK_GFONT): |
if (eqn_nextrawtok(ep, NULL) == NULL) |
if (eqn_nextrawtok(ep, NULL) == NULL) |
mandoc_msg(MANDOCERR_REQ_EMPTY, ep->parse, |
mandoc_msg(MANDOCERR_REQ_EMPTY, ep->parse, |