summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2005-06-17 23:41:00 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2005-06-17 23:41:00 (GMT)
commit1eab272665547e3f9be60541313af2b3c614c747 (patch)
tree6c75fc7a238a9d2b00bfd317f1b847798a418e12 /generic
parente1e80d15370c158d3ae2870cfc5d26e1d9791046 (diff)
downloadtcl-1eab272665547e3f9be60541313af2b3c614c747.zip
tcl-1eab272665547e3f9be60541313af2b3c614c747.tar.gz
tcl-1eab272665547e3f9be60541313af2b3c614c747.tar.bz2
Fix bug in [format %hx] handling on selected platforms. [Bug 1154163]
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdAH.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index 14b5e66..c2fae75 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.62 2005/06/07 09:04:00 dkf Exp $
+ * RCS: @(#) $Id: tclCmdAH.c,v 1.63 2005/06/17 23:41:03 dkf Exp $
*/
#include "tclInt.h"
@@ -2221,15 +2221,22 @@ Tcl_FormatObjCmd(dummy, interp, objc, objv)
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;