Home | History | Annotate | Download | only in path

Lines Matching refs:pattern

13 // ErrBadPattern indicates a globbing pattern was malformed.
14 var ErrBadPattern = errors.New("syntax error in pattern")
16 // Match reports whether name matches the shell file name pattern.
17 // The pattern syntax is:
19 // pattern:
34 // Match requires pattern to match all of name, not just a substring.
35 // The only possible returned error is ErrBadPattern, when pattern
38 func Match(pattern, name string) (matched bool, err error) {
39 Pattern:
40 for len(pattern) > 0 {
43 star, chunk, pattern = scanChunk(pattern)
53 if ok && (len(t) == 0 || len(pattern) > 0) {
67 if len(pattern) == 0 && len(t) > 0 {
71 continue Pattern
83 // scanChunk gets the next segment of pattern, which is a non-star string
85 func scanChunk(pattern string) (star bool, chunk, rest string) {
86 for len(pattern) > 0 && pattern[0] == '*' {
87 pattern = pattern[1:]
93 for i = 0; i < len(pattern); i++ {
94 switch pattern[i] {
96 // error check handled in matchChunk: bad pattern.
97 if i+1 < len(pattern) {
110 return star, pattern[0:i], pattern[i:]