aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/path
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2011-01-21 18:19:03 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-01-21 18:19:03 +0000
commitff5f50c52c421d75940ef9392211e3ab24d71332 (patch)
tree27d8768fb1d25696d3c40b42535eb5e073c278da /libgo/go/path
parentd6ed1c8903e728f4233122554bab5910853338bd (diff)
downloadgcc-ff5f50c52c421d75940ef9392211e3ab24d71332.zip
gcc-ff5f50c52c421d75940ef9392211e3ab24d71332.tar.gz
gcc-ff5f50c52c421d75940ef9392211e3ab24d71332.tar.bz2
Remove the types float and complex.
Update to current version of Go library. Update testsuite for removed types. * go-lang.c (go_langhook_init): Omit float_type_size when calling go_create_gogo. * go-c.h: Update declaration of go_create_gogo. From-SVN: r169098
Diffstat (limited to 'libgo/go/path')
-rw-r--r--libgo/go/path/match.go6
-rw-r--r--libgo/go/path/path.go12
-rw-r--r--libgo/go/path/path_test.go14
-rw-r--r--libgo/go/path/path_unix.go11
-rw-r--r--libgo/go/path/path_windows.go11
5 files changed, 44 insertions, 10 deletions
diff --git a/libgo/go/path/match.go b/libgo/go/path/match.go
index d5cd19f..dd3422c 100644
--- a/libgo/go/path/match.go
+++ b/libgo/go/path/match.go
@@ -240,9 +240,13 @@ func Glob(pattern string) (matches []string) {
// glob searches for files matching pattern in the directory dir
// and appends them to matches.
func glob(dir, pattern string, matches []string) []string {
- if fi, err := os.Stat(dir); err != nil || !fi.IsDirectory() {
+ fi, err := os.Stat(dir)
+ if err != nil {
return nil
}
+ if !fi.IsDirectory() {
+ return matches
+ }
d, err := os.Open(dir, os.O_RDONLY, 0666)
if err != nil {
return nil
diff --git a/libgo/go/path/path.go b/libgo/go/path/path.go
index 79b3000..61eea88 100644
--- a/libgo/go/path/path.go
+++ b/libgo/go/path/path.go
@@ -102,17 +102,13 @@ func Clean(path string) string {
return string(buf[0:w])
}
-// Split splits path immediately following the final slash,
+// Split splits path immediately following the final path separator,
// separating it into a directory and file name component.
-// If there is no slash in path, Split returns an empty dir and
+// If there is no separator in path, Split returns an empty dir and
// file set to path.
func Split(path string) (dir, file string) {
- for i := len(path) - 1; i >= 0; i-- {
- if path[i] == '/' {
- return path[0 : i+1], path[i+1:]
- }
- }
- return "", path
+ i := strings.LastIndexAny(path, PathSeps)
+ return path[:i+1], path[i+1:]
}
// Join joins any number of path elements into a single path, adding a
diff --git a/libgo/go/path/path_test.go b/libgo/go/path/path_test.go
index 2bbb924..6b4be07 100644
--- a/libgo/go/path/path_test.go
+++ b/libgo/go/path/path_test.go
@@ -6,6 +6,7 @@ package path
import (
"os"
+ "runtime"
"testing"
)
@@ -83,7 +84,18 @@ var splittests = []SplitTest{
{"/", "/", ""},
}
+var winsplittests = []SplitTest{
+ {`C:\Windows\System32`, `C:\Windows\`, `System32`},
+ {`C:\Windows\`, `C:\Windows\`, ``},
+ {`C:\Windows`, `C:\`, `Windows`},
+ {`C:Windows`, `C:`, `Windows`},
+ {`\\?\c:\`, `\\?\c:\`, ``},
+}
+
func TestSplit(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ splittests = append(splittests, winsplittests...)
+ }
for _, test := range splittests {
if d, f := Split(test.path); d != test.dir || f != test.file {
t.Errorf("Split(%q) = %q, %q, want %q, %q", test.path, d, f, test.dir, test.file)
@@ -245,7 +257,7 @@ func TestWalk(t *testing.T) {
errors := make(chan os.Error, 64)
Walk(tree.name, v, errors)
if err, ok := <-errors; ok {
- t.Errorf("no error expected, found: s", err)
+ t.Errorf("no error expected, found: %s", err)
}
checkMarks(t)
diff --git a/libgo/go/path/path_unix.go b/libgo/go/path/path_unix.go
new file mode 100644
index 0000000..7e8c5eb
--- /dev/null
+++ b/libgo/go/path/path_unix.go
@@ -0,0 +1,11 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package path
+
+const (
+ DirSeps = `/` // directory separators
+ VolumeSeps = `` // volume separators
+ PathSeps = DirSeps + VolumeSeps // all path separators
+)
diff --git a/libgo/go/path/path_windows.go b/libgo/go/path/path_windows.go
new file mode 100644
index 0000000..966eb49
--- /dev/null
+++ b/libgo/go/path/path_windows.go
@@ -0,0 +1,11 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package path
+
+const (
+ DirSeps = `\/` // directory separators
+ VolumeSeps = `:` // volume separators
+ PathSeps = DirSeps + VolumeSeps // all path separators
+)