Commit aec8e145 authored by Martin Möhrmann's avatar Martin Möhrmann Committed by Rob Pike

fmt: fix padding for 0 precision 0 integer value formatting

Fixes #14924

Change-Id: I098ef973e2cad76a121704492758c2971a9b55f3
Reviewed-on: https://go-review.googlesource.com/20920
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarRob Pike <r@golang.org>
parent d175a85c
......@@ -345,6 +345,7 @@ var fmtTests = []struct {
{"%x", ^uint32(0), "ffffffff"},
{"%X", ^uint64(0), "FFFFFFFFFFFFFFFF"},
{"%.20b", 7, "00000000000000000111"},
{"%6.0d", 0, " "},
{"%10d", 12345, " 12345"},
{"%10d", -12345, " -12345"},
{"%+10d", 12345, " +12345"},
......
......@@ -192,8 +192,11 @@ func (f *fmt) fmt_unicode(u uint64) {
// fmt_integer formats signed and unsigned integers.
func (f *fmt) fmt_integer(u uint64, base int, isSigned bool, digits string) {
// precision of 0 and value of 0 means "print nothing"
// Precision of 0 and value of 0 means "print nothing" but padding.
if f.precPresent && f.prec == 0 && u == 0 {
if f.widPresent {
f.writePadding(f.wid)
}
return
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment