Commit 67da5973 authored by Sylvain Zimmer's avatar Sylvain Zimmer Committed by Daniel Martí

regexp: Remove duplicated function wordRune()

Fixes #21742

Change-Id: Ib56b092c490c27a4ba7ebdb6391f1511794710b8
Reviewed-on: https://go-review.googlesource.com/61034
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarEmmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: default avatarDaniel Martí <mvdan@mvdan.cc>
parent 44f7fd03
......@@ -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")
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment