summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2003-05-14 22:45:10 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2003-05-14 22:45:10 (GMT)
commit3863b1c0eac186a8e9cb66952c457082ef00ac8d (patch)
treebdea045bc5f7963a4fb6247c17f8e39956e05c61 /generic
parent5cd21052537a2597271ccdca2ceffe007a74e0b3 (diff)
downloadtcl-3863b1c0eac186a8e9cb66952c457082ef00ac8d.zip
tcl-3863b1c0eac186a8e9cb66952c457082ef00ac8d.tar.gz
tcl-3863b1c0eac186a8e9cb66952c457082ef00ac8d.tar.bz2
Stopped [format] from demoting wides to ints too easily. [Bug 699060]
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdAH.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index 3731974..d4788be 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdAH.c,v 1.32 2003/05/05 20:54:38 dgp Exp $
+ * RCS: @(#) $Id: tclCmdAH.c,v 1.33 2003/05/14 22:45:12 dkf Exp $
*/
#include "tclInt.h"
@@ -2256,7 +2256,7 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv)
case 'x':
case 'X':
if (useWide) {
- if (Tcl_GetWideIntFromObj(interp, /* INTL: Tcl source. */
+ if (Tcl_GetWideIntFromObj(interp, /* INTL: Tcl source. */
objv[objIndex], &wideValue) != TCL_OK) {
goto fmtError;
}
@@ -2264,7 +2264,18 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv)
size = 40 + precision;
break;
}
- if (Tcl_GetLongFromObj(interp, /* INTL: Tcl source. */
+ if (objv[objIndex]->typePtr == &tclWideIntType) {
+ /* Operation won't fail; we're typed! */
+ Tcl_GetWideIntFromObj(NULL, objv[objIndex], &wideValue);
+ if (wideValue>ULONG_MAX || wideValue<LONG_MIN) {
+ /*
+ * Value too big for type. Generate an error;
+ */
+ Tcl_GetLongFromObj(interp, objv[objIndex], &intValue);
+ goto fmtError;
+ }
+ intValue = Tcl_WideAsLong(wideValue);
+ } else if (Tcl_GetLongFromObj(interp, /* INTL: Tcl source. */
objv[objIndex], &intValue) != TCL_OK) {
goto fmtError;
}