summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chars.c4
-rw-r--r--eqn.71
-rw-r--r--eqn.c14
-rw-r--r--libmandoc.h2
-rw-r--r--mandoc.c11
-rw-r--r--mandoc.h2
-rw-r--r--roff.c2
-rw-r--r--tree.c10
8 files changed, 31 insertions, 15 deletions
diff --git a/chars.c b/chars.c
index 24774eb8..dcfe2615 100644
--- a/chars.c
+++ b/chars.c
@@ -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');
diff --git a/eqn.7 b/eqn.7
index 083f2b64..3f8b7f7c 100644
--- a/eqn.7
+++ b/eqn.7
@@ -70,6 +70,7 @@ box : text
| box pos box
| box mark
| font box
+ | SIZE text box
text : TEXT
pos : OVER
| SUP
diff --git a/eqn.c b/eqn.c
index b4087f26..ca68b1b9 100644
--- a/eqn.c
+++ b/eqn.c
@@ -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 *);
diff --git a/mandoc.c b/mandoc.c
index 554c3048..6d11e9b7 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -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);
}
-
diff --git a/mandoc.h b/mandoc.h
index 68ae3b02..681a0f88 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -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 */
diff --git a/roff.c b/roff.c
index 4016ed0e..0bec5549 100644
--- a/roff.c
+++ b/roff.c
@@ -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;
diff --git a/tree.c b/tree.c
index 22f91a10..c1d7937e 100644
--- a/tree.c
+++ b/tree.c
@@ -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: