From 18a0e540335a6264e29cd6b5510235ba26e39e07 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Mon, 18 Jun 2018 15:26:59 +0200 Subject: [PATCH] bugfix in %D: output was 1 byte too short --- src/BCDConverter.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/BCDConverter.cc b/src/BCDConverter.cc index 8b84566..390e21f 100644 --- a/src/BCDConverter.cc +++ b/src/BCDConverter.cc @@ -53,8 +53,9 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value) if (fmt.flags & alt_flag) { // least significant byte first (little endian) - while (width-- && prec) + while (width && prec) { + width--; bcd = value%10; if (--prec) { @@ -75,8 +76,9 @@ printLong(const StreamFormat& fmt, StreamBuffer& output, long value) output.append('\0', width); if (neg) output[-(long)width] |= 0xf0; i = 0; - while (width-- && prec) + while (width && prec) { + width--; bcd = value%10; if (--prec) {