From 3ee412a268eff0c9e52bb141dc3289eda00a6d53 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Thu, 21 Jul 2011 15:21:13 +0000 Subject: Support `size' constructs in eqn.7. Generalise mandoc_strontou to this effect. --- mandoc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'mandoc.c') diff --git a/mandoc.c b/mandoc.c index 465965a4..891b9511 100644 --- a/mandoc.c +++ b/mandoc.c @@ -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 * Copyright (c) 2011 Ingo Schwarze @@ -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); } - -- cgit v1.2.3