summaryrefslogtreecommitdiffstats
path: root/generic/tclScan.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-08-19 20:58:59 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-08-19 20:58:59 (GMT)
commit2eb24794969d407846d80bce8ca07c486fb4ab0b (patch)
tree2d82ec9d0255996bf2683f03bceeebbeb36a320f /generic/tclScan.c
parentaedff4653c66d0c490a35ac117de3e4bee784f4f (diff)
downloadtcl-2eb24794969d407846d80bce8ca07c486fb4ab0b.zip
tcl-2eb24794969d407846d80bce8ca07c486fb4ab0b.tar.gz
tcl-2eb24794969d407846d80bce8ca07c486fb4ab0b.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 47d40bd..69e4170 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.14 2004/05/27 13:18:53 dkf Exp $
+ * RCS: @(#) $Id: tclScan.c,v 1.15 2004/08/19 20:59:00 dkf Exp $
*/
#include "tclInt.h"
@@ -367,9 +367,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);
}
@@ -700,9 +698,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.
*/
@@ -1036,12 +1032,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
}