diff options
Diffstat (limited to 'roff.c')
-rw-r--r-- | roff.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -1360,7 +1360,7 @@ roff_ds(ROFF_ARGS) } void -roff_setreg(struct roff *r, const char *name, int val) +roff_setreg(struct roff *r, const char *name, int val, char sign) { struct roffreg *reg; @@ -1375,11 +1375,17 @@ roff_setreg(struct roff *r, const char *name, int val) reg = mandoc_malloc(sizeof(struct roffreg)); reg->key.p = mandoc_strdup(name); reg->key.sz = strlen(name); + reg->val = 0; reg->next = r->regtab; r->regtab = reg; } - reg->val = val; + if ('+' == sign) + reg->val += val; + else if ('-' == sign) + reg->val -= val; + else + reg->val = val; } int @@ -1426,14 +1432,21 @@ roff_nr(ROFF_ARGS) { const char *key; char *val; + size_t sz; int iv; + char sign; val = *bufp + pos; key = roff_getname(r, &val, ln, pos); - iv = mandoc_strntoi(val, strlen(val), 10); + sign = *val; + if ('+' == sign || '-' == sign) + val++; + + sz = strspn(val, "0123456789"); + iv = sz ? mandoc_strntoi(val, sz, 10) : 0; - roff_setreg(r, key, iv); + roff_setreg(r, key, iv, sign); return(ROFF_IGN); } |