From: Sylvain Zimmer Date: Sat, 2 Sep 2017 15:38:45 +0000 (+0200) Subject: regexp: Remove duplicated function wordRune() X-Git-Tag: go1.10beta1~1186 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=67da597312556ca8fed27c0ce85ea7a60cb5a783;p=gostls13.git regexp: Remove duplicated function wordRune() Fixes #21742 Change-Id: Ib56b092c490c27a4ba7ebdb6391f1511794710b8 Reviewed-on: https://go-review.googlesource.com/61034 Run-TryBot: Daniel Martí TryBot-Result: Gobot Gobot Reviewed-by: Emmanuel Odeke Reviewed-by: Daniel Martí --- diff --git a/src/regexp/syntax/prog.go b/src/regexp/syntax/prog.go index c32ae8d9fa..6c56371b4c 100644 --- a/src/regexp/syntax/prog.go +++ b/src/regexp/syntax/prog.go @@ -247,15 +247,6 @@ func (i *Inst) MatchRunePos(r rune) int { return noMatch } -// As per re2's Prog::IsWordChar. Determines whether rune is an ASCII word char. -// Since we act on runes, it would be easy to support Unicode here. -func wordRune(r rune) bool { - return r == '_' || - ('A' <= r && r <= 'Z') || - ('a' <= r && r <= 'z') || - ('0' <= r && r <= '9') -} - // MatchEmptyWidth reports whether the instruction matches // an empty string between the runes before and after. // It should only be called when i.Op == InstEmptyWidth. @@ -270,9 +261,9 @@ func (i *Inst) MatchEmptyWidth(before rune, after rune) bool { case EmptyEndText: return after == -1 case EmptyWordBoundary: - return wordRune(before) != wordRune(after) + return IsWordChar(before) != IsWordChar(after) case EmptyNoWordBoundary: - return wordRune(before) == wordRune(after) + return IsWordChar(before) == IsWordChar(after) } panic("unknown empty width arg") }