From: Amos Jeffries Date: Wed, 25 Jul 2018 13:47:20 +0000 (+0000) Subject: Bug 4870: milliseconds logformats prepend 0s instead of spaces (#255) X-Git-Tag: M-staged-PR255 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f1162d09c91281aec88d34ccaa8b5d126ed1cf02;p=thirdparty%2Fsquid.git Bug 4870: milliseconds logformats prepend 0s instead of spaces (#255) --- diff --git a/src/format/Format.cc b/src/format/Format.cc index 82d13bf8b0..ec9b3db08f 100644 --- a/src/format/Format.cc +++ b/src/format/Format.cc @@ -1389,7 +1389,7 @@ Format::Format::assemble(MemBuf &mb, const AccessLogEntry::Pointer &al, int logS out = sb.c_str(); } else if (doMsec) { if (fmt->widthMax < 0) { - sb.appendf("%0*ld", fmt->widthMin, tvToMsec(outtv)); + sb.appendf("%0*ld", fmt->zero && fmt->widthMin >= 0 ? fmt->widthMin : 0, tvToMsec(outtv)); } else { int precision = fmt->widthMax; sb.appendf("%0*" PRId64 ".%0*" PRId64 "", fmt->zero && (fmt->widthMin - precision - 1 >= 0) ? fmt->widthMin - precision - 1 : 0, static_cast(outtv.tv_sec * 1000 + outtv.tv_usec / 1000), precision, static_cast((outtv.tv_usec % 1000 )* (1000 / fmt->divisor)));