diff options
Diffstat (limited to 'libgo/go/exp/template/html/css.go')
-rw-r--r-- | libgo/go/exp/template/html/css.go | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/libgo/go/exp/template/html/css.go b/libgo/go/exp/template/html/css.go index c22ec6df0d0..c26ae78d17f 100644 --- a/libgo/go/exp/template/html/css.go +++ b/libgo/go/exp/template/html/css.go @@ -35,19 +35,19 @@ func endsWithCSSKeyword(b []byte, kw string) bool { } // isCSSNmchar returns whether rune is allowed anywhere in a CSS identifier. -func isCSSNmchar(rune int) bool { +func isCSSNmchar(r rune) bool { // Based on the CSS3 nmchar production but ignores multi-rune escape // sequences. // http://www.w3.org/TR/css3-syntax/#SUBTOK-nmchar - return 'a' <= rune && rune <= 'z' || - 'A' <= rune && rune <= 'Z' || - '0' <= rune && rune <= '9' || - '-' == rune || - '_' == rune || + return 'a' <= r && r <= 'z' || + 'A' <= r && r <= 'Z' || + '0' <= r && r <= '9' || + r == '-' || + r == '_' || // Non-ASCII cases below. - 0x80 <= rune && rune <= 0xd7ff || - 0xe000 <= rune && rune <= 0xfffd || - 0x10000 <= rune && rune <= 0x10ffff + 0x80 <= r && r <= 0xd7ff || + 0xe000 <= r && r <= 0xfffd || + 0x10000 <= r && r <= 0x10ffff } // decodeCSS decodes CSS3 escapes given a sequence of stringchars. @@ -81,11 +81,11 @@ func decodeCSS(s []byte) []byte { for j < len(s) && j < 7 && isHex(s[j]) { j++ } - rune := hexDecode(s[1:j]) - if rune > unicode.MaxRune { - rune, j = rune/16, j-1 + r := hexDecode(s[1:j]) + if r > unicode.MaxRune { + r, j = r/16, j-1 } - n := utf8.EncodeRune(b[len(b):cap(b)], rune) + n := utf8.EncodeRune(b[len(b):cap(b)], r) // The optional space at the end allows a hex // sequence to be followed by a literal hex. // string(decodeCSS([]byte(`\A B`))) == "\nB" @@ -105,17 +105,17 @@ func isHex(c byte) bool { } // hexDecode decodes a short hex digit sequence: "10" -> 16. -func hexDecode(s []byte) int { - n := 0 +func hexDecode(s []byte) rune { + n := rune(0) for _, c := range s { n <<= 4 switch { case '0' <= c && c <= '9': - n |= int(c - '0') + n |= rune(c - '0') case 'a' <= c && c <= 'f': - n |= int(c-'a') + 10 + n |= rune(c-'a') + 10 case 'A' <= c && c <= 'F': - n |= int(c-'A') + 10 + n |= rune(c-'A') + 10 default: panic(fmt.Sprintf("Bad hex digit in %q", s)) } @@ -251,11 +251,11 @@ func cssValueFilter(args ...interface{}) string { case '-': // Disallow <!-- or -->. // -- should not appear in valid identifiers. - if i != 0 && '-' == b[i-1] { + if i != 0 && b[i-1] == '-' { return filterFailsafe } default: - if c < 0x80 && isCSSNmchar(int(c)) { + if c < 0x80 && isCSSNmchar(rune(c)) { id = append(id, c) } } |