diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2014-07-19 08:53:52 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2014-07-19 08:53:52 +0000 |
commit | 00d86ac99f5dd6afa5bbd7c38ffe1c585edd2387 (patch) | |
tree | b988e32ea14a3dc1b4718b1fdfa47bab087ae96c /libgo/go/unicode | |
parent | bcf2fc6ee0a7edbe7de4299f28b66527c07bb0a2 (diff) | |
download | gcc-00d86ac99f5dd6afa5bbd7c38ffe1c585edd2387.zip gcc-00d86ac99f5dd6afa5bbd7c38ffe1c585edd2387.tar.gz gcc-00d86ac99f5dd6afa5bbd7c38ffe1c585edd2387.tar.bz2 |
libgo: Update to Go 1.3 release.
From-SVN: r212837
Diffstat (limited to 'libgo/go/unicode')
-rw-r--r-- | libgo/go/unicode/letter.go | 2 | ||||
-rw-r--r-- | libgo/go/unicode/letter_test.go | 16 | ||||
-rw-r--r-- | libgo/go/unicode/utf16/utf16.go | 2 | ||||
-rw-r--r-- | libgo/go/unicode/utf8/utf8.go | 32 |
4 files changed, 16 insertions, 36 deletions
diff --git a/libgo/go/unicode/letter.go b/libgo/go/unicode/letter.go index 3b389e9..977bd2b 100644 --- a/libgo/go/unicode/letter.go +++ b/libgo/go/unicode/letter.go @@ -316,7 +316,7 @@ type foldPair struct { // SimpleFold iterates over Unicode code points equivalent under // the Unicode-defined simple case folding. Among the code points // equivalent to rune (including rune itself), SimpleFold returns the -// smallest rune >= r if one exists, or else the smallest rune >= 0. +// smallest rune > r if one exists, or else the smallest rune >= 0. // // For example: // SimpleFold('A') = 'a' diff --git a/libgo/go/unicode/letter_test.go b/libgo/go/unicode/letter_test.go index e4d5572..4ee11fb 100644 --- a/libgo/go/unicode/letter_test.go +++ b/libgo/go/unicode/letter_test.go @@ -387,32 +387,20 @@ func TestTurkishCase(t *testing.T) { } var simpleFoldTests = []string{ - // SimpleFold could order its returned slices in any order it wants, - // but we know it orders them in increasing order starting at in - // and looping around from MaxRune to 0. + // SimpleFold(x) returns the next equivalent rune > x or wraps + // around to smaller values. // Easy cases. "Aa", - "aA", "δΔ", - "Δδ", // ASCII special cases. "KkK", - "kKK", - "KKk", "Ssſ", - "sſS", - "ſSs", // Non-ASCII special cases. "ρϱΡ", - "ϱΡρ", - "Ρρϱ", "ͅΙιι", - "Ιιιͅ", - "ιιͅΙ", - "ιͅΙι", // Extra special cases: has lower/upper but no case fold. "İ", diff --git a/libgo/go/unicode/utf16/utf16.go b/libgo/go/unicode/utf16/utf16.go index 903e401..c0e47c5 100644 --- a/libgo/go/unicode/utf16/utf16.go +++ b/libgo/go/unicode/utf16/utf16.go @@ -36,7 +36,7 @@ func IsSurrogate(r rune) bool { // the Unicode replacement code point U+FFFD. func DecodeRune(r1, r2 rune) rune { if surr1 <= r1 && r1 < surr2 && surr2 <= r2 && r2 < surr3 { - return (rune(r1)-surr1)<<10 | (rune(r2) - surr2) + 0x10000 + return (r1-surr1)<<10 | (r2 - surr2) + 0x10000 } return replacementChar } diff --git a/libgo/go/unicode/utf8/utf8.go b/libgo/go/unicode/utf8/utf8.go index 93d0be5..0dc859a 100644 --- a/libgo/go/unicode/utf8/utf8.go +++ b/libgo/go/unicode/utf8/utf8.go @@ -329,37 +329,29 @@ func RuneLen(r rune) int { // It returns the number of bytes written. func EncodeRune(p []byte, r rune) int { // Negative values are erroneous. Making it unsigned addresses the problem. - if uint32(r) <= rune1Max { + switch i := uint32(r); { + case i <= rune1Max: p[0] = byte(r) return 1 - } - - if uint32(r) <= rune2Max { + case i <= rune2Max: p[0] = t2 | byte(r>>6) p[1] = tx | byte(r)&maskx return 2 - } - - if uint32(r) > MaxRune { + case i > MaxRune, surrogateMin <= i && i <= surrogateMax: r = RuneError - } - - if surrogateMin <= r && r <= surrogateMax { - r = RuneError - } - - if uint32(r) <= rune3Max { + fallthrough + case i <= rune3Max: p[0] = t3 | byte(r>>12) p[1] = tx | byte(r>>6)&maskx p[2] = tx | byte(r)&maskx return 3 + default: + p[0] = t4 | byte(r>>18) + p[1] = tx | byte(r>>12)&maskx + p[2] = tx | byte(r>>6)&maskx + p[3] = tx | byte(r)&maskx + return 4 } - - p[0] = t4 | byte(r>>18) - p[1] = tx | byte(r>>12)&maskx - p[2] = tx | byte(r>>6)&maskx - p[3] = tx | byte(r)&maskx - return 4 } // RuneCount returns the number of runes in p. Erroneous and short |