Commit 0f022fdd authored by Ian Lance Taylor's avatar Ian Lance Taylor

regexp/syntax: fix validity testing of zero repeats

This is already tested by TestRE2Exhaustive, but the build has
not broken because that test is not run when using -test.short.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/155580043
parent 3811c4d8
......@@ -272,14 +272,19 @@ func (p *parser) repeat(op Op, min, max int, before, after, lastRepeat string) (
func repeatIsValid(re *Regexp, n int) bool {
if re.Op == OpRepeat {
m := re.Max
if m == 0 {
return true
}
if m < 0 {
m = re.Min
}
if m > n {
return false
}
if m > 0 {
n /= m
}
}
for _, sub := range re.Sub {
if !repeatIsValid(sub, n) {
return false
......
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