diff options
author | Ian Lance Taylor <iant@golang.org> | 2019-09-06 18:12:46 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-09-06 18:12:46 +0000 |
commit | aa8901e9bb0399d2c16f988ba2fe46eb0c0c5d13 (patch) | |
tree | 7e63b06d1eec92beec6997c9d3ab47a5d6a835be /libgo/go/os/path_unix.go | |
parent | 920ea3b8ba3164b61ac9490dfdfceb6936eda6dd (diff) | |
download | gcc-aa8901e9bb0399d2c16f988ba2fe46eb0c0c5d13.zip gcc-aa8901e9bb0399d2c16f988ba2fe46eb0c0c5d13.tar.gz gcc-aa8901e9bb0399d2c16f988ba2fe46eb0c0c5d13.tar.bz2 |
libgo: update to Go 1.13beta1 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/193497
From-SVN: r275473
Diffstat (limited to 'libgo/go/os/path_unix.go')
-rw-r--r-- | libgo/go/os/path_unix.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/libgo/go/os/path_unix.go b/libgo/go/os/path_unix.go index 4864989..4c97f39 100644 --- a/libgo/go/os/path_unix.go +++ b/libgo/go/os/path_unix.go @@ -38,20 +38,30 @@ func basename(name string) string { func splitPath(path string) (string, string) { // if no better parent is found, the path is relative from "here" dirname := "." - // if no slashes in path, base is path - basename := path + + // Remove all but one leading slash. + for len(path) > 1 && path[0] == '/' && path[1] == '/' { + path = path[1:] + } i := len(path) - 1 - // Remove trailing slashes + // Remove trailing slashes. for ; i > 0 && path[i] == '/'; i-- { path = path[:i] } + // if no slashes in path, base is path + basename := path + // Remove leading directory path for i--; i >= 0; i-- { if path[i] == '/' { - dirname = path[:i] + if i == 0 { + dirname = path[:1] + } else { + dirname = path[:i] + } basename = path[i+1:] break } |