aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/strconv
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-02-11 14:53:56 -0800
committerIan Lance Taylor <iant@golang.org>2022-02-11 15:01:19 -0800
commit8dc2499aa62f768c6395c9754b8cabc1ce25c494 (patch)
tree43d7fd2bbfd7ad8c9625a718a5e8718889351994 /libgo/go/strconv
parent9a56779dbc4e2d9c15be8d31e36f2f59be7331a8 (diff)
downloadgcc-8dc2499aa62f768c6395c9754b8cabc1ce25c494.zip
gcc-8dc2499aa62f768c6395c9754b8cabc1ce25c494.tar.gz
gcc-8dc2499aa62f768c6395c9754b8cabc1ce25c494.tar.bz2
libgo: update to Go1.18beta2
gotools/ * Makefile.am (go_cmd_cgo_files): Add ast_go118.go (check-go-tool): Copy golang.org/x/tools directories. * Makefile.in: Regenerate. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/384695
Diffstat (limited to 'libgo/go/strconv')
-rw-r--r--libgo/go/strconv/fp_test.go20
-rw-r--r--libgo/go/strconv/ftoaryu.go2
-rw-r--r--libgo/go/strconv/quote.go4
-rw-r--r--libgo/go/strconv/quote_test.go3
4 files changed, 15 insertions, 14 deletions
diff --git a/libgo/go/strconv/fp_test.go b/libgo/go/strconv/fp_test.go
index 39dd9c4..fd73958 100644
--- a/libgo/go/strconv/fp_test.go
+++ b/libgo/go/strconv/fp_test.go
@@ -28,15 +28,14 @@ func pow2(i int) float64 {
// Wrapper around strconv.ParseFloat(x, 64). Handles dddddp+ddd (binary exponent)
// itself, passes the rest on to strconv.ParseFloat.
func myatof64(s string) (f float64, ok bool) {
- a := strings.SplitN(s, "p", 2)
- if len(a) == 2 {
- n, err := strconv.ParseInt(a[0], 10, 64)
+ if mant, exp, ok := strings.Cut(s, "p"); ok {
+ n, err := strconv.ParseInt(mant, 10, 64)
if err != nil {
return 0, false
}
- e, err1 := strconv.Atoi(a[1])
+ e, err1 := strconv.Atoi(exp)
if err1 != nil {
- println("bad e", a[1])
+ println("bad e", exp)
return 0, false
}
v := float64(n)
@@ -72,16 +71,15 @@ func myatof64(s string) (f float64, ok bool) {
// Wrapper around strconv.ParseFloat(x, 32). Handles dddddp+ddd (binary exponent)
// itself, passes the rest on to strconv.ParseFloat.
func myatof32(s string) (f float32, ok bool) {
- a := strings.SplitN(s, "p", 2)
- if len(a) == 2 {
- n, err := strconv.Atoi(a[0])
+ if mant, exp, ok := strings.Cut(s, "p"); ok {
+ n, err := strconv.Atoi(mant)
if err != nil {
- println("bad n", a[0])
+ println("bad n", mant)
return 0, false
}
- e, err1 := strconv.Atoi(a[1])
+ e, err1 := strconv.Atoi(exp)
if err1 != nil {
- println("bad p", a[1])
+ println("bad p", exp)
return 0, false
}
return float32(float64(n) * pow2(e)), true
diff --git a/libgo/go/strconv/ftoaryu.go b/libgo/go/strconv/ftoaryu.go
index 1c61288..f2e74be 100644
--- a/libgo/go/strconv/ftoaryu.go
+++ b/libgo/go/strconv/ftoaryu.go
@@ -291,7 +291,7 @@ func ryuFtoaShortest(d *decimalSlice, mant uint64, exp int, flt *floatInfo) {
// Is it allowed to use 'du' as a result?
// It is always allowed when it is truncated, but also
// if it is exact and the original binary mantissa is even
- // When disallowed, we can substract 1.
+ // When disallowed, we can subtract 1.
uok := !du0 || fracu > 0
if du0 && fracu == 0 {
uok = mant&1 == 0
diff --git a/libgo/go/strconv/quote.go b/libgo/go/strconv/quote.go
index b3bbb16..d2814b9 100644
--- a/libgo/go/strconv/quote.go
+++ b/libgo/go/strconv/quote.go
@@ -103,7 +103,7 @@ func appendEscapedRune(buf []byte, r rune, quote byte, ASCIIonly, graphicOnly bo
buf = append(buf, `\x`...)
buf = append(buf, lowerhex[byte(r)>>4])
buf = append(buf, lowerhex[byte(r)&0xF])
- case r > utf8.MaxRune:
+ case !utf8.ValidRune(r):
r = 0xFFFD
fallthrough
case r < 0x10000:
@@ -322,7 +322,7 @@ func UnquoteChar(s string, quote byte) (value rune, multibyte bool, tail string,
value = v
break
}
- if v > utf8.MaxRune {
+ if !utf8.ValidRune(v) {
err = ErrSyntax
return
}
diff --git a/libgo/go/strconv/quote_test.go b/libgo/go/strconv/quote_test.go
index 4750be2..81fc8f7 100644
--- a/libgo/go/strconv/quote_test.go
+++ b/libgo/go/strconv/quote_test.go
@@ -131,6 +131,7 @@ var quoterunetests = []quoteRuneTest{
{'\\', `'\\'`, `'\\'`, `'\\'`},
{0xFF, `'ÿ'`, `'\u00ff'`, `'ÿ'`},
{0x263a, `'☺'`, `'\u263a'`, `'☺'`},
+ {0xdead, `'�'`, `'\ufffd'`, `'�'`},
{0xfffd, `'�'`, `'\ufffd'`, `'�'`},
{0x0010ffff, `'\U0010ffff'`, `'\U0010ffff'`, `'\U0010ffff'`},
{0x0010ffff + 1, `'�'`, `'\ufffd'`, `'�'`},
@@ -305,6 +306,8 @@ var misquoted = []string{
"\"\n\"",
"\"\\n\n\"",
"'\n'",
+ `"\udead"`,
+ `"\ud83d\ude4f"`,
}
func TestUnquote(t *testing.T) {