aboutsummaryrefslogtreecommitdiff
path: root/src/regexp/syntax/parse.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/regexp/syntax/parse.go')
-rw-r--r--src/regexp/syntax/parse.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/regexp/syntax/parse.go b/src/regexp/syntax/parse.go
index a4ccfe3bdb..6b360b8700 100644
--- a/src/regexp/syntax/parse.go
+++ b/src/regexp/syntax/parse.go
@@ -1863,6 +1863,22 @@ func cleanClass(rp *[]rune) []rune {
return r[:w]
}
+// inCharClass reports whether r is in the class.
+// It assumes the class has been cleaned by cleanClass.
+func inCharClass(r rune, class []rune) bool {
+ _, ok := sort.Find(len(class)/2, func(i int) int {
+ lo, hi := class[2*i], class[2*i+1]
+ if r > hi {
+ return +1
+ }
+ if r < lo {
+ return -1
+ }
+ return 0
+ })
+ return ok
+}
+
// appendLiteral returns the result of appending the literal x to the class r.
func appendLiteral(r []rune, x rune, flags Flags) []rune {
if flags&FoldCase != 0 {