diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-13 19:16:27 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-13 19:16:27 +0000 |
commit | 7b1c3dd9e670da2041ff1af415999310f88888ad (patch) | |
tree | c5132538d5da85ed816c7e1f9d93c4a503b838ab /libgo/go/strings/strings.go | |
parent | 36cfbee133027429a681ce585643d38228ab1213 (diff) | |
download | gcc-7b1c3dd9e670da2041ff1af415999310f88888ad.zip gcc-7b1c3dd9e670da2041ff1af415999310f88888ad.tar.gz gcc-7b1c3dd9e670da2041ff1af415999310f88888ad.tar.bz2 |
libgo: Update to weekly.2011-12-02.
From-SVN: r182295
Diffstat (limited to 'libgo/go/strings/strings.go')
-rw-r--r-- | libgo/go/strings/strings.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/libgo/go/strings/strings.go b/libgo/go/strings/strings.go index b4d9207..53fdead 100644 --- a/libgo/go/strings/strings.go +++ b/libgo/go/strings/strings.go @@ -64,7 +64,17 @@ func Count(s, sep string) int { // Contains returns true if substr is within s. func Contains(s, substr string) bool { - return Index(s, substr) != -1 + return Index(s, substr) >= 0 +} + +// ContainsAny returns true if any Unicode code points in chars are within s. +func ContainsAny(s, chars string) bool { + return IndexAny(s, chars) >= 0 +} + +// ContainsRune returns true if the Unicode code point r is within s. +func ContainsRune(s string, r rune) bool { + return IndexRune(s, r) >= 0 } // Index returns the index of the first instance of sep in s, or -1 if sep is not present in s. @@ -269,7 +279,7 @@ func FieldsFunc(s string, f func(rune) bool) []string { fieldStart = i } } - if fieldStart != -1 { // Last field might end at EOF. + if fieldStart >= 0 { // Last field might end at EOF. a[na] = s[fieldStart:] } return a @@ -512,7 +522,7 @@ func lastIndexFunc(s string, f func(rune) bool, truth bool) int { } func makeCutsetFunc(cutset string) func(rune) bool { - return func(r rune) bool { return IndexRune(cutset, r) != -1 } + return func(r rune) bool { return IndexRune(cutset, r) >= 0 } } // Trim returns a slice of the string s with all leading and |