diff options
author | hobbs <hobbs> | 2001-09-20 01:03:08 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2001-09-20 01:03:08 (GMT) |
commit | 32d25a83797b68399f879b2bbdc6555c639487eb (patch) | |
tree | 3d9d23e524722e06cf15681524b4db6900855fa4 /generic/tclCmdAH.c | |
parent | 43ce4a3c4a76eeb1a99a53e43ec6d32433e77680 (diff) | |
download | tcl-32d25a83797b68399f879b2bbdc6555c639487eb.zip tcl-32d25a83797b68399f879b2bbdc6555c639487eb.tar.gz tcl-32d25a83797b68399f879b2bbdc6555c639487eb.tar.bz2 |
* generic/tclCmdAH.c (Tcl_FormatObjCmd):
* generic/tclScan.c (Tcl_ScanObjCmd): corrected handling of format
and scan on 64-bit machines. [Bug #412696] (rmax)
Diffstat (limited to 'generic/tclCmdAH.c')
-rw-r--r-- | generic/tclCmdAH.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 3ea9aad..1645ad3 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.15 2001/09/04 18:06:34 vincentdarley Exp $ + * RCS: @(#) $Id: tclCmdAH.c,v 1.16 2001/09/20 01:03:08 hobbs Exp $ */ #include "tclInt.h" @@ -1854,7 +1854,7 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv) int size; /* Number of bytes needed for result of * conversion, based on type of conversion * ("e", "s", etc.), width, and precision. */ - int intValue; /* Used to hold value to pass to sprintf, if + long intValue; /* Used to hold value to pass to sprintf, if * it's a one-word integer or char value */ char *ptrValue = NULL; /* Used to hold value to pass to sprintf, if * it's a one-word value. */ @@ -1870,7 +1870,7 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv) # define DOUBLE_VALUE 3 # define STRING_VALUE 4 # define MAX_FLOAT_SIZE 320 - + Tcl_Obj *resultPtr; /* Where result is stored finally. */ char staticBuf[MAX_FLOAT_SIZE + 1]; /* A static buffer to copy the format results @@ -2090,10 +2090,19 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv) case 'u': case 'x': case 'X': - if (Tcl_GetIntFromObj(interp, /* INTL: Tcl source. */ + if (Tcl_GetLongFromObj(interp, /* INTL: Tcl source. */ objv[objIndex], &intValue) != TCL_OK) { goto fmtError; } + if ((unsigned long) intValue > UINT_MAX) { + /* + * Add the 'l' for long format type. + */ + newPtr++; + *newPtr = 0; + newPtr[-1] = newPtr[-2]; + newPtr[-2] = 'l'; + } whichValue = INT_VALUE; size = 40 + precision; break; @@ -2117,7 +2126,7 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv) } break; case 'c': - if (Tcl_GetIntFromObj(interp, /* INTL: Tcl source. */ + if (Tcl_GetLongFromObj(interp, /* INTL: Tcl source. */ objv[objIndex], &intValue) != TCL_OK) { goto fmtError; } |