aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/strings
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-12-03 02:17:34 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-12-03 02:17:34 +0000
commit2fd401c8f190f1fe43e51a7f726f6ed6119a1f96 (patch)
tree7f76eff391f37fe6467ff4ffbc0c582c9959ea30 /libgo/go/strings
parent02e9018f1616b23f1276151797216717b3564202 (diff)
downloadgcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.zip
gcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.tar.gz
gcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.tar.bz2
libgo: Update to weekly.2011-11-02.
From-SVN: r181964
Diffstat (limited to 'libgo/go/strings')
-rw-r--r--libgo/go/strings/reader.go23
-rw-r--r--libgo/go/strings/replace.go19
-rw-r--r--libgo/go/strings/strings_test.go6
3 files changed, 23 insertions, 25 deletions
diff --git a/libgo/go/strings/reader.go b/libgo/go/strings/reader.go
index f4385a4..ac8d9dc 100644
--- a/libgo/go/strings/reader.go
+++ b/libgo/go/strings/reader.go
@@ -5,7 +5,8 @@
package strings
import (
- "os"
+ "errors"
+ "io"
"utf8"
)
@@ -23,9 +24,9 @@ func (r *Reader) Len() int {
return len(r.s) - r.i
}
-func (r *Reader) Read(b []byte) (n int, err os.Error) {
+func (r *Reader) Read(b []byte) (n int, err error) {
if r.i >= len(r.s) {
- return 0, os.EOF
+ return 0, io.EOF
}
n = copy(b, r.s[r.i:])
r.i += n
@@ -33,9 +34,9 @@ func (r *Reader) Read(b []byte) (n int, err os.Error) {
return
}
-func (r *Reader) ReadByte() (b byte, err os.Error) {
+func (r *Reader) ReadByte() (b byte, err error) {
if r.i >= len(r.s) {
- return 0, os.EOF
+ return 0, io.EOF
}
b = r.s[r.i]
r.i++
@@ -46,9 +47,9 @@ func (r *Reader) ReadByte() (b byte, err os.Error) {
// UnreadByte moves the reading position back by one byte.
// It is an error to call UnreadByte if nothing has been
// read yet.
-func (r *Reader) UnreadByte() os.Error {
+func (r *Reader) UnreadByte() error {
if r.i <= 0 {
- return os.NewError("strings.Reader: at beginning of string")
+ return errors.New("strings.Reader: at beginning of string")
}
r.i--
r.prevRune = -1
@@ -60,9 +61,9 @@ func (r *Reader) UnreadByte() os.Error {
// If no bytes are available, the error returned is os.EOF.
// If the bytes are an erroneous UTF-8 encoding, it
// consumes one byte and returns U+FFFD, 1.
-func (r *Reader) ReadRune() (ch rune, size int, err os.Error) {
+func (r *Reader) ReadRune() (ch rune, size int, err error) {
if r.i >= len(r.s) {
- return 0, 0, os.EOF
+ return 0, 0, io.EOF
}
r.prevRune = r.i
if c := r.s[r.i]; c < utf8.RuneSelf {
@@ -77,9 +78,9 @@ func (r *Reader) ReadRune() (ch rune, size int, err os.Error) {
// UnreadRune causes the next call to ReadRune to return the same rune
// as the previous call to ReadRune.
// The last method called on r must have been ReadRune.
-func (r *Reader) UnreadRune() os.Error {
+func (r *Reader) UnreadRune() error {
if r.prevRune < 0 {
- return os.NewError("strings.Reader: previous operation was not ReadRune")
+ return errors.New("strings.Reader: previous operation was not ReadRune")
}
r.i = r.prevRune
r.prevRune = -1
diff --git a/libgo/go/strings/replace.go b/libgo/go/strings/replace.go
index 64a7f20..f53a96e 100644
--- a/libgo/go/strings/replace.go
+++ b/libgo/go/strings/replace.go
@@ -4,10 +4,7 @@
package strings
-import (
- "io"
- "os"
-)
+import "io"
// A Replacer replaces a list of strings with replacements.
type Replacer struct {
@@ -17,7 +14,7 @@ type Replacer struct {
// replacer is the interface that a replacement algorithm needs to implement.
type replacer interface {
Replace(s string) string
- WriteString(w io.Writer, s string) (n int, err os.Error)
+ WriteString(w io.Writer, s string) (n int, err error)
}
// byteBitmap represents bytes which are sought for replacement.
@@ -85,7 +82,7 @@ func (r *Replacer) Replace(s string) string {
}
// WriteString writes s to w with all replacements performed.
-func (r *Replacer) WriteString(w io.Writer, s string) (n int, err os.Error) {
+func (r *Replacer) WriteString(w io.Writer, s string) (n int, err error) {
return r.r.WriteString(w, s)
}
@@ -101,7 +98,7 @@ type appendSliceWriter struct {
b []byte
}
-func (w *appendSliceWriter) Write(p []byte) (int, os.Error) {
+func (w *appendSliceWriter) Write(p []byte) (int, error) {
w.b = append(w.b, p...)
return len(p), nil
}
@@ -114,7 +111,7 @@ func (r *genericReplacer) Replace(s string) string {
return string(w.b)
}
-func (r *genericReplacer) WriteString(w io.Writer, s string) (n int, err os.Error) {
+func (r *genericReplacer) WriteString(w io.Writer, s string) (n int, err error) {
lastEmpty := false // the last replacement was of the empty string
Input:
// TODO(bradfitz): optimized version
@@ -192,7 +189,7 @@ func (r *byteReplacer) Replace(s string) string {
return string(buf)
}
-func (r *byteReplacer) WriteString(w io.Writer, s string) (n int, err os.Error) {
+func (r *byteReplacer) WriteString(w io.Writer, s string) (n int, err error) {
// TODO(bradfitz): use io.WriteString with slices of s, avoiding allocation.
bufsize := 32 << 10
if len(s) < bufsize {
@@ -262,7 +259,7 @@ func (r *byteStringReplacer) Replace(s string) string {
// WriteString maintains one buffer that's at most 32KB. The bytes in
// s are enumerated and the buffer is filled. If it reaches its
// capacity or a byte has a replacement, the buffer is flushed to w.
-func (r *byteStringReplacer) WriteString(w io.Writer, s string) (n int, err os.Error) {
+func (r *byteStringReplacer) WriteString(w io.Writer, s string) (n int, err error) {
// TODO(bradfitz): use io.WriteString with slices of s instead.
bufsize := 32 << 10
if len(s) < bufsize {
@@ -310,6 +307,6 @@ var discard io.Writer = devNull(0)
type devNull int
-func (devNull) Write(p []byte) (int, os.Error) {
+func (devNull) Write(p []byte) (int, error) {
return len(p), nil
}
diff --git a/libgo/go/strings/strings_test.go b/libgo/go/strings/strings_test.go
index 4132996..2cf4bde 100644
--- a/libgo/go/strings/strings_test.go
+++ b/libgo/go/strings/strings_test.go
@@ -6,7 +6,7 @@ package strings_test
import (
"bytes"
- "os"
+ "io"
"reflect"
"strconv"
. "strings"
@@ -759,7 +759,7 @@ func TestReadByte(t *testing.T) {
var res bytes.Buffer
for {
b, e := reader.ReadByte()
- if e == os.EOF {
+ if e == io.EOF {
break
}
if e != nil {
@@ -799,7 +799,7 @@ func TestReadRune(t *testing.T) {
res := ""
for {
r, z, e := reader.ReadRune()
- if e == os.EOF {
+ if e == io.EOF {
break
}
if e != nil {