version 1.66, 2017/06/21 20:50:50 |
version 1.67, 2017/06/22 00:30:20 |
|
|
/* $OpenBSD$ */ |
/* $Id$ |
/* |
/* |
* Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org> |
|
|
EQN_TOK_ABOVE, |
EQN_TOK_ABOVE, |
EQN_TOK__MAX, |
EQN_TOK__MAX, |
EQN_TOK_FUNC, |
EQN_TOK_FUNC, |
|
EQN_TOK_QUOTED, |
|
EQN_TOK_SYM, |
EQN_TOK_EOF |
EQN_TOK_EOF |
}; |
}; |
|
|
Line 517 eqn_tok_parse(struct eqn_node *ep, char **p) |
|
Line 519 eqn_tok_parse(struct eqn_node *ep, char **p) |
|
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_QUOTED; |
} |
} |
|
|
for (i = 0; i < EQN_TOK__MAX; i++) |
for (i = 0; i < EQN_TOK__MAX; i++) |
Line 528 eqn_tok_parse(struct eqn_node *ep, char **p) |
|
Line 530 eqn_tok_parse(struct eqn_node *ep, char **p) |
|
if (STRNEQ(start, sz, |
if (STRNEQ(start, sz, |
eqnsyms[i].str, strlen(eqnsyms[i].str))) { |
eqnsyms[i].str, strlen(eqnsyms[i].str))) { |
mandoc_asprintf(p, "\\[%s]", eqnsyms[i].sym); |
mandoc_asprintf(p, "\\[%s]", eqnsyms[i].sym); |
return EQN_TOK__MAX; |
return EQN_TOK_SYM; |
} |
} |
} |
} |
|
|
|
|
* 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; |
case EQN_TOK_FUNC: |
|
case EQN_TOK__MAX: |
case EQN_TOK__MAX: |
|
case EQN_TOK_FUNC: |
|
case EQN_TOK_QUOTED: |
|
case EQN_TOK_SYM: |
assert(p != NULL); |
assert(p != NULL); |
/* |
/* |
* If we already have something in the stack and we're |
* If we already have something in the stack and we're |
|
|
cur->text = p; |
cur->text = p; |
/* |
/* |
* If not inside any explicit font context, |
* If not inside any explicit font context, |
* give every letter its own box. |
* quoted strings become italic, and every letter |
|
* of a bare string gets its own italic box. |
*/ |
*/ |
if (fontp == NULL && *p != '\0') { |
do { |
|
if (fontp != NULL || *p == '\0' || |
|
tok == EQN_TOK_SYM) |
|
break; |
|
if (tok == EQN_TOK_QUOTED) { |
|
cur->font = EQNFONT_ITALIC; |
|
break; |
|
} |
cp = p; |
cp = p; |
for (;;) { |
for (;;) { |
|
if (isalpha((unsigned char)*cp)) |
|
cur->font = EQNFONT_ITALIC; |
cpn = cp + 1; |
cpn = cp + 1; |
if (*cp == '\\') |
if (*cp == '\\') |
mandoc_escape(&cpn, NULL, NULL); |
mandoc_escape(&cpn, NULL, NULL); |
if (*cpn == '\0') |
if (*cpn == '\0') |
break; |
break; |
if (isalpha((unsigned char)*cp) == 0 && |
if (cur->font != EQNFONT_ITALIC && |
isalpha((unsigned char)*cpn) == 0) { |
isalpha((unsigned char)*cpn) == 0) { |
cp = cpn; |
cp = cpn; |
continue; |
continue; |
|
|
cur = nbox; |
cur = nbox; |
cp = nbox->text; |
cp = nbox->text; |
} |
} |
} |
} while (0); |
/* |
/* |
* Post-process list status. |
* Post-process list status. |
*/ |
*/ |