diff options
author | dkf <dkf@noemail.net> | 2005-06-17 23:26:06 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2005-06-17 23:26:06 (GMT) |
commit | 57f412a48abacd0573e57ce2efff632891ccb6e4 (patch) | |
tree | 519cadab94bf19ba9f5c89129a24396b267240c2 /generic/tclCmdAH.c | |
parent | 929bcb36e21dd19108a22b51c023687016660f41 (diff) | |
download | tcl-57f412a48abacd0573e57ce2efff632891ccb6e4.zip tcl-57f412a48abacd0573e57ce2efff632891ccb6e4.tar.gz tcl-57f412a48abacd0573e57ce2efff632891ccb6e4.tar.bz2 |
Fix bug in [format %hx] handling on selected platforms. [Bug 1154163]
FossilOrigin-Name: 7e05cf3e68c5e3660f375585a68b6a4f0f573a5f
Diffstat (limited to 'generic/tclCmdAH.c')
-rw-r--r-- | generic/tclCmdAH.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 4d99fbd..9c9fe7e 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.11 2004/10/30 21:00:09 msofer Exp $ + * RCS: @(#) $Id: tclCmdAH.c,v 1.27.2.12 2005/06/17 23:26:20 dkf Exp $ */ #include "tclInt.h" @@ -2187,31 +2187,37 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv) case 'u': case 'x': case 'X': - if ( useWide ) { - if ( Tcl_GetWideIntFromObj( interp, /* INTL: Tcl source. */ - objv[objIndex], &wideValue ) - != 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 ) { + 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 - * LP64 archtecture and we are really going to pass a long - * argument to sprintf. - */ - newPtr++; - *newPtr = 0; - newPtr[-1] = newPtr[-2]; - newPtr[-2] = 'l'; + if (!useShort) { + /* + * Add the 'l' for long format type because we are on an + * LP64 archtecture and we are really going to pass a long + * argument to sprintf. + * + * Do not add this if we're going to pass in a short (i.e. + * if we've got an 'h' modifier already in the string); some + * libc implementations of sprintf() do not like it at all. + * [Bug 1154163] + */ + newPtr++; + *newPtr = 0; + newPtr[-1] = newPtr[-2]; + newPtr[-2] = 'l'; + } #endif /* LONG_MAX > INT_MAX */ whichValue = INT_VALUE; size = 40 + precision; |