diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-12-22 01:15:33 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-12-22 01:15:33 +0000 |
commit | 409a5e7eb4cca107037fafa4a7eea92603edb83d (patch) | |
tree | 06f36bbef6fae78278f799194ad0df8ba2dabaa1 /libgo/go/fmt | |
parent | 7e9268b4cf01ab87d9b602f592ed2e2facfadda9 (diff) | |
download | gcc-409a5e7eb4cca107037fafa4a7eea92603edb83d.zip gcc-409a5e7eb4cca107037fafa4a7eea92603edb83d.tar.gz gcc-409a5e7eb4cca107037fafa4a7eea92603edb83d.tar.bz2 |
libgo: Update to revision 15193:6fdc1974457c of master library.
From-SVN: r194692
Diffstat (limited to 'libgo/go/fmt')
-rw-r--r-- | libgo/go/fmt/fmt_test.go | 5 | ||||
-rw-r--r-- | libgo/go/fmt/format.go | 6 | ||||
-rw-r--r-- | libgo/go/fmt/scan.go | 5 |
3 files changed, 14 insertions, 2 deletions
diff --git a/libgo/go/fmt/fmt_test.go b/libgo/go/fmt/fmt_test.go index 3406113..ab06465 100644 --- a/libgo/go/fmt/fmt_test.go +++ b/libgo/go/fmt/fmt_test.go @@ -476,6 +476,11 @@ var fmttests = []struct { // Used to crash because nByte didn't allow for a sign. {"%b", int64(-1 << 63), "-1000000000000000000000000000000000000000000000000000000000000000"}, + + // Complex fmt used to leave the plus flag set for future entries in the array + // causing +2+0i and +3+0i instead of 2+0i and 3+0i. + {"%v", []complex64{1, 2, 3}, "[(1+0i) (2+0i) (3+0i)]"}, + {"%v", []complex128{1, 2, 3}, "[(1+0i) (2+0i) (3+0i)]"}, } func TestSprintf(t *testing.T) { diff --git a/libgo/go/fmt/format.go b/libgo/go/fmt/format.go index ce80116..c3d7605 100644 --- a/libgo/go/fmt/format.go +++ b/libgo/go/fmt/format.go @@ -396,7 +396,7 @@ func (f *fmt) fmt_f64(v float64) { f.formatFloat(v, 'f', doPrec(f, 6), 64) } // fmt_g64 formats a float64 in the 'f' or 'e' form according to size. func (f *fmt) fmt_g64(v float64) { f.formatFloat(v, 'g', doPrec(f, -1), 64) } -// fmt_g64 formats a float64 in the 'f' or 'E' form according to size. +// fmt_G64 formats a float64 in the 'f' or 'E' form according to size. func (f *fmt) fmt_G64(v float64) { f.formatFloat(v, 'G', doPrec(f, -1), 64) } // fmt_fb64 formats a float64 in the form -123p3 (exponent is power of 2). @@ -428,6 +428,7 @@ func (f *fmt) fmt_fb32(v float32) { f.formatFloat(float64(v), 'b', 0, 32) } func (f *fmt) fmt_c64(v complex64, verb rune) { f.buf.WriteByte('(') r := real(v) + oldPlus := f.plus for i := 0; ; i++ { switch verb { case 'e': @@ -447,6 +448,7 @@ func (f *fmt) fmt_c64(v complex64, verb rune) { f.plus = true r = imag(v) } + f.plus = oldPlus f.buf.Write(irparenBytes) } @@ -454,6 +456,7 @@ func (f *fmt) fmt_c64(v complex64, verb rune) { func (f *fmt) fmt_c128(v complex128, verb rune) { f.buf.WriteByte('(') r := real(v) + oldPlus := f.plus for i := 0; ; i++ { switch verb { case 'e': @@ -473,5 +476,6 @@ func (f *fmt) fmt_c128(v complex128, verb rune) { f.plus = true r = imag(v) } + f.plus = oldPlus f.buf.Write(irparenBytes) } diff --git a/libgo/go/fmt/scan.go b/libgo/go/fmt/scan.go index 62de3a2..6a282c8 100644 --- a/libgo/go/fmt/scan.go +++ b/libgo/go/fmt/scan.go @@ -337,7 +337,10 @@ func (r *readRune) readByte() (b byte, err error) { r.pending-- return } - _, err = r.reader.Read(r.pendBuf[0:1]) + n, err := io.ReadFull(r.reader, r.pendBuf[0:1]) + if n != 1 { + return 0, err + } return r.pendBuf[0], err } |