summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclStringObj.c8
-rw-r--r--tests/format.test6
3 files changed, 15 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 61eb727..532cd00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-01-10 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/tclStringObj.c (Tcl_AppendFormatToObj): Correct failure to
+ * tests/format.test: account for big.used == 0 corner case in the
+ %ll(idox) format directives. [Bug 1867855].
+
2008-01-09 George Peter Staplin <georgeps@xmission.com>
* doc/vwait.n: add a missing be to fix a typo.
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 1b39745..57b1669 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -33,7 +33,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStringObj.c,v 1.68 2007/12/13 15:23:20 dgp Exp $ */
+ * RCS: @(#) $Id: tclStringObj.c,v 1.69 2008/01/10 16:09:23 dgp Exp $ */
#include "tclInt.h"
#include "tommath.h"
@@ -2105,7 +2105,7 @@ Tcl_AppendFormatToObj(
numDigits++;
uw /= base;
}
- } else if (useBig) {
+ } else if (useBig && big.used) {
int leftover = (big.used * DIGIT_BIT) % numBits;
mp_digit mask = (~(mp_digit)0) << (DIGIT_BIT-leftover);
@@ -2114,7 +2114,7 @@ Tcl_AppendFormatToObj(
numDigits--;
mask >>= numBits;
}
- } else {
+ } else if (!useBig) {
unsigned long int ul = (unsigned long int) l;
bits = (Tcl_WideUInt) ul;
@@ -2138,7 +2138,7 @@ Tcl_AppendFormatToObj(
while (numDigits--) {
int digitOffset;
- if (useBig) {
+ if (useBig && big.used) {
if ((size_t) shift <
CHAR_BIT*sizeof(Tcl_WideUInt) - DIGIT_BIT) {
bits |= (((Tcl_WideUInt)big.dp[index++]) <<shift);
diff --git a/tests/format.test b/tests/format.test
index 321f52f..b050fc3 100644
--- a/tests/format.test
+++ b/tests/format.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: format.test,v 1.24 2006/03/21 11:12:29 dkf Exp $
+# RCS: @(#) $Id: format.test,v 1.25 2008/01/10 16:09:23 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -553,6 +553,10 @@ test format-19.1 {
list [expr { ~ $x }] [format %08x [expr { ~$x }]]
} -match regexp -result {-2414724693 f*701239ab}
+test format-19.2 {Bug 1867855} {
+ format %llx 0
+} 0
+
# cleanup
catch {unset a}
catch {unset b}