diff options
Diffstat (limited to 'generic/tclCmdAH.c')
-rw-r--r-- | generic/tclCmdAH.c | 60 |
1 files changed, 13 insertions, 47 deletions
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 4bb76d2..4c43b87 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.27.2.8 2003/12/12 16:47:47 vincentdarley Exp $ + * RCS: @(#) $Id: tclCmdAH.c,v 1.27.2.9 2004/10/27 15:39:35 kennykb Exp $ */ #include "tclInt.h" @@ -2193,55 +2193,21 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv) case 'u': case 'x': case 'X': - size = 40 + precision; - - /* - * Peek what kind of value we've got so as not to be - * converting stuff unduly. [Bug #699060] - */ - if (objv[objIndex]->typePtr == &tclWideIntType) { - Tcl_GetWideIntFromObj(NULL, objv[objIndex], &wideValue); - if (useWide) { - whichValue = WIDE_VALUE; - break; - } else { - whichValue = INT_VALUE; - 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 (objv[objIndex]->typePtr == &tclIntType) { - Tcl_GetLongFromObj(NULL, objv[objIndex], &intValue); - if (useWide) { - whichValue = WIDE_VALUE; - wideValue = Tcl_LongAsWide(intValue); - break; - } else { - whichValue = INT_VALUE; - } - } else { - /* - * No existing numeric interpretation, so we can - * coerce to whichever is convenient. - */ - if (useWide) { - if (Tcl_GetWideIntFromObj(interp, /* INTL: Tcl source. */ - objv[objIndex], &wideValue) != TCL_OK) { - goto fmtError; - } - whichValue = WIDE_VALUE; - break; - } - if (Tcl_GetLongFromObj(interp, /* INTL: Tcl source. */ - objv[objIndex], &intValue) != TCL_OK) { + if ( useWide ) { + if ( Tcl_GetWideIntFromObj( interp, /* INTL: Tcl source. */ + objv[objIndex], &wideValue ) + != TCL_OK ) { goto fmtError; } + whichValue = WIDE_VALUE; + size = 40 + precision; + break; } + if ( Tcl_GetLongFromObj( interp, /* INTL: Tcl source. */ + objv[objIndex], &intValue ) != TCL_OK ) { + goto fmtError; + } + #if (LONG_MAX > INT_MAX) /* * Add the 'l' for long format type because we are on an |