diff options
author | hobbs <hobbs@noemail.net> | 2001-09-20 01:03:08 (GMT) |
---|---|---|
committer | hobbs <hobbs@noemail.net> | 2001-09-20 01:03:08 (GMT) |
commit | f1eb55df231122e0d865cfb354f8331aad0f37b7 (patch) | |
tree | 3d9d23e524722e06cf15681524b4db6900855fa4 /generic/tclScan.c | |
parent | ea239e709b93f871bdb9c9af45b15d198223af46 (diff) | |
download | tcl-f1eb55df231122e0d865cfb354f8331aad0f37b7.zip tcl-f1eb55df231122e0d865cfb354f8331aad0f37b7.tar.gz tcl-f1eb55df231122e0d865cfb354f8331aad0f37b7.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)
FossilOrigin-Name: faf16960975465b15abcf102bd1aa3ce3c1d5c92
Diffstat (limited to 'generic/tclScan.c')
-rw-r--r-- | generic/tclScan.c | 17 |
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; |