diff options
Diffstat (limited to 'libgo/go/path/filepath/match.go')
-rw-r--r-- | libgo/go/path/filepath/match.go | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/libgo/go/path/filepath/match.go b/libgo/go/path/filepath/match.go index 38d264fb97a..db8b0260ca8 100644 --- a/libgo/go/path/filepath/match.go +++ b/libgo/go/path/filepath/match.go @@ -7,6 +7,7 @@ package filepath import ( "errors" "os" + "runtime" "sort" "strings" "unicode/utf8" @@ -37,6 +38,9 @@ var ErrBadPattern = errors.New("syntax error in pattern") // The only possible returned error is ErrBadPattern, when pattern // is malformed. // +// On Windows, escaping is disabled. Instead, '\\' is treated as +// path separator. +// func Match(pattern, name string) (matched bool, err error) { Pattern: for len(pattern) > 0 { @@ -95,9 +99,11 @@ Scan: for i = 0; i < len(pattern); i++ { switch pattern[i] { case '\\': - // error check handled in matchChunk: bad pattern. - if i+1 < len(pattern) { - i++ + if runtime.GOOS != "windows" { + // error check handled in matchChunk: bad pattern. + if i+1 < len(pattern) { + i++ + } } case '[': inrange = true @@ -167,10 +173,12 @@ func matchChunk(chunk, s string) (rest string, ok bool, err error) { chunk = chunk[1:] case '\\': - chunk = chunk[1:] - if len(chunk) == 0 { - err = ErrBadPattern - return + if runtime.GOOS != "windows" { + chunk = chunk[1:] + if len(chunk) == 0 { + err = ErrBadPattern + return + } } fallthrough @@ -191,7 +199,7 @@ func getEsc(chunk string) (r rune, nchunk string, err error) { err = ErrBadPattern return } - if chunk[0] == '\\' { + if chunk[0] == '\\' && runtime.GOOS != "windows" { chunk = chunk[1:] if len(chunk) == 0 { err = ErrBadPattern |