summaryrefslogtreecommitdiff
path: root/libgo/go/unicode/letter.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/unicode/letter.go')
-rw-r--r--libgo/go/unicode/letter.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/libgo/go/unicode/letter.go b/libgo/go/unicode/letter.go
index 8aec920d22f..b43cc66e7d3 100644
--- a/libgo/go/unicode/letter.go
+++ b/libgo/go/unicode/letter.go
@@ -320,6 +320,7 @@ type foldPair struct {
// 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.
+// If r is not a valid Unicode code point, SimpleFold(r) returns r.
//
// For example:
// SimpleFold('A') = 'a'
@@ -331,7 +332,13 @@ type foldPair struct {
//
// SimpleFold('1') = '1'
//
+// SimpleFold(-2) = -2
+//
func SimpleFold(r rune) rune {
+ if r < 0 || r > MaxRune {
+ return r
+ }
+
if int(r) < len(asciiFold) {
return rune(asciiFold[r])
}