mirror of https://github.com/golang/go.git
all: replace magic 0x80 with named constant utf8.RuneSelf
Change-Id: Id1c2e8e9d60588de866e8b6ca59cc83dd28f848f Reviewed-on: https://go-review.googlesource.com/21756 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
527ffebb2c
commit
012557b376
|
|
@ -266,7 +266,7 @@ func (b *Reader) ReadRune() (r rune, size int, err error) {
|
|||
return 0, 0, b.readErr()
|
||||
}
|
||||
r, size = rune(b.buf[b.r]), 1
|
||||
if r >= 0x80 {
|
||||
if r >= utf8.RuneSelf {
|
||||
r, size = utf8.DecodeRune(b.buf[b.r:b.w])
|
||||
}
|
||||
b.r += size
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ func Vconv(v Val, flag FmtFlag) string {
|
|||
|
||||
case CTRUNE:
|
||||
x := v.U.(*Mpint).Int64()
|
||||
if ' ' <= x && x < 0x80 && x != '\\' && x != '\'' {
|
||||
if ' ' <= x && x < utf8.RuneSelf && x != '\\' && x != '\'' {
|
||||
return fmt.Sprintf("'%c'", int(x))
|
||||
}
|
||||
if 0 <= x && x < 1<<16 {
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ func isPrintable(b byte) bool {
|
|||
// byte slice and returns it.
|
||||
func parseIA5String(bytes []byte) (ret string, err error) {
|
||||
for _, b := range bytes {
|
||||
if b >= 0x80 {
|
||||
if b >= utf8.RuneSelf {
|
||||
err = SyntaxError{"IA5String contains invalid character"}
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1266,7 +1266,7 @@ func safeCgoName(s string, spaces bool) bool {
|
|||
safe = safe[len(safeSpaces):]
|
||||
}
|
||||
for i := 0; i < len(s); i++ {
|
||||
if c := s[i]; c < 0x80 && bytes.IndexByte(safe, c) < 0 {
|
||||
if c := s[i]; c < utf8.RuneSelf && bytes.IndexByte(safe, c) < 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"bufio"
|
||||
"errors"
|
||||
"io"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
type importReader struct {
|
||||
|
|
@ -20,7 +21,7 @@ type importReader struct {
|
|||
}
|
||||
|
||||
func isIdent(c byte) bool {
|
||||
return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || '0' <= c && c <= '9' || c == '_' || c >= 0x80
|
||||
return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || '0' <= c && c <= '9' || c == '_' || c >= utf8.RuneSelf
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ func (s *Scanner) next() {
|
|||
switch {
|
||||
case r == 0:
|
||||
s.error(s.offset, "illegal character NUL")
|
||||
case r >= 0x80:
|
||||
case r >= utf8.RuneSelf:
|
||||
// not ASCII
|
||||
r, w = utf8.DecodeRune(s.src[s.rdOffset:])
|
||||
if r == utf8.RuneError && w == 1 {
|
||||
|
|
@ -255,11 +255,11 @@ func (s *Scanner) findLineEnd() bool {
|
|||
}
|
||||
|
||||
func isLetter(ch rune) bool {
|
||||
return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' || ch >= 0x80 && unicode.IsLetter(ch)
|
||||
return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' || ch >= utf8.RuneSelf && unicode.IsLetter(ch)
|
||||
}
|
||||
|
||||
func isDigit(ch rune) bool {
|
||||
return '0' <= ch && ch <= '9' || ch >= 0x80 && unicode.IsDigit(ch)
|
||||
return '0' <= ch && ch <= '9' || ch >= utf8.RuneSelf && unicode.IsDigit(ch)
|
||||
}
|
||||
|
||||
func (s *Scanner) scanIdentifier() string {
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ func cssValueFilter(args ...interface{}) string {
|
|||
return filterFailsafe
|
||||
}
|
||||
default:
|
||||
if c < 0x80 && isCSSNmchar(rune(c)) {
|
||||
if c < utf8.RuneSelf && isCSSNmchar(rune(c)) {
|
||||
id = append(id, c)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ func encode(prefix, s string) (string, error) {
|
|||
delta, n, bias := int32(0), initialN, initialBias
|
||||
b, remaining := int32(0), int32(0)
|
||||
for _, r := range s {
|
||||
if r < 0x80 {
|
||||
if r < utf8.RuneSelf {
|
||||
b++
|
||||
output = append(output, byte(r))
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue