summaryrefslogtreecommitdiff
path: root/tcl/compat/strtod.c
diff options
context:
space:
mode:
Diffstat (limited to 'tcl/compat/strtod.c')
-rw-r--r--tcl/compat/strtod.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/tcl/compat/strtod.c b/tcl/compat/strtod.c
index 19d24a1f7f7..14f97d40a66 100644
--- a/tcl/compat/strtod.c
+++ b/tcl/compat/strtod.c
@@ -12,12 +12,8 @@
* RCS: @(#) $Id$
*/
-#include "tcl.h"
-#ifdef NO_STDLIB_H
-# include "../compat/stdlib.h"
-#else
-# include <stdlib.h>
-#endif
+#include "tclInt.h"
+#include "tclPort.h"
#include <ctype.h>
#ifndef TRUE
@@ -108,7 +104,7 @@ strtod(string, endPtr)
*/
p = string;
- while (isspace(*p)) {
+ while (isspace(UCHAR(*p))) {
p += 1;
}
if (*p == '-') {
@@ -206,7 +202,11 @@ strtod(string, endPtr)
}
expSign = FALSE;
}
- while (isdigit(*p)) {
+ if (!isdigit(UCHAR(*p))) {
+ p = pExp;
+ goto done;
+ }
+ while (isdigit(UCHAR(*p))) {
exp = exp * 10 + (*p - '0');
p += 1;
}
@@ -232,6 +232,7 @@ strtod(string, endPtr)
}
if (exp > maxExponent) {
exp = maxExponent;
+ errno = ERANGE;
}
dblExp = 1.0;
for (d = powersOf10; exp != 0; exp >>= 1, d += 1) {