From 67da597312556ca8fed27c0ce85ea7a60cb5a783 Mon Sep 17 00:00:00 2001 From: Sylvain Zimmer Date: Sat, 2 Sep 2017 17:38:45 +0200 Subject: [PATCH] regexp: Remove duplicated function wordRune() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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í --- src/regexp/syntax/prog.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) 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") } -- 2.50.0