aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/strconv
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/strconv
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/strconv')
-rw-r--r--libgo/go/strconv/atob.go4
-rw-r--r--libgo/go/strconv/atob_test.go5
-rw-r--r--libgo/go/strconv/atof.go11
-rw-r--r--libgo/go/strconv/atof_test.go3
-rw-r--r--libgo/go/strconv/atoi.go32
-rw-r--r--libgo/go/strconv/atoi_test.go9
-rw-r--r--libgo/go/strconv/fp_test.go5
-rw-r--r--libgo/go/strconv/quote.go5
8 files changed, 33 insertions, 41 deletions
diff --git a/libgo/go/strconv/atob.go b/libgo/go/strconv/atob.go
index 7208194..e2d87bc 100644
--- a/libgo/go/strconv/atob.go
+++ b/libgo/go/strconv/atob.go
@@ -4,12 +4,10 @@
package strconv
-import "os"
-
// Atob returns the boolean value represented by the string.
// It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False.
// Any other value returns an error.
-func Atob(str string) (value bool, err os.Error) {
+func Atob(str string) (value bool, err error) {
switch str {
case "1", "t", "T", "true", "TRUE", "True":
return true, nil
diff --git a/libgo/go/strconv/atob_test.go b/libgo/go/strconv/atob_test.go
index d9db6c7..2f31eb5 100644
--- a/libgo/go/strconv/atob_test.go
+++ b/libgo/go/strconv/atob_test.go
@@ -5,7 +5,6 @@
package strconv_test
import (
- "os"
. "strconv"
"testing"
)
@@ -13,7 +12,7 @@ import (
type atobTest struct {
in string
out bool
- err os.Error
+ err error
}
var atobtests = []atobTest{
@@ -42,7 +41,7 @@ func TestAtob(t *testing.T) {
t.Errorf("%s: expected %s but got nil", test.in, test.err)
} else {
// NumError assertion must succeed; it's the only thing we return.
- if test.err != e.(*NumError).Error {
+ if test.err != e.(*NumError).Err {
t.Errorf("%s: expected %s but got %s", test.in, test.err, e)
}
}
diff --git a/libgo/go/strconv/atof.go b/libgo/go/strconv/atof.go
index 4a4b1b4..06dae85 100644
--- a/libgo/go/strconv/atof.go
+++ b/libgo/go/strconv/atof.go
@@ -12,10 +12,7 @@ package strconv
// 2) Multiply/divide decimal by powers of two until in range [0.5, 1)
// 3) Multiply by 2^precision and round to get mantissa.
-import (
- "math"
- "os"
-)
+import "math"
var optimize = true // can change for testing
@@ -355,7 +352,7 @@ func (d *decimal) atof32() (f float32, ok bool) {
// If s is syntactically well-formed but is more than 1/2 ULP
// away from the largest floating point number of the given size,
// Atof32 returns f = ±Inf, err.Error = ErrRange.
-func Atof32(s string) (f float32, err os.Error) {
+func Atof32(s string) (f float32, err error) {
if val, ok := special(s); ok {
return float32(val), nil
}
@@ -380,7 +377,7 @@ func Atof32(s string) (f float32, err os.Error) {
// Atof64 converts the string s to a 64-bit floating-point number.
// Except for the type of its result, its definition is the same as that
// of Atof32.
-func Atof64(s string) (f float64, err os.Error) {
+func Atof64(s string) (f float64, err error) {
if val, ok := special(s); ok {
return val, nil
}
@@ -405,7 +402,7 @@ func Atof64(s string) (f float64, err os.Error) {
// AtofN converts the string s to a 64-bit floating-point number,
// but it rounds the result assuming that it will be stored in a value
// of n bits (32 or 64).
-func AtofN(s string, n int) (f float64, err os.Error) {
+func AtofN(s string, n int) (f float64, err error) {
if n == 32 {
f1, err1 := Atof32(s)
return float64(f1), err1
diff --git a/libgo/go/strconv/atof_test.go b/libgo/go/strconv/atof_test.go
index 33f881c..871bf0c 100644
--- a/libgo/go/strconv/atof_test.go
+++ b/libgo/go/strconv/atof_test.go
@@ -5,7 +5,6 @@
package strconv_test
import (
- "os"
"reflect"
. "strconv"
"testing"
@@ -14,7 +13,7 @@ import (
type atofTest struct {
in string
out string
- err os.Error
+ err error
}
var atoftests = []atofTest{
diff --git a/libgo/go/strconv/atoi.go b/libgo/go/strconv/atoi.go
index 92ba89d..2c6c3d5 100644
--- a/libgo/go/strconv/atoi.go
+++ b/libgo/go/strconv/atoi.go
@@ -4,21 +4,21 @@
package strconv
-import "os"
+import "errors"
// ErrRange indicates that a value is out of range for the target type.
-var ErrRange = os.NewError("value out of range")
+var ErrRange = errors.New("value out of range")
// ErrSyntax indicates that a value does not have the right syntax for the target type.
-var ErrSyntax = os.NewError("invalid syntax")
+var ErrSyntax = errors.New("invalid syntax")
// A NumError records a failed conversion.
type NumError struct {
- Num string // the input
- Error os.Error // the reason the conversion failed (ErrRange, ErrSyntax)
+ Num string // the input
+ Err error // the reason the conversion failed (ErrRange, ErrSyntax)
}
-func (e *NumError) String() string { return `parsing "` + e.Num + `": ` + e.Error.String() }
+func (e *NumError) Error() string { return `parsing "` + e.Num + `": ` + e.Err.Error() }
func computeIntsize() uint {
siz := uint(8)
@@ -47,7 +47,7 @@ func cutoff64(base int) uint64 {
// and include err.Num = s. If s is empty or contains invalid
// digits, err.Error = ErrSyntax; if the value corresponding
// to s cannot be represented by a uint64, err.Error = ErrRange.
-func Btoui64(s string, b int) (n uint64, err os.Error) {
+func Btoui64(s string, b int) (n uint64, err error) {
var cutoff uint64
s0 := s
@@ -76,7 +76,7 @@ func Btoui64(s string, b int) (n uint64, err os.Error) {
}
default:
- err = os.NewError("invalid base " + Itoa(b))
+ err = errors.New("invalid base " + Itoa(b))
goto Error
}
@@ -133,13 +133,13 @@ Error:
//
// Atoui64 returns err.Error = ErrSyntax if s is empty or contains invalid digits.
// It returns err.Error = ErrRange if s cannot be represented by a uint64.
-func Atoui64(s string) (n uint64, err os.Error) {
+func Atoui64(s string) (n uint64, err error) {
return Btoui64(s, 10)
}
// Btoi64 is like Btoui64 but allows signed numbers and
// returns its result in an int64.
-func Btoi64(s string, base int) (i int64, err os.Error) {
+func Btoi64(s string, base int) (i int64, err error) {
// Empty string bad.
if len(s) == 0 {
return 0, &NumError{s, ErrSyntax}
@@ -158,7 +158,7 @@ func Btoi64(s string, base int) (i int64, err os.Error) {
// Convert unsigned and check range.
var un uint64
un, err = Btoui64(s, base)
- if err != nil && err.(*NumError).Error != ErrRange {
+ if err != nil && err.(*NumError).Err != ErrRange {
err.(*NumError).Num = s0
return 0, err
}
@@ -177,12 +177,12 @@ func Btoi64(s string, base int) (i int64, err os.Error) {
// Atoi64 is like Atoui64 but allows signed numbers and
// returns its result in an int64.
-func Atoi64(s string) (i int64, err os.Error) { return Btoi64(s, 10) }
+func Atoi64(s string) (i int64, err error) { return Btoi64(s, 10) }
// Atoui is like Atoui64 but returns its result as a uint.
-func Atoui(s string) (i uint, err os.Error) {
+func Atoui(s string) (i uint, err error) {
i1, e1 := Atoui64(s)
- if e1 != nil && e1.(*NumError).Error != ErrRange {
+ if e1 != nil && e1.(*NumError).Err != ErrRange {
return 0, e1
}
i = uint(i1)
@@ -193,9 +193,9 @@ func Atoui(s string) (i uint, err os.Error) {
}
// Atoi is like Atoi64 but returns its result as an int.
-func Atoi(s string) (i int, err os.Error) {
+func Atoi(s string) (i int, err error) {
i1, e1 := Atoi64(s)
- if e1 != nil && e1.(*NumError).Error != ErrRange {
+ if e1 != nil && e1.(*NumError).Err != ErrRange {
return 0, e1
}
i = int(i1)
diff --git a/libgo/go/strconv/atoi_test.go b/libgo/go/strconv/atoi_test.go
index 0d2e381..9ee11b7 100644
--- a/libgo/go/strconv/atoi_test.go
+++ b/libgo/go/strconv/atoi_test.go
@@ -5,7 +5,6 @@
package strconv_test
import (
- "os"
"reflect"
. "strconv"
"testing"
@@ -14,7 +13,7 @@ import (
type atoui64Test struct {
in string
out uint64
- err os.Error
+ err error
}
var atoui64tests = []atoui64Test{
@@ -54,7 +53,7 @@ var btoui64tests = []atoui64Test{
type atoi64Test struct {
in string
out int64
- err os.Error
+ err error
}
var atoi64tests = []atoi64Test{
@@ -104,7 +103,7 @@ var btoi64tests = []atoi64Test{
type atoui32Test struct {
in string
out uint32
- err os.Error
+ err error
}
var atoui32tests = []atoui32Test{
@@ -122,7 +121,7 @@ var atoui32tests = []atoui32Test{
type atoi32Test struct {
in string
out int32
- err os.Error
+ err error
}
var atoi32tests = []atoi32Test{
diff --git a/libgo/go/strconv/fp_test.go b/libgo/go/strconv/fp_test.go
index 991d3ac..9785ca6 100644
--- a/libgo/go/strconv/fp_test.go
+++ b/libgo/go/strconv/fp_test.go
@@ -7,6 +7,7 @@ package strconv_test
import (
"bufio"
"fmt"
+ "io"
"os"
"strconv"
"strings"
@@ -105,11 +106,11 @@ func TestFp(t *testing.T) {
lineno := 0
for {
line, err2 := b.ReadString('\n')
- if err2 == os.EOF {
+ if err2 == io.EOF {
break
}
if err2 != nil {
- t.Fatal("testfp: read testfp.txt: " + err2.String())
+ t.Fatal("testfp: read testfp.txt: " + err2.Error())
}
line = line[0 : len(line)-1]
lineno++
diff --git a/libgo/go/strconv/quote.go b/libgo/go/strconv/quote.go
index 7efdcfe..24b19be 100644
--- a/libgo/go/strconv/quote.go
+++ b/libgo/go/strconv/quote.go
@@ -6,7 +6,6 @@ package strconv
import (
"bytes"
- "os"
"strings"
"unicode"
"utf8"
@@ -157,7 +156,7 @@ func unhex(b byte) (v rune, ok bool) {
// If set to a single quote, it permits the sequence \' and disallows unescaped '.
// If set to a double quote, it permits \" and disallows unescaped ".
// If set to zero, it does not permit either escape and allows both quote characters to appear unescaped.
-func UnquoteChar(s string, quote byte) (value rune, multibyte bool, tail string, err os.Error) {
+func UnquoteChar(s string, quote byte) (value rune, multibyte bool, tail string, err error) {
// easy cases
switch c := s[0]; {
case c == quote && (quote == '\'' || quote == '"'):
@@ -268,7 +267,7 @@ func UnquoteChar(s string, quote byte) (value rune, multibyte bool, tail string,
// that s quotes. (If s is single-quoted, it would be a Go
// character literal; Unquote returns the corresponding
// one-character string.)
-func Unquote(s string) (t string, err os.Error) {
+func Unquote(s string) (t string, err error) {
n := len(s)
if n < 2 {
return "", ErrSyntax