summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2005-06-17 23:26:06 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2005-06-17 23:26:06 (GMT)
commit17efc09f1ef6cf0d49925423ef414a55c83320b2 (patch)
tree519cadab94bf19ba9f5c89129a24396b267240c2 /generic
parenta36b4c045ab06380df9b554a4cd8ebfefe9da25d (diff)
downloadtcl-17efc09f1ef6cf0d49925423ef414a55c83320b2.zip
tcl-17efc09f1ef6cf0d49925423ef414a55c83320b2.tar.gz
tcl-17efc09f1ef6cf0d49925423ef414a55c83320b2.tar.bz2
Fix bug in [format %hx] handling on selected platforms. [Bug 1154163]
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdAH.c38
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;