diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-01-21 18:19:03 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-01-21 18:19:03 +0000 |
commit | 48080209fa53b6ea88c86e9f445c431b4cd1e47b (patch) | |
tree | 27d8768fb1d25696d3c40b42535eb5e073c278da /libgo/go/bufio/bufio.go | |
parent | bff898fbbe4358a4b7e337852df4d6043e0bd3f5 (diff) | |
download | gcc-48080209fa53b6ea88c86e9f445c431b4cd1e47b.tar.gz |
Remove the types float and complex.
Update to current version of Go library.
Update testsuite for removed types.
* go-lang.c (go_langhook_init): Omit float_type_size when calling
go_create_gogo.
* go-c.h: Update declaration of go_create_gogo.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169098 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/bufio/bufio.go')
-rw-r--r-- | libgo/go/bufio/bufio.go | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/libgo/go/bufio/bufio.go b/libgo/go/bufio/bufio.go index 7d59fb883cb..c13456a6326 100644 --- a/libgo/go/bufio/bufio.go +++ b/libgo/go/bufio/bufio.go @@ -128,43 +128,42 @@ func (b *Reader) Peek(n int) ([]byte, os.Error) { // Read reads data into p. // It returns the number of bytes read into p. -// If nn < len(p), also returns an error explaining -// why the read is short. At EOF, the count will be -// zero and err will be os.EOF. -func (b *Reader) Read(p []byte) (nn int, err os.Error) { - nn = 0 - for len(p) > 0 { - n := len(p) - if b.w == b.r { - if b.err != nil { - return nn, b.err - } - if len(p) >= len(b.buf) { - // Large read, empty buffer. - // Read directly into p to avoid copy. - n, b.err = b.rd.Read(p) - if n > 0 { - b.lastByte = int(p[n-1]) - b.lastRuneSize = -1 - } - p = p[n:] - nn += n - continue +// It calls Read at most once on the underlying Reader, +// hence n may be less than len(p). +// At EOF, the count will be zero and err will be os.EOF. +func (b *Reader) Read(p []byte) (n int, err os.Error) { + n = len(p) + if n == 0 { + return 0, b.err + } + if b.w == b.r { + if b.err != nil { + return 0, b.err + } + if len(p) >= len(b.buf) { + // Large read, empty buffer. + // Read directly into p to avoid copy. + n, b.err = b.rd.Read(p) + if n > 0 { + b.lastByte = int(p[n-1]) + b.lastRuneSize = -1 } - b.fill() - continue + return n, b.err } - if n > b.w-b.r { - n = b.w - b.r + b.fill() + if b.w == b.r { + return 0, b.err } - copy(p[0:n], b.buf[b.r:]) - p = p[n:] - b.r += n - b.lastByte = int(b.buf[b.r-1]) - b.lastRuneSize = -1 - nn += n } - return nn, nil + + if n > b.w-b.r { + n = b.w - b.r + } + copy(p[0:n], b.buf[b.r:]) + b.r += n + b.lastByte = int(b.buf[b.r-1]) + b.lastRuneSize = -1 + return n, nil } // ReadByte reads and returns a single byte. @@ -482,7 +481,7 @@ func (b *Writer) WriteRune(rune int) (size int, err os.Error) { return b.WriteString(string(rune)) } } - size = utf8.EncodeRune(rune, b.buf[b.n:]) + size = utf8.EncodeRune(b.buf[b.n:], rune) b.n += size return size, nil } |