diff options
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; |