diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-03 02:17:34 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-03 02:17:34 +0000 |
commit | 2fd401c8f190f1fe43e51a7f726f6ed6119a1f96 (patch) | |
tree | 7f76eff391f37fe6467ff4ffbc0c582c9959ea30 /libgo/go/path | |
parent | 02e9018f1616b23f1276151797216717b3564202 (diff) | |
download | gcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.zip gcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.tar.gz gcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.tar.bz2 |
libgo: Update to weekly.2011-11-02.
From-SVN: r181964
Diffstat (limited to 'libgo/go/path')
-rw-r--r-- | libgo/go/path/filepath/match.go | 13 | ||||
-rw-r--r-- | libgo/go/path/filepath/match_test.go | 7 | ||||
-rw-r--r-- | libgo/go/path/filepath/path.go | 23 | ||||
-rw-r--r-- | libgo/go/path/filepath/path_test.go | 10 | ||||
-rw-r--r-- | libgo/go/path/match.go | 10 | ||||
-rw-r--r-- | libgo/go/path/match_test.go | 7 |
6 files changed, 34 insertions, 36 deletions
diff --git a/libgo/go/path/filepath/match.go b/libgo/go/path/filepath/match.go index 15c84a7..bc0930e 100644 --- a/libgo/go/path/filepath/match.go +++ b/libgo/go/path/filepath/match.go @@ -5,13 +5,14 @@ package filepath import ( + "errors" "os" "sort" "strings" "utf8" ) -var ErrBadPattern = os.NewError("syntax error in pattern") +var ErrBadPattern = errors.New("syntax error in pattern") // Match returns true if name matches the shell file name pattern. // The pattern syntax is: @@ -34,7 +35,7 @@ var ErrBadPattern = os.NewError("syntax error in pattern") // Match requires pattern to match all of name, not just a substring. // The only possible error return occurs when the pattern is malformed. // -func Match(pattern, name string) (matched bool, err os.Error) { +func Match(pattern, name string) (matched bool, err error) { Pattern: for len(pattern) > 0 { var star bool @@ -112,7 +113,7 @@ Scan: // matchChunk checks whether chunk matches the beginning of s. // If so, it returns the remainder of s (after the match). // Chunk is all single-character operators: literals, char classes, and ?. -func matchChunk(chunk, s string) (rest string, ok bool, err os.Error) { +func matchChunk(chunk, s string) (rest string, ok bool, err error) { for len(chunk) > 0 { if len(s) == 0 { return @@ -183,7 +184,7 @@ func matchChunk(chunk, s string) (rest string, ok bool, err os.Error) { } // getEsc gets a possibly-escaped character from chunk, for a character class. -func getEsc(chunk string) (r rune, nchunk string, err os.Error) { +func getEsc(chunk string) (r rune, nchunk string, err error) { if len(chunk) == 0 || chunk[0] == '-' || chunk[0] == ']' { err = ErrBadPattern return @@ -212,7 +213,7 @@ func getEsc(chunk string) (r rune, nchunk string, err os.Error) { // /usr/*/bin/ed (assuming the Separator is '/'). // The only possible error return occurs when the pattern is malformed. // -func Glob(pattern string) (matches []string, err os.Error) { +func Glob(pattern string) (matches []string, err error) { if !hasMeta(pattern) { if _, err = os.Stat(pattern); err != nil { return nil, nil @@ -253,7 +254,7 @@ func Glob(pattern string) (matches []string, err os.Error) { // opened, it returns the existing matches. New matches are // added in lexicographical order. // The only possible error return occurs when the pattern is malformed. -func glob(dir, pattern string, matches []string) (m []string, e os.Error) { +func glob(dir, pattern string, matches []string) (m []string, e error) { m = matches fi, err := os.Stat(dir) if err != nil { diff --git a/libgo/go/path/filepath/match_test.go b/libgo/go/path/filepath/match_test.go index fa7aad9..bf253a4 100644 --- a/libgo/go/path/filepath/match_test.go +++ b/libgo/go/path/filepath/match_test.go @@ -5,7 +5,6 @@ package filepath_test import ( - "os" . "path/filepath" "testing" "runtime" @@ -14,7 +13,7 @@ import ( type MatchTest struct { pattern, s string match bool - err os.Error + err error } var matchTests = []MatchTest{ @@ -69,11 +68,11 @@ var matchTests = []MatchTest{ {"*x", "xxx", true, nil}, } -func errp(e os.Error) string { +func errp(e error) string { if e == nil { return "<nil>" } - return e.String() + return e.Error() } func TestMatch(t *testing.T) { diff --git a/libgo/go/path/filepath/path.go b/libgo/go/path/filepath/path.go index afb8f10..1b5d6c3 100644 --- a/libgo/go/path/filepath/path.go +++ b/libgo/go/path/filepath/path.go @@ -8,6 +8,7 @@ package filepath import ( "bytes" + "errors" "os" "runtime" "sort" @@ -182,7 +183,7 @@ func Ext(path string) string { // EvalSymlinks returns the path name after the evaluation of any symbolic // links. // If path is relative it will be evaluated relative to the current directory. -func EvalSymlinks(path string) (string, os.Error) { +func EvalSymlinks(path string) (string, error) { if runtime.GOOS == "windows" { // Symlinks are not supported under windows. _, err := os.Lstat(path) @@ -198,7 +199,7 @@ func EvalSymlinks(path string) (string, os.Error) { var b bytes.Buffer for n := 0; path != ""; n++ { if n > maxIter { - return "", os.NewError("EvalSymlinks: too many links in " + originalPath) + return "", errors.New("EvalSymlinks: too many links in " + originalPath) } // find next path component, p @@ -247,7 +248,7 @@ func EvalSymlinks(path string) (string, os.Error) { // If the path is not absolute it will be joined with the current // 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, os.Error) { +func Abs(path string) (string, error) { if IsAbs(path) { return Clean(path), nil } @@ -263,7 +264,7 @@ func Abs(path string) (string, os.Error) { // Join(basepath, Rel(basepath, targpath)) is equivalent to targpath itself. // An error is returned if targpath can't be made relative to basepath or if // knowing the current working directory would be necessary to compute it. -func Rel(basepath, targpath string) (string, os.Error) { +func Rel(basepath, targpath string) (string, error) { baseVol := VolumeName(basepath) targVol := VolumeName(targpath) base := Clean(basepath) @@ -280,7 +281,7 @@ func Rel(basepath, targpath string) (string, os.Error) { baseSlashed := len(base) > 0 && base[0] == Separator targSlashed := len(targ) > 0 && targ[0] == Separator if baseSlashed != targSlashed || baseVol != targVol { - return "", os.NewError("Rel: can't make " + targ + " relative to " + base) + return "", errors.New("Rel: can't make " + targ + " relative to " + base) } // Position base[b0:bi] and targ[t0:ti] at the first differing elements. bl := len(base) @@ -306,7 +307,7 @@ func Rel(basepath, targpath string) (string, os.Error) { t0 = ti } if base[b0:bi] == ".." { - return "", os.NewError("Rel: can't make " + targ + " relative to " + base) + return "", errors.New("Rel: can't make " + targ + " relative to " + base) } if b0 != bl { // Base elements left. Must go up before going down. @@ -330,7 +331,7 @@ func Rel(basepath, targpath string) (string, os.Error) { // SkipDir is used as a return value from WalkFuncs to indicate that // the directory named in the call is to be skipped. It is not returned // as an error by any function. -var SkipDir = os.NewError("skip this directory") +var SkipDir = errors.New("skip this directory") // WalkFunc is the type of the function called for each file or directory // visited by Walk. If there was a problem walking to the file or directory @@ -340,10 +341,10 @@ var SkipDir = os.NewError("skip this directory") // sole exception is that if path is a directory and the function returns the // special value SkipDir, the contents of the directory are skipped // and processing continues as usual on the next file. -type WalkFunc func(path string, info *os.FileInfo, err os.Error) os.Error +type WalkFunc func(path string, info *os.FileInfo, err error) error // walk recursively descends path, calling w. -func walk(path string, info *os.FileInfo, walkFn WalkFunc) os.Error { +func walk(path string, info *os.FileInfo, walkFn WalkFunc) error { err := walkFn(path, info, nil) if err != nil { if info.IsDirectory() && err == SkipDir { @@ -374,7 +375,7 @@ func walk(path string, info *os.FileInfo, walkFn WalkFunc) os.Error { // and directories are filtered by walkFn. The files are walked in lexical // order, which makes the output deterministic but means that for very // large directories Walk can be inefficient. -func Walk(root string, walkFn WalkFunc) os.Error { +func Walk(root string, walkFn WalkFunc) error { info, err := os.Lstat(root) if err != nil { return walkFn(root, nil, err) @@ -385,7 +386,7 @@ func Walk(root string, walkFn WalkFunc) os.Error { // readDir reads the directory named by dirname and returns // a sorted list of directory entries. // Copied from io/ioutil to avoid the circular import. -func readDir(dirname string) ([]*os.FileInfo, os.Error) { +func readDir(dirname string) ([]*os.FileInfo, error) { f, err := os.Open(dirname) if err != nil { return nil, err diff --git a/libgo/go/path/filepath/path_test.go b/libgo/go/path/filepath/path_test.go index f8e055b..c81cbf0 100644 --- a/libgo/go/path/filepath/path_test.go +++ b/libgo/go/path/filepath/path_test.go @@ -317,7 +317,7 @@ func checkMarks(t *testing.T, report bool) { // Assumes that each node name is unique. Good enough for a test. // If clear is true, any incoming error is cleared before return. The errors // are always accumulated, though. -func mark(path string, info *os.FileInfo, err os.Error, errors *[]os.Error, clear bool) os.Error { +func mark(path string, info *os.FileInfo, err error, errors *[]error, clear bool) error { if err != nil { *errors = append(*errors, err) if clear { @@ -335,9 +335,9 @@ func mark(path string, info *os.FileInfo, err os.Error, errors *[]os.Error, clea func TestWalk(t *testing.T) { makeTree(t) - errors := make([]os.Error, 0, 10) + errors := make([]error, 0, 10) clear := true - markFn := func(path string, info *os.FileInfo, err os.Error) os.Error { + markFn := func(path string, info *os.FileInfo, err error) error { return mark(path, info, err, &errors, clear) } // Expect no errors. @@ -522,7 +522,7 @@ func testEvalSymlinks(t *testing.T, tests []EvalSymlinksTest) { func TestEvalSymlinks(t *testing.T) { defer os.RemoveAll("test") for _, d := range EvalSymlinksTestDirs { - var err os.Error + var err error if d.dest == "" { err = os.Mkdir(d.path, 0755) } else { @@ -585,7 +585,7 @@ var abstests = []string{ func TestAbs(t *testing.T) { oldwd, err := os.Getwd() if err != nil { - t.Fatal("Getwd failed: " + err.String()) + t.Fatal("Getwd failed: " + err.Error()) } defer os.Chdir(oldwd) goroot := os.Getenv("GOROOT") diff --git a/libgo/go/path/match.go b/libgo/go/path/match.go index e9d0327..bc685f4 100644 --- a/libgo/go/path/match.go +++ b/libgo/go/path/match.go @@ -5,12 +5,12 @@ package path import ( - "os" + "errors" "strings" "utf8" ) -var ErrBadPattern = os.NewError("syntax error in pattern") +var ErrBadPattern = errors.New("syntax error in pattern") // Match returns true if name matches the shell file name pattern. // The pattern syntax is: @@ -33,7 +33,7 @@ var ErrBadPattern = os.NewError("syntax error in pattern") // Match requires pattern to match all of name, not just a substring. // The only possible error return is when pattern is malformed. // -func Match(pattern, name string) (matched bool, err os.Error) { +func Match(pattern, name string) (matched bool, err error) { Pattern: for len(pattern) > 0 { var star bool @@ -111,7 +111,7 @@ Scan: // matchChunk checks whether chunk matches the beginning of s. // If so, it returns the remainder of s (after the match). // Chunk is all single-character operators: literals, char classes, and ?. -func matchChunk(chunk, s string) (rest string, ok bool, err os.Error) { +func matchChunk(chunk, s string) (rest string, ok bool, err error) { for len(chunk) > 0 { if len(s) == 0 { return @@ -183,7 +183,7 @@ func matchChunk(chunk, s string) (rest string, ok bool, err os.Error) { } // getEsc gets a possibly-escaped character from chunk, for a character class. -func getEsc(chunk string) (r rune, nchunk string, err os.Error) { +func getEsc(chunk string) (r rune, nchunk string, err error) { if len(chunk) == 0 || chunk[0] == '-' || chunk[0] == ']' { err = ErrBadPattern return diff --git a/libgo/go/path/match_test.go b/libgo/go/path/match_test.go index f377f10..730b6b9 100644 --- a/libgo/go/path/match_test.go +++ b/libgo/go/path/match_test.go @@ -4,15 +4,12 @@ package path -import ( - "os" - "testing" -) +import "testing" type MatchTest struct { pattern, s string match bool - err os.Error + err error } var matchTests = []MatchTest{ |