summaryrefslogtreecommitdiffstats
path: root/generic/tclScan.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2001-09-20 01:03:08 (GMT)
committerhobbs <hobbs>2001-09-20 01:03:08 (GMT)
commit32d25a83797b68399f879b2bbdc6555c639487eb (patch)
tree3d9d23e524722e06cf15681524b4db6900855fa4 /generic/tclScan.c
parent43ce4a3c4a76eeb1a99a53e43ec6d32433e77680 (diff)
downloadtcl-32d25a83797b68399f879b2bbdc6555c639487eb.zip
tcl-32d25a83797b68399f879b2bbdc6555c639487eb.tar.gz
tcl-32d25a83797b68399f879b2bbdc6555c639487eb.tar.bz2
* generic/tclCmdAH.c (Tcl_FormatObjCmd):
* generic/tclScan.c (Tcl_ScanObjCmd): corrected handling of format and scan on 64-bit machines. [Bug #412696] (rmax)
Diffstat (limited to 'generic/tclScan.c')
-rw-r--r--generic/tclScan.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/generic/tclScan.c b/generic/tclScan.c
index 2cd48d4..23483e7 100644
--- a/generic/tclScan.c
+++ b/generic/tclScan.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclScan.c,v 1.7 2000/12/10 03:27:04 hobbs Exp $
+ * RCS: @(#) $Id: tclScan.c,v 1.8 2001/09/20 01:03:08 hobbs Exp $
*/
#include "tclInt.h"
@@ -539,7 +539,8 @@ Tcl_ScanObjCmd(dummy, interp, objc, objv)
{
char *format;
int numVars, nconversions, totalVars = -1;
- int objIndex, offset, i, value, result, code;
+ int objIndex, offset, i, result, code;
+ long value;
char *string, *end, *baseString;
char op = 0;
int base = 0;
@@ -644,7 +645,7 @@ Tcl_ScanObjCmd(dummy, interp, objc, objv)
if (*end == '$') {
format = end+1;
format += Tcl_UtfToUniChar(format, &ch);
- objIndex = value - 1;
+ objIndex = (int) value - 1;
}
}
@@ -954,12 +955,16 @@ Tcl_ScanObjCmd(dummy, interp, objc, objv)
if (!(flags & SCAN_SUPPRESS)) {
*end = '\0';
- value = (int) (*fn)(buf, NULL, base);
+ value = (long) (*fn)(buf, NULL, base);
if ((flags & SCAN_UNSIGNED) && (value < 0)) {
- sprintf(buf, "%u", value); /* INTL: ISO digit */
+ sprintf(buf, "%lu", value); /* INTL: ISO digit */
objPtr = Tcl_NewStringObj(buf, -1);
} else {
- objPtr = Tcl_NewIntObj(value);
+ if ((unsigned long) value > UINT_MAX) {
+ objPtr = Tcl_NewLongObj(value);
+ } else {
+ objPtr = Tcl_NewIntObj(value);
+ }
}
Tcl_IncrRefCount(objPtr);
objs[objIndex++] = objPtr;