Commit b22e29d9 authored by Yasuhiro Matsumoto's avatar Yasuhiro Matsumoto Committed by Robert Griesemer

godoc: fix path problem for windows.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/4299044
parent 61c83b64
...@@ -266,8 +266,8 @@ func (dir *Directory) lookupLocal(name string) *Directory { ...@@ -266,8 +266,8 @@ func (dir *Directory) lookupLocal(name string) *Directory {
// lookup looks for the *Directory for a given path, relative to dir. // lookup looks for the *Directory for a given path, relative to dir.
func (dir *Directory) lookup(path string) *Directory { func (dir *Directory) lookup(path string) *Directory {
d := strings.Split(dir.Path, "/", -1) d := strings.Split(dir.Path, string(filepath.Separator), -1)
p := strings.Split(path, "/", -1) p := strings.Split(path, string(filepath.Separator), -1)
i := 0 i := 0
for i < len(d) { for i < len(d) {
if i >= len(p) || d[i] != p[i] { if i >= len(p) || d[i] != p[i] {
...@@ -342,8 +342,8 @@ func (root *Directory) listing(skipRoot bool) *DirList { ...@@ -342,8 +342,8 @@ func (root *Directory) listing(skipRoot bool) *DirList {
if strings.HasPrefix(d.Path, root.Path) { if strings.HasPrefix(d.Path, root.Path) {
path = d.Path[len(root.Path):] path = d.Path[len(root.Path):]
} }
// remove trailing '/' if any - path must be relative // remove trailing separator if any - path must be relative
if len(path) > 0 && path[0] == '/' { if len(path) > 0 && filepath.IsAbs(path) {
path = path[1:] path = path[1:]
} }
p.Path = path p.Path = path
......
...@@ -222,6 +222,9 @@ func main() { ...@@ -222,6 +222,9 @@ func main() {
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()
// Clean goroot: normalize path separator.
*goroot = filepath.Clean(*goroot)
// Check usage: either server and no args, or command line and args // Check usage: either server and no args, or command line and args
if (*httpAddr != "") != (flag.NArg() == 0) { if (*httpAddr != "") != (flag.NArg() == 0) {
usage() usage()
......
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