diff options
Diffstat (limited to 'libgo/go/unicode/letter.go')
-rw-r--r-- | libgo/go/unicode/letter.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/libgo/go/unicode/letter.go b/libgo/go/unicode/letter.go index 7fe4241..8aec920 100644 --- a/libgo/go/unicode/letter.go +++ b/libgo/go/unicode/letter.go @@ -27,7 +27,7 @@ type RangeTable struct { LatinOffset int // number of entries in R16 with Hi <= MaxLatin1 } -// Range16 represents of a range of 16-bit Unicode code points. The range runs from Lo to Hi +// Range16 represents of a range of 16-bit Unicode code points. The range runs from Lo to Hi // inclusive and has the specified stride. type Range16 struct { Lo uint16 @@ -36,7 +36,7 @@ type Range16 struct { } // Range32 represents of a range of Unicode code points and is used when one or -// more of the values will not fit in 16 bits. The range runs from Lo to Hi +// more of the values will not fit in 16 bits. The range runs from Lo to Hi // inclusive and has the specified stride. Lo and Hi must always be >= 1<<16. type Range32 struct { Lo uint32 @@ -48,10 +48,10 @@ type Range32 struct { // code point to one code point) case conversion. // The range runs from Lo to Hi inclusive, with a fixed stride of 1. Deltas // are the number to add to the code point to reach the code point for a -// different case for that character. They may be negative. If zero, it +// different case for that character. They may be negative. If zero, it // means the character is in the corresponding case. There is a special // case representing sequences of alternating corresponding Upper and Lower -// pairs. It appears with a fixed Delta of +// pairs. It appears with a fixed Delta of // {UpperLower, UpperLower, UpperLower} // The constant UpperLower has an otherwise impossible delta value. type CaseRange struct { @@ -217,7 +217,7 @@ func to(_case int, r rune, caseRange []CaseRange) rune { m := lo + (hi-lo)/2 cr := caseRange[m] if rune(cr.Lo) <= r && r <= rune(cr.Hi) { - delta := rune(cr.Delta[_case]) + delta := cr.Delta[_case] if delta > MaxRune { // In an Upper-Lower sequence, which always starts with // an UpperCase letter, the real deltas always look like: @@ -307,7 +307,7 @@ func (special SpecialCase) ToLower(r rune) rune { return r1 } -// caseOrbit is defined in tables.go as []foldPair. Right now all the +// caseOrbit is defined in tables.go as []foldPair. Right now all the // entries fit in uint16, so use uint16. If that changes, compilation // will fail (the constants in the composite literal will not fit in uint16) // and the types here can change to uint32. @@ -317,7 +317,7 @@ type foldPair struct { } // SimpleFold iterates over Unicode code points equivalent under -// the Unicode-defined simple case folding. Among the code points +// 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. // @@ -332,6 +332,10 @@ type foldPair struct { // SimpleFold('1') = '1' // func SimpleFold(r rune) rune { + if int(r) < len(asciiFold) { + return rune(asciiFold[r]) + } + // Consult caseOrbit table for special cases. lo := 0 hi := len(caseOrbit) @@ -347,7 +351,7 @@ func SimpleFold(r rune) rune { return rune(caseOrbit[lo].To) } - // No folding specified. This is a one- or two-element + // No folding specified. This is a one- or two-element // equivalence class containing rune and ToLower(rune) // and ToUpper(rune) if they are different from rune. if l := ToLower(r); l != r { |