=================================================================== RCS file: /cvs/mandoc/eqn.c,v retrieving revision 1.17 retrieving revision 1.19 diff -u -p -r1.17 -r1.19 --- mandoc/eqn.c 2011/07/21 13:37:04 1.17 +++ mandoc/eqn.c 2011/07/21 15:21:13 1.19 @@ -1,4 +1,4 @@ -/* $Id: eqn.c,v 1.17 2011/07/21 13:37:04 kristaps Exp $ */ +/* $Id: eqn.c,v 1.19 2011/07/21 15:21:13 kristaps Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * @@ -19,6 +19,7 @@ #endif #include +#include #include #include #include @@ -80,11 +81,22 @@ static const struct eqnstr eqnmarks[EQNMARK__MAX] = { }; static const struct eqnstr eqnfonts[EQNFONT__MAX] = { + { "", 0 }, { "roman", 5 }, { "bold", 4 }, { "italic", 6 }, }; +static const struct eqnstr eqnposs[EQNPOS__MAX] = { + { "", 0 }, + { "over", 4 }, + { "sup", 3 }, + { "sub", 3 }, + { "to", 2 }, + { "from", 4 }, + { "above", 5 }, +}; + /* ARGSUSED */ enum rofferr eqn_read(struct eqn_node **epp, int ln, @@ -177,7 +189,7 @@ eqn_box(struct eqn_node *ep, struct eqn_box *last, str { size_t sz; const char *start; - int c, i, nextc; + int c, i, nextc, size; enum eqn_fontt font; struct eqn_box *bp; @@ -189,8 +201,8 @@ eqn_box(struct eqn_node *ep, struct eqn_box *last, str *sv = last; nextc = 1; - font = EQNFONT_NONE; - + font = EQNFONT_NONE; + size = EQN_DEFSIZE; again: if (NULL == (start = eqn_nexttok(ep, &sz))) return(0); @@ -204,6 +216,15 @@ again: goto again; } + for (i = 0; i < (int)EQNFONT__MAX; i++) { + if (eqnposs[i].sz != sz) + continue; + if (strncmp(eqnposs[i].name, start, sz)) + continue; + last->pos = (enum eqn_post)i; + goto again; + } + for (i = 0; i < (int)EQN__MAX; i++) { if (eqnparts[i].str.sz != sz) continue; @@ -223,14 +244,22 @@ again: goto again; } - /* Exit this [hopefully] subexpression. */ + if (sz == 4 && 0 == strncmp("size", start, 1)) { + if (NULL == (start = eqn_nexttok(ep, &sz))) + return(0); + size = mandoc_strntoi(start, sz, 10); + goto again; + } if (sz == 1 && 0 == strncmp("}", start, 1)) return(1); bp = mandoc_calloc(1, sizeof(struct eqn_box)); bp->font = font; + bp->size = size; + font = EQNFONT_NONE; + size = EQN_DEFSIZE; if (nextc) last->child = bp;