diff options
author | Ian Lance Taylor <iant@google.com> | 2015-01-15 00:27:56 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-01-15 00:27:56 +0000 |
commit | f8d9fa9e80b57f89e7877ce6cad8a3464879009b (patch) | |
tree | 58a1724fee16d2b03c65678c4dd9b50bb97137a9 /libgo/go/path | |
parent | 6bd3f109d8d8fa58eeccd6b3504721b4f20c00c2 (diff) | |
download | gcc-f8d9fa9e80b57f89e7877ce6cad8a3464879009b.zip gcc-f8d9fa9e80b57f89e7877ce6cad8a3464879009b.tar.gz gcc-f8d9fa9e80b57f89e7877ce6cad8a3464879009b.tar.bz2 |
libgo, compiler: Upgrade libgo to Go 1.4, except for runtime.
This upgrades all of libgo other than the runtime package to
the Go 1.4 release. In Go 1.4 much of the runtime was
rewritten into Go. Merging that code will take more time and
will not change the API, so I'm putting it off for now.
There are a few runtime changes anyhow, to accomodate other
packages that rely on minor modifications to the runtime
support.
The compiler changes slightly to add a one-bit flag to each
type descriptor kind that is stored directly in an interface,
which for gccgo is currently only pointer types. Another
one-bit flag (gcprog) is reserved because it is used by the gc
compiler, but gccgo does not currently use it.
There is another error check in the compiler since I ran
across it during testing.
gotools/:
* Makefile.am (go_cmd_go_files): Sort entries. Add generate.go.
* Makefile.in: Rebuild.
From-SVN: r219627
Diffstat (limited to 'libgo/go/path')
-rw-r--r-- | libgo/go/path/filepath/match.go | 8 | ||||
-rw-r--r-- | libgo/go/path/filepath/match_test.go | 7 | ||||
-rw-r--r-- | libgo/go/path/filepath/path.go | 11 | ||||
-rw-r--r-- | libgo/go/path/filepath/path_plan9.go | 4 | ||||
-rw-r--r-- | libgo/go/path/filepath/path_test.go | 33 | ||||
-rw-r--r-- | libgo/go/path/filepath/path_unix.go | 4 | ||||
-rw-r--r-- | libgo/go/path/filepath/path_windows.go | 5 | ||||
-rw-r--r-- | libgo/go/path/filepath/symlink.go | 19 | ||||
-rw-r--r-- | libgo/go/path/filepath/symlink_unix.go | 7 | ||||
-rw-r--r-- | libgo/go/path/filepath/symlink_windows.go | 5 | ||||
-rw-r--r-- | libgo/go/path/path.go | 10 |
11 files changed, 74 insertions, 39 deletions
diff --git a/libgo/go/path/filepath/match.go b/libgo/go/path/filepath/match.go index a9bcc10..ecc07aa 100644 --- a/libgo/go/path/filepath/match.go +++ b/libgo/go/path/filepath/match.go @@ -228,6 +228,9 @@ func getEsc(chunk string) (r rune, nchunk string, err error) { // as in Match. The pattern may describe hierarchical names such as // /usr/*/bin/ed (assuming the Separator is '/'). // +// Glob ignores file system errors such as I/O errors reading directories. +// The only possible returned error is ErrBadPattern, when pattern +// is malformed. func Glob(pattern string) (matches []string, err error) { if !hasMeta(pattern) { if _, err = os.Lstat(pattern); err != nil { @@ -283,10 +286,7 @@ func glob(dir, pattern string, matches []string) (m []string, e error) { } defer d.Close() - names, err := d.Readdirnames(-1) - if err != nil { - return - } + names, _ := d.Readdirnames(-1) sort.Strings(names) for _, n := range names { diff --git a/libgo/go/path/filepath/match_test.go b/libgo/go/path/filepath/match_test.go index 9886620..c29f93f 100644 --- a/libgo/go/path/filepath/match_test.go +++ b/libgo/go/path/filepath/match_test.go @@ -168,8 +168,13 @@ var globSymlinkTests = []struct { func TestGlobSymlink(t *testing.T) { switch runtime.GOOS { - case "nacl", "plan9", "windows": + case "nacl", "plan9": t.Skipf("skipping on %s", runtime.GOOS) + case "windows": + if !supportsSymlinks { + t.Skipf("skipping on %s", runtime.GOOS) + } + } tmpDir, err := ioutil.TempDir("", "globsymlink") diff --git a/libgo/go/path/filepath/path.go b/libgo/go/path/filepath/path.go index 71603cc..d37fc9d 100644 --- a/libgo/go/path/filepath/path.go +++ b/libgo/go/path/filepath/path.go @@ -231,6 +231,10 @@ func EvalSymlinks(path string) (string, error) { // working directory to turn it into an absolute path. The absolute // path name for a given file is not guaranteed to be unique. func Abs(path string) (string, error) { + return abs(path) +} + +func unixAbs(path string) (string, error) { if IsAbs(path) { return Clean(path), nil } @@ -448,13 +452,6 @@ func Dir(path string) string { i-- } dir := Clean(path[len(vol) : i+1]) - last := len(dir) - 1 - if last > 0 && os.IsPathSeparator(dir[last]) { - dir = dir[:last] - } - if dir == "" { - dir = "." - } return vol + dir } diff --git a/libgo/go/path/filepath/path_plan9.go b/libgo/go/path/filepath/path_plan9.go index 12e85aa..ee8912d 100644 --- a/libgo/go/path/filepath/path_plan9.go +++ b/libgo/go/path/filepath/path_plan9.go @@ -28,3 +28,7 @@ func splitList(path string) []string { } return strings.Split(path, string(ListSeparator)) } + +func abs(path string) (string, error) { + return unixAbs(path) +} diff --git a/libgo/go/path/filepath/path_test.go b/libgo/go/path/filepath/path_test.go index 6d11394..c3ee0cb 100644 --- a/libgo/go/path/filepath/path_test.go +++ b/libgo/go/path/filepath/path_test.go @@ -15,6 +15,8 @@ import ( "testing" ) +var supportsSymlinks = true + type PathTest struct { path, result string } @@ -629,6 +631,8 @@ var winisabstests = []IsAbsTest{ {`\`, false}, {`\Windows`, false}, {`c:a\b`, false}, + {`c:\a\b`, true}, + {`c:/a/b`, true}, {`\\host\share\foo`, true}, {`//host/share/foo/bar`, true}, } @@ -719,7 +723,7 @@ func TestEvalSymlinks(t *testing.T) { if d.dest == "" { err = os.Mkdir(path, 0755) } else { - if runtime.GOOS != "windows" { + if supportsSymlinks { err = os.Symlink(d.dest, path) } } @@ -729,7 +733,9 @@ func TestEvalSymlinks(t *testing.T) { } var tests []EvalSymlinksTest - if runtime.GOOS == "windows" { + if supportsSymlinks { + tests = EvalSymlinksTests + } else { for _, d := range EvalSymlinksTests { if d.path == d.dest { // will test only real files and directories @@ -742,15 +748,13 @@ func TestEvalSymlinks(t *testing.T) { tests = append(tests, d2) } } - } else { - tests = EvalSymlinksTests } // Evaluate the symlink farm. for _, d := range tests { path := simpleJoin(tmpDir, d.path) dest := simpleJoin(tmpDir, d.dest) - if filepath.IsAbs(d.dest) { + if filepath.IsAbs(d.dest) || os.IsPathSeparator(d.dest[0]) { dest = d.dest } if p, err := filepath.EvalSymlinks(path); err != nil { @@ -785,12 +789,6 @@ var absTests = []string{ } func TestAbs(t *testing.T) { - oldwd, err := os.Getwd() - if err != nil { - t.Fatal("Getwd failed: ", err) - } - defer os.Chdir(oldwd) - root, err := ioutil.TempDir("", "TestAbs") if err != nil { t.Fatal("TempDir failed: ", err) @@ -814,6 +812,19 @@ func TestAbs(t *testing.T) { } } + if runtime.GOOS == "windows" { + vol := filepath.VolumeName(root) + var extra []string + for _, path := range absTests { + if strings.Index(path, "$") != -1 { + continue + } + path = vol + path + extra = append(extra, path) + } + absTests = append(absTests, extra...) + } + err = os.Chdir(absTestDirs[0]) if err != nil { t.Fatal("chdir failed: ", err) diff --git a/libgo/go/path/filepath/path_unix.go b/libgo/go/path/filepath/path_unix.go index 7aba0ab..4e7d0d1 100644 --- a/libgo/go/path/filepath/path_unix.go +++ b/libgo/go/path/filepath/path_unix.go @@ -30,3 +30,7 @@ func splitList(path string) []string { } return strings.Split(path, string(ListSeparator)) } + +func abs(path string) (string, error) { + return unixAbs(path) +} diff --git a/libgo/go/path/filepath/path_windows.go b/libgo/go/path/filepath/path_windows.go index e999972..ec50f6b 100644 --- a/libgo/go/path/filepath/path_windows.go +++ b/libgo/go/path/filepath/path_windows.go @@ -6,6 +6,7 @@ package filepath import ( "strings" + "syscall" ) func isSlash(c uint8) bool { @@ -103,3 +104,7 @@ func splitList(path string) []string { return list } + +func abs(path string) (string, error) { + return syscall.FullPath(path) +} diff --git a/libgo/go/path/filepath/symlink.go b/libgo/go/path/filepath/symlink.go index 307dd0f..df0a9e0 100644 --- a/libgo/go/path/filepath/symlink.go +++ b/libgo/go/path/filepath/symlink.go @@ -2,18 +2,17 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build !windows - package filepath import ( "bytes" "errors" "os" - "strings" ) -func evalSymlinks(path string) (string, error) { +const utf8RuneSelf = 0x80 + +func walkSymlinks(path string) (string, error) { const maxIter = 255 originalPath := path // consume path by taking each frontmost path element, @@ -25,7 +24,13 @@ func evalSymlinks(path string) (string, error) { } // find next path component, p - i := strings.IndexRune(path, Separator) + var i = -1 + for j, c := range path { + if c < utf8RuneSelf && os.IsPathSeparator(uint8(c)) { + i = j + break + } + } var p string if i == -1 { p, path = path, "" @@ -47,7 +52,7 @@ func evalSymlinks(path string) (string, error) { } if fi.Mode()&os.ModeSymlink == 0 { b.WriteString(p) - if path != "" { + if path != "" || (b.Len() == 2 && len(p) == 2 && p[1] == ':') { b.WriteRune(Separator) } continue @@ -58,7 +63,7 @@ func evalSymlinks(path string) (string, error) { if err != nil { return "", err } - if IsAbs(dest) { + if IsAbs(dest) || os.IsPathSeparator(dest[0]) { b.Reset() } path = dest + string(Separator) + path diff --git a/libgo/go/path/filepath/symlink_unix.go b/libgo/go/path/filepath/symlink_unix.go new file mode 100644 index 0000000..d20e63a --- /dev/null +++ b/libgo/go/path/filepath/symlink_unix.go @@ -0,0 +1,7 @@ +// +build !windows + +package filepath + +func evalSymlinks(path string) (string, error) { + return walkSymlinks(path) +} diff --git a/libgo/go/path/filepath/symlink_windows.go b/libgo/go/path/filepath/symlink_windows.go index 9adc8a4..327c2c8 100644 --- a/libgo/go/path/filepath/symlink_windows.go +++ b/libgo/go/path/filepath/symlink_windows.go @@ -50,6 +50,11 @@ func toLong(path string) (string, error) { } func evalSymlinks(path string) (string, error) { + path, err := walkSymlinks(path) + if err != nil { + return "", err + } + p, err := toShort(path) if err != nil { return "", err diff --git a/libgo/go/path/path.go b/libgo/go/path/path.go index bdb85c6..98a6d52 100644 --- a/libgo/go/path/path.go +++ b/libgo/go/path/path.go @@ -206,13 +206,5 @@ func IsAbs(path string) bool { // slash. func Dir(path string) string { dir, _ := Split(path) - dir = Clean(dir) - last := len(dir) - 1 - if last > 0 && dir[last] == '/' { - dir = dir[:last] - } - if dir == "" { - dir = "." - } - return dir + return Clean(dir) } |