summaryrefslogtreecommitdiffstats
path: root/compat
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2002-02-15 23:42:12 (GMT)
committerKevin B Kenny <kennykb@acm.org>2002-02-15 23:42:12 (GMT)
commitb5e9e40d2f0d57b15ea03e954e1c2085b9874fed (patch)
tree87a231b742d00bcbf481e3439acb70032c612370 /compat
parent097b4b7f2e14a0d47f82c9d8b7579bee651660b4 (diff)
downloadtcl-b5e9e40d2f0d57b15ea03e954e1c2085b9874fed.zip
tcl-b5e9e40d2f0d57b15ea03e954e1c2085b9874fed.tar.gz
tcl-b5e9e40d2f0d57b15ea03e954e1c2085b9874fed.tar.bz2
Further changes to the TIP 72 patch to make it compile under VC++
Diffstat (limited to 'compat')
-rw-r--r--compat/strtoll.c4
-rw-r--r--compat/strtoul.c6
-rw-r--r--compat/strtoull.c20
3 files changed, 21 insertions, 9 deletions
diff --git a/compat/strtoll.c b/compat/strtoll.c
index 2872006..1105040 100644
--- a/compat/strtoll.c
+++ b/compat/strtoll.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: strtoll.c,v 1.2 2002/02/15 14:28:47 dkf Exp $
+ * RCS: @(#) $Id: strtoll.c,v 1.3 2002/02/15 23:42:12 kennykb Exp $
*/
#include "tcl.h"
@@ -82,7 +82,7 @@ strtoll(string, endPtr, base)
} else if (uwResult > TCL_WIDEINT_MAX) {
return ~((Tcl_WideInt)TCL_WIDEINT_MAX);
} else {
- result = -uwResult;
+ result = -((Tcl_WideInt) uwResult);
}
}
} else {
diff --git a/compat/strtoul.c b/compat/strtoul.c
index 3b7918c..e31299d 100644
--- a/compat/strtoul.c
+++ b/compat/strtoul.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: strtoul.c,v 1.2 1998/09/14 18:39:45 stanton Exp $
+ * RCS: @(#) $Id: strtoul.c,v 1.3 2002/02/15 23:42:12 kennykb Exp $
*/
#include <ctype.h>
@@ -152,14 +152,14 @@ strtoul(string, endPtr, base)
result = (result << 4) + digit;
anyDigits = 1;
}
- } else {
+ } else if ( base >= 2 && base <= 36 ) {
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > ('z' - '0')) {
break;
}
digit = cvtIn[digit];
- if (digit >= base) {
+ if (digit >= ( (unsigned) base )) {
break;
}
result = result*base + digit;
diff --git a/compat/strtoull.c b/compat/strtoull.c
index 8658eb0..af508d0 100644
--- a/compat/strtoull.c
+++ b/compat/strtoull.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: strtoull.c,v 1.2 2002/02/15 14:28:47 dkf Exp $
+ * RCS: @(#) $Id: strtoull.c,v 1.3 2002/02/15 23:42:12 kennykb Exp $
*/
#include "tcl.h"
@@ -149,6 +149,9 @@ strtoull(string, endPtr, base)
goto overflow;
}
result = shifted + digit;
+ if ( result < shifted ) {
+ goto overflow;
+ }
anyDigits = 1;
}
} else if (base == 10) {
@@ -162,6 +165,9 @@ strtoull(string, endPtr, base)
goto overflow;
}
result = shifted + digit;
+ if ( result < shifted ) {
+ goto overflow;
+ }
anyDigits = 1;
}
} else if (base == 16) {
@@ -179,16 +185,19 @@ strtoull(string, endPtr, base)
goto overflow;
}
result = shifted + digit;
+ if ( result < shifted ) {
+ goto overflow;
+ }
anyDigits = 1;
}
- } else {
+ } else if ( base >= 2 && base <= 36 ) {
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > ('z' - '0')) {
break;
}
digit = cvtIn[digit];
- if (digit >= base) {
+ if (digit >= (unsigned) base) {
break;
}
shifted = result * base;
@@ -196,6 +205,9 @@ strtoull(string, endPtr, base)
goto overflow;
}
result = shifted + digit;
+ if ( result < shifted ) {
+ goto overflow;
+ }
anyDigits = 1;
}
}
@@ -235,7 +247,7 @@ strtoull(string, endPtr, base)
break;
}
digit = cvtIn[digit];
- if (digit >= base) {
+ if (digit >= (unsigned) base) {
break;
}
}