bytes: fix bugs in buffer.ReadBytes
Fixes #1498.
R=golang-dev, mattn, r, rsc
CC=golang-dev
https://golang.org/cl/4140041
diff --git a/src/pkg/bytes/buffer.go b/src/pkg/bytes/buffer.go
index 3da8008..1acd4e0 100644
--- a/src/pkg/bytes/buffer.go
+++ b/src/pkg/bytes/buffer.go
@@ -312,13 +312,14 @@
// delim.
func (b *Buffer) ReadBytes(delim byte) (line []byte, err os.Error) {
i := IndexByte(b.buf[b.off:], delim)
- size := i + 1 - b.off
+ size := i + 1
if i < 0 {
size = len(b.buf) - b.off
err = os.EOF
}
line = make([]byte, size)
copy(line, b.buf[b.off:])
+ b.off += size
return
}