diff options
-rw-r--r-- | chars.c | 6 | ||||
-rw-r--r-- | eqn.7 | 3 | ||||
-rw-r--r-- | eqn.c | 16 | ||||
-rw-r--r-- | libmandoc.h | 4 | ||||
-rw-r--r-- | mandoc.c | 13 | ||||
-rw-r--r-- | mandoc.h | 4 | ||||
-rw-r--r-- | roff.c | 4 | ||||
-rw-r--r-- | tree.c | 12 |
8 files changed, 39 insertions, 23 deletions
@@ -1,4 +1,4 @@ -/* $Id: chars.c,v 1.47 2011/07/07 06:41:50 kristaps Exp $ */ +/* $Id: chars.c,v 1.48 2011/07/21 15:21:13 kristaps Exp $ */ /* * Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -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'); @@ -1,4 +1,4 @@ -.\" $Id: eqn.7,v 1.11 2011/07/21 14:13:00 kristaps Exp $ +.\" $Id: eqn.7,v 1.12 2011/07/21 15:21:13 kristaps Exp $ .\" .\" Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> .\" @@ -70,6 +70,7 @@ box : text | box pos box | box mark | font box + | SIZE text box text : TEXT pos : OVER | SUP @@ -1,4 +1,4 @@ -/* $Id: eqn.c,v 1.18 2011/07/21 14:13:00 kristaps Exp $ */ +/* $Id: eqn.c,v 1.19 2011/07/21 15:21:13 kristaps Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -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 737f70fe..ad3ed254 100644 --- a/libmandoc.h +++ b/libmandoc.h @@ -1,4 +1,4 @@ -/* $Id: libmandoc.h,v 1.23 2011/07/18 07:46:41 kristaps Exp $ */ +/* $Id: libmandoc.h,v 1.24 2011/07/21 15:21:13 kristaps Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -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 *); @@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.53 2011/05/24 21:31:23 kristaps Exp $ */ +/* $Id: mandoc.c,v 1.54 2011/07/21 15:21:13 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -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); } - @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.87 2011/07/21 14:13:00 kristaps Exp $ */ +/* $Id: mandoc.h,v 1.88 2011/07/21 15:21:13 kristaps Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -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 */ @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.148 2011/07/21 10:24:35 kristaps Exp $ */ +/* $Id: roff.c,v 1.149 2011/07/21 15:21:13 kristaps Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -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; @@ -1,4 +1,4 @@ -/* $Id: tree.c,v 1.42 2011/07/21 14:13:00 kristaps Exp $ */ +/* $Id: tree.c,v 1.43 2011/07/21 15:21:13 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -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: |