aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/bytes
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-12-07 01:11:29 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-12-07 01:11:29 +0000
commit9c63abc9a1d127f95162756467284cf76b47aff8 (patch)
tree84f27a6ab44d932e4b0455f18390b070b4de626e /libgo/go/bytes
parent374280238f934fa851273e2ee16ba53be890c6b8 (diff)
downloadgcc-9c63abc9a1d127f95162756467284cf76b47aff8.zip
gcc-9c63abc9a1d127f95162756467284cf76b47aff8.tar.gz
gcc-9c63abc9a1d127f95162756467284cf76b47aff8.tar.bz2
libgo: Update to weekly 2011-11-09.
From-SVN: r182073
Diffstat (limited to 'libgo/go/bytes')
-rw-r--r--libgo/go/bytes/buffer.go14
-rw-r--r--libgo/go/bytes/buffer_test.go4
-rw-r--r--libgo/go/bytes/bytes.go7
-rw-r--r--libgo/go/bytes/bytes_test.go2
4 files changed, 16 insertions, 11 deletions
diff --git a/libgo/go/bytes/buffer.go b/libgo/go/bytes/buffer.go
index fbfd621..e66ac02 100644
--- a/libgo/go/bytes/buffer.go
+++ b/libgo/go/bytes/buffer.go
@@ -9,7 +9,7 @@ package bytes
import (
"errors"
"io"
- "utf8"
+ "unicode/utf8"
)
// A Buffer is a variable-sized buffer of bytes with Read and Write methods.
@@ -117,7 +117,7 @@ const MinRead = 512
// ReadFrom reads data from r until EOF and appends it to the buffer.
// The return value n is the number of bytes read.
-// Any error except os.EOF encountered during the read
+// Any error except io.EOF encountered during the read
// is also returned.
func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error) {
b.lastRead = opInvalid
@@ -200,7 +200,7 @@ func (b *Buffer) WriteRune(r rune) (n int, err error) {
// Read reads the next len(p) bytes from the buffer or until the buffer
// is drained. The return value n is the number of bytes read. If the
-// buffer has no data to return, err is os.EOF even if len(p) is zero;
+// buffer has no data to return, err is io.EOF even if len(p) is zero;
// otherwise it is nil.
func (b *Buffer) Read(p []byte) (n int, err error) {
b.lastRead = opInvalid
@@ -236,7 +236,7 @@ func (b *Buffer) Next(n int) []byte {
}
// ReadByte reads and returns the next byte from the buffer.
-// If no byte is available, it returns error os.EOF.
+// If no byte is available, it returns error io.EOF.
func (b *Buffer) ReadByte() (c byte, err error) {
b.lastRead = opInvalid
if b.off >= len(b.buf) {
@@ -252,7 +252,7 @@ func (b *Buffer) ReadByte() (c byte, err error) {
// ReadRune reads and returns the next UTF-8-encoded
// Unicode code point from the buffer.
-// If no bytes are available, the error returned is os.EOF.
+// If no bytes are available, the error returned is io.EOF.
// If the bytes are an erroneous UTF-8 encoding, it
// consumes one byte and returns U+FFFD, 1.
func (b *Buffer) ReadRune() (r rune, size int, err error) {
@@ -307,7 +307,7 @@ func (b *Buffer) UnreadByte() error {
// ReadBytes reads until the first occurrence of delim in the input,
// returning a slice containing the data up to and including the delimiter.
// If ReadBytes encounters an error before finding a delimiter,
-// it returns the data read before the error and the error itself (often os.EOF).
+// it returns the data read before the error and the error itself (often io.EOF).
// ReadBytes returns err != nil if and only if the returned data does not end in
// delim.
func (b *Buffer) ReadBytes(delim byte) (line []byte, err error) {
@@ -326,7 +326,7 @@ func (b *Buffer) ReadBytes(delim byte) (line []byte, err error) {
// ReadString reads until the first occurrence of delim in the input,
// returning a string containing the data up to and including the delimiter.
// If ReadString encounters an error before finding a delimiter,
-// it returns the data read before the error and the error itself (often os.EOF).
+// it returns the data read before the error and the error itself (often io.EOF).
// ReadString returns err != nil if and only if the returned data does not end
// in delim.
func (b *Buffer) ReadString(delim byte) (line string, err error) {
diff --git a/libgo/go/bytes/buffer_test.go b/libgo/go/bytes/buffer_test.go
index c271b48..5235970 100644
--- a/libgo/go/bytes/buffer_test.go
+++ b/libgo/go/bytes/buffer_test.go
@@ -7,9 +7,9 @@ package bytes_test
import (
. "bytes"
"io"
- "rand"
+ "math/rand"
"testing"
- "utf8"
+ "unicode/utf8"
)
const N = 10000 // make this bigger for a larger (and slower) test
diff --git a/libgo/go/bytes/bytes.go b/libgo/go/bytes/bytes.go
index ac8320f..9bfd88f 100644
--- a/libgo/go/bytes/bytes.go
+++ b/libgo/go/bytes/bytes.go
@@ -8,7 +8,7 @@ package bytes
import (
"unicode"
- "utf8"
+ "unicode/utf8"
)
// Compare returns an integer comparing the two byte arrays lexicographically.
@@ -88,6 +88,11 @@ func Count(s, sep []byte) int {
return n
}
+// Contains returns whether subslice is within b.
+func Contains(b, subslice []byte) bool {
+ return Index(b, subslice) != -1
+}
+
// Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
func Index(s, sep []byte) int {
n := len(sep)
diff --git a/libgo/go/bytes/bytes_test.go b/libgo/go/bytes/bytes_test.go
index 62f258d..9256b18 100644
--- a/libgo/go/bytes/bytes_test.go
+++ b/libgo/go/bytes/bytes_test.go
@@ -9,7 +9,7 @@ import (
"reflect"
"testing"
"unicode"
- "utf8"
+ "unicode/utf8"
)
func eq(a, b []string) bool {