[service/debugger] Case-insensitive paths on Windows

Fixes #370.
This commit is contained in:
Luke Hoban
2016-01-26 13:08:05 -08:00
committed by Derek Parker
parent 39bc379dd2
commit d756eba13a
4 changed files with 19 additions and 6 deletions

View File

@ -6,6 +6,7 @@ import (
"go/constant"
"path/filepath"
"reflect"
"runtime"
"strconv"
"strings"
@ -49,6 +50,13 @@ type FuncLocationSpec struct {
BaseName string
}
func normalizePath(path string) string {
if runtime.GOOS != "windows" {
return path
}
return strings.ToLower(filepath.ToSlash(path))
}
func parseLocationSpec(locStr string) (LocationSpec, error) {
rest := locStr
@ -98,7 +106,7 @@ func parseLocationSpecDefault(locStr, rest string) (LocationSpec, error) {
v := strings.Split(rest, ":")
if len(v) > 2 {
// On Windows, path may contain ":", so split only on last ":"
v = []string { strings.Join(v[0:len(v)-1], ":"), v[len(v)-1] }
v = []string{strings.Join(v[0:len(v)-1], ":"), v[len(v)-1]}
}
if len(v) == 1 {
@ -111,7 +119,6 @@ func parseLocationSpecDefault(locStr, rest string) (LocationSpec, error) {
spec := &NormalLocationSpec{}
spec.Base = v[0]
spec.Base = filepath.ToSlash(spec.Base)
spec.FuncBase = parseFuncLocationSpec(spec.Base)
if len(v) < 2 {
@ -284,6 +291,8 @@ func (loc *NormalLocationSpec) FileMatch(path string) bool {
}
func partialPathMatch(expr, path string) bool {
expr = normalizePath(expr)
path = normalizePath(path)
if len(expr) < len(path)-1 {
return strings.HasSuffix(path, expr) && (path[len(path)-len(expr)-1] == '/')
} else {