]> Cypherpunks repositories - gostls13.git/commitdiff
all: replace magic 0x80 with named constant utf8.RuneSelf
authorMartin Möhrmann <martisch@uos.de>
Sun, 10 Apr 2016 06:48:55 +0000 (08:48 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sun, 10 Apr 2016 15:15:57 +0000 (15:15 +0000)
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>

src/bufio/bufio.go
src/cmd/compile/internal/gc/fmt.go
src/encoding/asn1/asn1.go
src/go/build/build.go
src/go/build/read.go
src/go/scanner/scanner.go
src/html/template/css.go
src/net/http/cookiejar/punycode.go

index d2ccc74f5263df45bfefb0a55c2fa5685faac5c6..3b30b8b80cd6c0f66e7f0ae15e24b5db8c89aeaf 100644 (file)
@@ -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
index 19f109055d09178256d7b693a462ce658cb7c4c7..41d696574ced88ffdf7873d7e2cd6c2dbf386811 100644 (file)
@@ -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 {
index bd2c96d887150b170394af0e5e64ffc7c9134a74..2b5ad08551ec71692fc2a287c9df37aaa4fe7a3f 100644 (file)
@@ -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
                }
index e61d564fa34195000c0c0f5331cac1002615a05f..04a41a6c2ecda7d97328fc03e80879b6dde1a07a 100644 (file)
@@ -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
                }
        }
index d411c1980e4bff1205008782fdfcf8de08762322..29b8cdc786711ba08716bb1a42454eadf3ba5b44 100644 (file)
@@ -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 (
index 4041d9aa470653ff2bb3940ac54e0d961dc9ff02..ce660c71d5c954218a88221ceb41235f266874b2 100644 (file)
@@ -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 {
index 4c27cce85ac830d1032de3a4e130e0408bb24f0f..9154d8636dab0fca200837df5249b11859eb2555 100644 (file)
@@ -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)
                        }
                }
index ea7ceb5ef3f94a4f8f6df12eac3703fc3ceb01c1..a9cc666e8c9637e9806b22581ece20aef131735f 100644 (file)
@@ -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 {