diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-07-21 13:18:24 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-07-21 13:18:24 +0000 |
commit | d98b3838b2d49efc6220b1dc7bdb995e37cd4d10 (patch) | |
tree | 78b6d8a9ac3e4bf00688322b73cc0728f1ee1fa1 /eqn.c | |
parent | 5bbaf34f67268b1270c7dd46448c7cf7556805f8 (diff) | |
download | mandoc-d98b3838b2d49efc6220b1dc7bdb995e37cd4d10.tar.gz |
Add support for markers. These decorate the last box: see eqn.7.
Diffstat (limited to 'eqn.c')
-rw-r--r-- | eqn.c | 38 |
1 files changed, 33 insertions, 5 deletions
@@ -37,6 +37,11 @@ struct eqnpart { int (*fp)(struct eqn_node *); }; +struct eqnmark { + const char *name; + size_t sz; +}; + enum eqnpartt { EQN_DEFINE = 0, EQN_SET, @@ -63,6 +68,18 @@ static const struct eqnpart eqnparts[EQN__MAX] = { { "undef", 5, eqn_do_undef }, /* EQN_UNDEF */ }; +static const struct eqnmark eqnmarks[EQNMARK__MAX] = { + { "", 0 }, /* EQNMARK_NONE */ + { "dot", 3 }, /* EQNMARK_DOT */ + { "dotdot", 6 }, /* EQNMARK_DOTDOT */ + { "hat", 3 }, /* EQNMARK_HAT */ + { "tilde", 5 }, /* EQNMARK_TILDE */ + { "vec", 3 }, /* EQNMARK_VEC */ + { "dyad", 4 }, /* EQNMARK_DYAD */ + { "bar", 3 }, /* EQNMARK_BAR */ + { "under", 5 }, /* EQNMARK_UNDER */ +}; + /* ARGSUSED */ enum rofferr eqn_read(struct eqn_node **epp, int ln, @@ -139,13 +156,15 @@ eqn_end(struct eqn_node *ep) * Otherwise, return the equation. */ - if ((c = eqn_box(ep, root, &last)) > 0) { + if (0 == (c = eqn_box(ep, root, &last))) { + if (last != root) { + EQN_MSG(MANDOCERR_EQNSCOPE, ep); + c = 0; + } + } else if (c > 0) EQN_MSG(MANDOCERR_EQNNSCOPE, ep); - c = 0; - } else if (0 == c && last != root) - EQN_MSG(MANDOCERR_EQNSCOPE, ep); - return(1 == c ? ROFF_EQN : ROFF_IGN); + return(0 == c ? ROFF_EQN : ROFF_IGN); } static int @@ -179,6 +198,15 @@ again: goto again; } + for (i = 0; i < (int)EQNMARK__MAX; i++) { + if (eqnmarks[i].sz != sz) + continue; + if (strncmp(eqnmarks[i].name, start, sz)) + continue; + last->mark = (enum eqn_markt)i; + goto again; + } + /* Exit this [hopefully] subexpression. */ if (sz == 1 && 0 == strncmp("}", start, 1)) |