summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdMZ.c
diff options
context:
space:
mode:
authordgp <dgp@noemail.net>2003-04-11 20:49:50 (GMT)
committerdgp <dgp@noemail.net>2003-04-11 20:49:50 (GMT)
commit297d4a22757ef3c028b621f3d0ceed663426faee (patch)
tree7db1303db34093aa5b7a152871db2616ecae2794 /generic/tclCmdMZ.c
parent537d42cf0634d607879b95c7c8ad1c026e4417dd (diff)
downloadtcl-297d4a22757ef3c028b621f3d0ceed663426faee.zip
tcl-297d4a22757ef3c028b621f3d0ceed663426faee.tar.gz
tcl-297d4a22757ef3c028b621f3d0ceed663426faee.tar.bz2
* generic/tclCmdMZ.c (Tcl_StringObjCmd,STR_IS_INT): Corrected
inconsistent results of [string is integer] observed on systems where sizeof(long) != sizeof(int). [Bug 718878] * tests/string.test: Added tests for Bug 718878. * doc/string.n: Clarified that [string is integer] accepts 32-bit integers. FossilOrigin-Name: c1cbd75c51a0d96a027348d34a444ad0acc07242
Diffstat (limited to 'generic/tclCmdMZ.c')
-rw-r--r--generic/tclCmdMZ.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 8e179ce..8c4a951 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdMZ.c,v 1.82.2.2 2003/04/07 16:54:11 dgp Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.82.2.3 2003/04/11 20:49:53 dgp Exp $
*/
#include "tclInt.h"
@@ -1659,23 +1659,20 @@ Tcl_StringObjCmd(dummy, interp, objc, objv)
break;
case STR_IS_INT: {
char *stop;
+ long int l = 0;
- if ((objPtr->typePtr == &tclIntType) ||
- (Tcl_GetInt(NULL, string1, &i) == TCL_OK)) {
+ if (TCL_OK == Tcl_GetIntFromObj(NULL, objPtr, &i)) {
break;
}
/*
* Like STR_IS_DOUBLE, but we use strtoul.
- * Since Tcl_GetInt already failed, we set result to 0.
+ * Since Tcl_GetIntFromObj already failed,
+ * we set result to 0.
*/
result = 0;
errno = 0;
-#ifdef TCL_WIDE_INT_IS_LONG
- strtoul(string1, &stop, 0); /* INTL: Tcl source. */
-#else
- strtoull(string1, &stop, 0); /* INTL: Tcl source. */
-#endif
- if (errno == ERANGE) {
+ l = strtol(string1, &stop, 0); /* INTL: Tcl source. */
+ if ((errno == ERANGE) || (l > INT_MAX) || (l < INT_MIN)) {
/*
* if (errno == ERANGE), then it was an over/underflow
* problem, but in this method, we only want to know
@@ -1683,6 +1680,7 @@ Tcl_StringObjCmd(dummy, interp, objc, objv)
* the failVarObj to the string length.
*/
failat = -1;
+
} else if (stop == string1) {
/*
* In this case, nothing like a number was found