summaryrefslogtreecommitdiffstats
path: root/generic/tclScan.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-08-19 21:12:03 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-08-19 21:12:03 (GMT)
commit7b42aece2ff4d125c9e687a18b8dc775e6cc4172 (patch)
tree76cd978d84e7c39546540ce6800867d25c620f4d /generic/tclScan.c
parent1cbe8bf0a4251625c5a4253c5cefceaccb01d877 (diff)
downloadtcl-7b42aece2ff4d125c9e687a18b8dc775e6cc4172.zip
tcl-7b42aece2ff4d125c9e687a18b8dc775e6cc4172.tar.gz
tcl-7b42aece2ff4d125c9e687a18b8dc775e6cc4172.tar.bz2
Ensure that the %ld conversion works correctly on 64-bit platforms. [Bug 1011860]
Diffstat (limited to 'generic/tclScan.c')
-rw-r--r--generic/tclScan.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/generic/tclScan.c b/generic/tclScan.c
index 7d5b093..693fa60 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.12 2002/02/25 15:23:02 dkf Exp $
+ * RCS: @(#) $Id: tclScan.c,v 1.12.2.1 2004/08/19 21:12:04 dkf Exp $
*/
#include "tclInt.h"
@@ -371,9 +371,7 @@ ValidateFormat(interp, format, numVars, totalSubs)
switch (ch) {
case 'l':
case 'L':
-#ifndef TCL_WIDE_INT_IS_LONG
flags |= SCAN_LONGER;
-#endif
case 'h':
format += Tcl_UtfToUniChar(format, &ch);
}
@@ -704,9 +702,7 @@ Tcl_ScanObjCmd(dummy, interp, objc, objv)
switch (ch) {
case 'l':
case 'L':
-#ifndef TCL_WIDE_INT_IS_LONG
flags |= SCAN_LONGER;
-#endif
/*
* Fall through so we skip to the next character.
*/
@@ -1040,12 +1036,11 @@ Tcl_ScanObjCmd(dummy, interp, objc, objv)
if ((flags & SCAN_UNSIGNED) && (value < 0)) {
sprintf(buf, "%lu", value); /* INTL: ISO digit */
objPtr = Tcl_NewStringObj(buf, -1);
+ } else if ((flags & SCAN_LONGER)
+ || (unsigned long) value > UINT_MAX) {
+ objPtr = Tcl_NewLongObj(value);
} else {
- if ((unsigned long) value > UINT_MAX) {
- objPtr = Tcl_NewLongObj(value);
- } else {
- objPtr = Tcl_NewIntObj(value);
- }
+ objPtr = Tcl_NewIntObj(value);
}
#ifndef TCL_WIDE_INT_IS_LONG
}