summaryrefslogtreecommitdiff
path: root/src/pkg/strconv
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/strconv')
-rw-r--r--src/pkg/strconv/atoi.go6
-rw-r--r--src/pkg/strconv/fp_test.go6
-rw-r--r--src/pkg/strconv/quote.go6
3 files changed, 11 insertions, 7 deletions
diff --git a/src/pkg/strconv/atoi.go b/src/pkg/strconv/atoi.go
index f7b845672..e1154782b 100644
--- a/src/pkg/strconv/atoi.go
+++ b/src/pkg/strconv/atoi.go
@@ -42,6 +42,8 @@ func cutoff64(base int) uint64 {
// digits, err.Error = os.EINVAL; if the value corresponding
// to s cannot be represented by a uint64, err.Error = os.ERANGE.
func Btoui64(s string, b int) (n uint64, err os.Error) {
+ var cutoff uint64
+
s0 := s
switch {
case len(s) < 1:
@@ -68,12 +70,12 @@ func Btoui64(s string, b int) (n uint64, err os.Error) {
}
default:
- err = os.ErrorString("invalid base " + Itoa(b))
+ err = os.NewError("invalid base " + Itoa(b))
goto Error
}
n = 0
- cutoff := cutoff64(b)
+ cutoff = cutoff64(b)
for i := 0; i < len(s); i++ {
var v byte
diff --git a/src/pkg/strconv/fp_test.go b/src/pkg/strconv/fp_test.go
index 34baeee39..3096957f5 100644
--- a/src/pkg/strconv/fp_test.go
+++ b/src/pkg/strconv/fp_test.go
@@ -28,7 +28,7 @@ func pow2(i int) float64 {
// Wrapper around strconv.Atof64. Handles dddddp+ddd (binary exponent)
// itself, passes the rest on to strconv.Atof64.
func myatof64(s string) (f float64, ok bool) {
- a := strings.Split(s, "p", 2)
+ a := strings.SplitN(s, "p", 2)
if len(a) == 2 {
n, err := strconv.Atoi64(a[0])
if err != nil {
@@ -72,7 +72,7 @@ func myatof64(s string) (f float64, ok bool) {
// Wrapper around strconv.Atof32. Handles dddddp+ddd (binary exponent)
// itself, passes the rest on to strconv.Atof32.
func myatof32(s string) (f float32, ok bool) {
- a := strings.Split(s, "p", 2)
+ a := strings.SplitN(s, "p", 2)
if len(a) == 2 {
n, err := strconv.Atoi(a[0])
if err != nil {
@@ -116,7 +116,7 @@ func TestFp(t *testing.T) {
if len(line) == 0 || line[0] == '#' {
continue
}
- a := strings.Split(line, " ", -1)
+ a := strings.Split(line, " ")
if len(a) != 4 {
t.Error("testfp.txt:", lineno, ": wrong field count")
continue
diff --git a/src/pkg/strconv/quote.go b/src/pkg/strconv/quote.go
index 98b19d3a2..05e49d32d 100644
--- a/src/pkg/strconv/quote.go
+++ b/src/pkg/strconv/quote.go
@@ -24,7 +24,10 @@ func quoteWith(s string, quote byte, ASCIIonly bool) string {
rune, width = utf8.DecodeRuneInString(s)
}
if width == 1 && rune == utf8.RuneError {
- goto printEscX
+ buf.WriteString(`\x`)
+ buf.WriteByte(lowerhex[s[0]>>4])
+ buf.WriteByte(lowerhex[s[0]&0xF])
+ continue
}
if rune == int(quote) || rune == '\\' { // always backslashed
buf.WriteByte('\\')
@@ -58,7 +61,6 @@ func quoteWith(s string, quote byte, ASCIIonly bool) string {
default:
switch {
case rune < ' ':
- printEscX:
buf.WriteString(`\x`)
buf.WriteByte(lowerhex[s[0]>>4])
buf.WriteByte(lowerhex[s[0]&0xF])