diff options
-rw-r--r-- | chars.c | 4 | ||||
-rw-r--r-- | eqn.7 | 1 | ||||
-rw-r--r-- | eqn.c | 14 | ||||
-rw-r--r-- | libmandoc.h | 2 | ||||
-rw-r--r-- | mandoc.c | 11 | ||||
-rw-r--r-- | mandoc.h | 2 | ||||
-rw-r--r-- | roff.c | 2 | ||||
-rw-r--r-- | tree.c | 10 |
8 files changed, 31 insertions, 15 deletions
@@ -111,7 +111,7 @@ mchars_num2char(const char *p, size_t sz) { int i; - if ((i = mandoc_strntou(p, sz, 10)) < 0) + if ((i = mandoc_strntoi(p, sz, 10)) < 0) return('\0'); return(isprint(i) ? i : '\0'); } @@ -121,7 +121,7 @@ mchars_num2uc(const char *p, size_t sz) { int i; - if ((i = mandoc_strntou(p, sz, 16)) < 0) + if ((i = mandoc_strntoi(p, sz, 16)) < 0) return('\0'); /* FIXME: make sure we're not in a bogus range. */ return(i > 0x80 && i <= 0x10FFFF ? i : '\0'); @@ -70,6 +70,7 @@ box : text | box pos box | box mark | font box + | SIZE text box text : TEXT pos : OVER | SUP @@ -19,6 +19,7 @@ #endif #include <assert.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -188,7 +189,7 @@ eqn_box(struct eqn_node *ep, struct eqn_box *last, struct eqn_box **sv) { size_t sz; const char *start; - int c, i, nextc; + int c, i, nextc, size; enum eqn_fontt font; struct eqn_box *bp; @@ -201,6 +202,7 @@ eqn_box(struct eqn_node *ep, struct eqn_box *last, struct eqn_box **sv) *sv = last; nextc = 1; font = EQNFONT_NONE; + size = EQN_DEFSIZE; again: if (NULL == (start = eqn_nexttok(ep, &sz))) return(0); @@ -242,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; diff --git a/libmandoc.h b/libmandoc.h index 0e79ca99..7a79257a 100644 --- a/libmandoc.h +++ b/libmandoc.h @@ -49,7 +49,7 @@ char *mandoc_normdate(struct mparse *, char *, int, int); int mandoc_eos(const char *, size_t, int); int mandoc_hyph(const char *, const char *); int mandoc_getcontrol(const char *, int *); -int mandoc_strntou(const char *, size_t, int); +int mandoc_strntoi(const char *, size_t, int); void mdoc_free(struct mdoc *); struct mdoc *mdoc_alloc(struct roff *, struct mparse *); @@ -698,7 +698,7 @@ mandoc_getcontrol(const char *cp, int *ppos) * If the string is invalid, or is less than 0, return -1. */ int -mandoc_strntou(const char *p, size_t sz, int base) +mandoc_strntoi(const char *p, size_t sz, int base) { char buf[32]; char *ep; @@ -716,11 +716,10 @@ mandoc_strntou(const char *p, size_t sz, int base) if (buf[0] == '\0' || *ep != '\0') return(-1); - if ((errno == ERANGE && - (v == LONG_MAX || v == LONG_MIN)) || - (v > INT_MAX || v < 0)) - return(-1); + if (v > INT_MAX) + v = INT_MAX; + if (v < INT_MIN) + v = INT_MIN; return((int)v); } - @@ -322,6 +322,8 @@ enum eqn_post { * grammar. */ struct eqn_box { + int size; /* font size of expression */ +#define EQN_DEFSIZE INT_MIN enum eqn_boxt type; /* type of node */ struct eqn_box *child; /* child node */ struct eqn_box *next; /* next in tree */ @@ -1149,7 +1149,7 @@ roff_nr(ROFF_ARGS) if (0 == strcmp(key, "nS")) { r->regs[(int)REG_nS].set = 1; - if ((iv = mandoc_strntou(val, strlen(val), 10)) >= 0) + if ((iv = mandoc_strntoi(val, strlen(val), 10)) >= 0) r->regs[(int)REG_nS].u = (unsigned)iv; else r->regs[(int)REG_nS].u = 0u; @@ -19,6 +19,7 @@ #endif #include <assert.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <time.h> @@ -270,17 +271,20 @@ print_box(const struct eqn_box *ep, int indent) switch (ep->type) { case (EQN_ROOT): - printf("eqn-root(%d, %d, %d)\n", + printf("eqn-root(%d, %d, %d, %d)\n", + EQN_DEFSIZE == ep->size ? 0 : ep->size, ep->pos, ep->font, ep->mark); print_box(ep->child, indent + 1); break; case (EQN_SUBEXPR): - printf("eqn-subxpr(%d, %d, %d)\n", + printf("eqn-subxpr(%d, %d, %d, %d)\n", + EQN_DEFSIZE == ep->size ? 0 : ep->size, ep->pos, ep->font, ep->mark); print_box(ep->child, indent + 1); break; case (EQN_TEXT): - printf("eqn-text(%d, %d, %d): [%s]\n", + printf("eqn-text(%d, %d, %d, %d): [%s]\n", + EQN_DEFSIZE == ep->size ? 0 : ep->size, ep->pos, ep->font, ep->mark, ep->text); break; default: |