diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2014-06-06 22:37:27 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2014-06-06 22:37:27 +0000 |
commit | 6736ef96eab222e58e6294f42be981a5afb59811 (patch) | |
tree | 2bc668fae9bf96f9a3988e0b0a16685bde8c4f0b /libgo/go/fmt/format.go | |
parent | 38a138411da4206c53f9a153ee9c3624fce58a52 (diff) | |
download | gcc-6736ef96eab222e58e6294f42be981a5afb59811.zip gcc-6736ef96eab222e58e6294f42be981a5afb59811.tar.gz gcc-6736ef96eab222e58e6294f42be981a5afb59811.tar.bz2 |
libgo: Merge to master revision 19184.
The next revision, 19185, renames several runtime files, and
will be handled in a separate change.
From-SVN: r211328
Diffstat (limited to 'libgo/go/fmt/format.go')
-rw-r--r-- | libgo/go/fmt/format.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libgo/go/fmt/format.go b/libgo/go/fmt/format.go index a54f12e..3835aa9 100644 --- a/libgo/go/fmt/format.go +++ b/libgo/go/fmt/format.go @@ -10,7 +10,9 @@ import ( ) const ( - nByte = 65 // %b of an int64, plus a sign. + // %b of an int64, plus a sign. + // Hex can add 0x and we handle it specially. + nByte = 65 ldigits = "0123456789abcdef" udigits = "0123456789ABCDEF" @@ -160,9 +162,16 @@ func (f *fmt) integer(a int64, base uint64, signedness bool, digits string) { } var buf []byte = f.intbuf[0:] - if f.widPresent && f.wid > nByte { - // We're going to need a bigger boat. - buf = make([]byte, f.wid) + if f.widPresent { + width := f.wid + if base == 16 && f.sharp { + // Also adds "0x". + width += 2 + } + if width > nByte { + // We're going to need a bigger boat. + buf = make([]byte, width) + } } negative := signedness == signed && a < 0 |