runtime: fix UTF-8 decoding

The algorithm now checks for invalid UTF-8 sequences, which is required
by the Go spec.

This gets the tests of the unicode/utf8 package to pass.

Also add bytes.Equal for Go 1.11, which again is necessary for the
unicode/utf8 package.
This commit is contained in:
Ayke van Laethem
2020-09-17 22:45:51 +02:00
committed by Ron Evans
parent 41afb77080
commit ec54e7763d
3 changed files with 42 additions and 9 deletions
+7 -1
View File
@@ -4,11 +4,17 @@ package runtime
import "internal/bytealg"
// indexByte provides compatibility with Go 1.11.
// The following functions provide compatibility with Go 1.11.
// See the following:
// https://github.com/tinygo-org/tinygo/issues/351
// https://github.com/golang/go/commit/ad4a58e31501bce5de2aad90a620eaecdc1eecb8
//go:linkname indexByte strings.IndexByte
func indexByte(s string, c byte) int {
return bytealg.IndexByteString(s, c)
}
//go:linkname bytesEqual bytes.Equal
func bytesEqual(a, b []byte) bool {
return bytealg.Equal(a, b)
}