]> Cypherpunks repositories - gostls13.git/commitdiff
godoc: fix path problem for windows.
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Fri, 18 Mar 2011 05:27:30 +0000 (22:27 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 18 Mar 2011 05:27:30 +0000 (22:27 -0700)
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/4299044

src/cmd/godoc/dirtrees.go
src/cmd/godoc/main.go

index 3ad7c8cfc50536ac283f82ca8e09956df55c067b..c13ff235dd68d5493250b0e92b5cf2c14e4ef498 100644 (file)
@@ -266,8 +266,8 @@ func (dir *Directory) lookupLocal(name string) *Directory {
 
 // lookup looks for the *Directory for a given path, relative to dir.
 func (dir *Directory) lookup(path string) *Directory {
-       d := strings.Split(dir.Path, "/", -1)
-       p := strings.Split(path, "/", -1)
+       d := strings.Split(dir.Path, string(filepath.Separator), -1)
+       p := strings.Split(path, string(filepath.Separator), -1)
        i := 0
        for i < len(d) {
                if i >= len(p) || d[i] != p[i] {
@@ -342,8 +342,8 @@ func (root *Directory) listing(skipRoot bool) *DirList {
                if strings.HasPrefix(d.Path, root.Path) {
                        path = d.Path[len(root.Path):]
                }
-               // remove trailing '/' if any - path must be relative
-               if len(path) > 0 && path[0] == '/' {
+               // remove trailing separator if any - path must be relative
+               if len(path) > 0 && filepath.IsAbs(path) {
                        path = path[1:]
                }
                p.Path = path
index b31758bc88a5859624b695f54449d33d7b071588..e426626b3b8821741bdeb5da42fd6071a9568c07 100644 (file)
@@ -222,6 +222,9 @@ func main() {
        flag.Usage = usage
        flag.Parse()
 
+       // Clean goroot: normalize path separator.
+       *goroot = filepath.Clean(*goroot)
+
        // Check usage: either server and no args, or command line and args
        if (*httpAddr != "") != (flag.NArg() == 0) {
                usage()