fixed parsering bug for like "*/5"

This commit is contained in:
Safx
2014-04-23 01:22:28 +09:00
parent f2ed51895e
commit b0d44377d8
2 changed files with 50 additions and 11 deletions

View File

@@ -411,6 +411,17 @@ func genericFieldParse(s string, desc fieldDescriptor) ([]*cronDirective, error)
send: indices[i][1],
}
snormal := strings.ToLower(s[indices[i][0]:indices[i][1]])
// `*/2`
pairs := makeLayoutRegexp(layoutWildcardAndInterval, desc.valuePattern).FindStringSubmatchIndex(snormal)
if len(pairs) > 0 {
directive.kind = span
directive.first = desc.min
directive.last = desc.max
directive.step = atoi(snormal[pairs[2]:pairs[3]])
directives = append(directives, &directive)
continue
}
// `*`
if makeLayoutRegexp(layoutWildcard, desc.valuePattern).MatchString(snormal) {
directive.kind = all
@@ -428,7 +439,7 @@ func genericFieldParse(s string, desc fieldDescriptor) ([]*cronDirective, error)
continue
}
// `5-20`
pairs := makeLayoutRegexp(layoutRange, desc.valuePattern).FindStringSubmatchIndex(snormal)
pairs = makeLayoutRegexp(layoutRange, desc.valuePattern).FindStringSubmatchIndex(snormal)
if len(pairs) > 0 {
directive.kind = span
directive.first = desc.atoi(snormal[pairs[2]:pairs[3]])
@@ -437,16 +448,6 @@ func genericFieldParse(s string, desc fieldDescriptor) ([]*cronDirective, error)
directives = append(directives, &directive)
continue
}
// `*/2`
pairs = makeLayoutRegexp(layoutWildcardAndInterval, desc.valuePattern).FindStringSubmatchIndex(snormal)
if len(pairs) > 0 {
directive.kind = span
directive.first = desc.min
directive.last = desc.max
directive.step = atoi(snormal[pairs[2]:pairs[3]])
directives = append(directives, &directive)
continue
}
// `5/2`
pairs = makeLayoutRegexp(layoutValueAndInterval, desc.valuePattern).FindStringSubmatchIndex(snormal)
if len(pairs) > 0 {