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/patch | |
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/patch')
-rw-r--r-- | libgo/go/patch/apply.go | 4 | ||||
-rw-r--r-- | libgo/go/patch/git.go | 16 | ||||
-rw-r--r-- | libgo/go/patch/patch.go | 9 | ||||
-rw-r--r-- | libgo/go/patch/textdiff.go | 8 |
4 files changed, 18 insertions, 19 deletions
diff --git a/libgo/go/patch/apply.go b/libgo/go/patch/apply.go index 0dd9080..7c4f4ad 100644 --- a/libgo/go/patch/apply.go +++ b/libgo/go/patch/apply.go @@ -23,7 +23,7 @@ type Op struct { // The function readFile should return the contents of the named file. // Typically this function will be io.ReadFile. // -func (set *Set) Apply(readFile func(string) ([]byte, os.Error)) ([]Op, os.Error) { +func (set *Set) Apply(readFile func(string) ([]byte, error)) ([]Op, error) { op := make([]Op, len(set.File)) for i, f := range set.File { @@ -36,7 +36,7 @@ func (set *Set) Apply(readFile func(string) ([]byte, os.Error)) ([]Op, os.Error) // Clients assume o.Data == nil means no data diff. // Start with a non-nil data. var old []byte = make([]byte, 0) // not nil - var err os.Error + var err error if f.Src != "" { old, err = readFile(f.Src) if err != nil { diff --git a/libgo/go/patch/git.go b/libgo/go/patch/git.go index 6516097..454eade 100644 --- a/libgo/go/patch/git.go +++ b/libgo/go/patch/git.go @@ -9,9 +9,9 @@ import ( "compress/zlib" "crypto/sha1" "encoding/git85" + "errors" "fmt" "io" - "os" ) func gitSHA1(data []byte) []byte { @@ -34,7 +34,7 @@ type GitBinaryLiteral struct { } // Apply implements the Diff interface's Apply method. -func (d *GitBinaryLiteral) Apply(old []byte) ([]byte, os.Error) { +func (d *GitBinaryLiteral) Apply(old []byte) ([]byte, error) { if sum := gitSHA1(old); !bytes.HasPrefix(sum, d.OldSHA1) { return nil, ErrPatchFailure } @@ -68,7 +68,7 @@ func getHex(s []byte) (data []byte, rest []byte) { } // ParseGitBinary parses raw as a Git binary patch. -func ParseGitBinary(raw []byte) (Diff, os.Error) { +func ParseGitBinary(raw []byte) (Diff, error) { var oldSHA1, newSHA1 []byte var sawBinary bool @@ -97,24 +97,24 @@ func ParseGitBinary(raw []byte) (Diff, os.Error) { } defer z.Close() if _, err = io.ReadFull(z, data); err != nil { - if err == os.EOF { + if err == io.EOF { err = io.ErrUnexpectedEOF } return nil, err } var buf [1]byte m, err := z.Read(buf[0:]) - if m != 0 || err != os.EOF { - return nil, os.NewError("Git binary literal longer than expected") + if m != 0 || err != io.EOF { + return nil, errors.New("Git binary literal longer than expected") } if sum := gitSHA1(data); !bytes.HasPrefix(sum, newSHA1) { - return nil, os.NewError("Git binary literal SHA1 mismatch") + return nil, errors.New("Git binary literal SHA1 mismatch") } return &GitBinaryLiteral{oldSHA1, data}, nil } if !sawBinary { - return nil, os.NewError("unexpected Git patch header: " + string(first)) + return nil, errors.New("unexpected Git patch header: " + string(first)) } } panic("unreachable") diff --git a/libgo/go/patch/patch.go b/libgo/go/patch/patch.go index fcc8307..1d804f3 100644 --- a/libgo/go/patch/patch.go +++ b/libgo/go/patch/patch.go @@ -9,7 +9,6 @@ package patch import ( "bytes" - "os" "path" "strings" ) @@ -47,7 +46,7 @@ type Diff interface { // Apply applies the changes listed in the diff // to the string s, returning the new version of the string. // Note that the string s need not be a text string. - Apply(old []byte) (new []byte, err os.Error) + Apply(old []byte) (new []byte, err error) } // NoDiff is a no-op Diff implementation: it passes the @@ -56,14 +55,14 @@ var NoDiff Diff = noDiffType(0) type noDiffType int -func (noDiffType) Apply(old []byte) ([]byte, os.Error) { +func (noDiffType) Apply(old []byte) ([]byte, error) { return old, nil } // A SyntaxError represents a syntax error encountered while parsing a patch. type SyntaxError string -func (e SyntaxError) String() string { return string(e) } +func (e SyntaxError) Error() string { return string(e) } var newline = []byte{'\n'} @@ -71,7 +70,7 @@ var newline = []byte{'\n'} // The patch text typically comprises a textual header and a sequence // of file patches, as would be generated by CVS, Subversion, // Mercurial, or Git. -func Parse(text []byte) (*Set, os.Error) { +func Parse(text []byte) (*Set, error) { // Split text into files. // CVS and Subversion begin new files with // Index: file name. diff --git a/libgo/go/patch/textdiff.go b/libgo/go/patch/textdiff.go index 482bd67..adb629a 100644 --- a/libgo/go/patch/textdiff.go +++ b/libgo/go/patch/textdiff.go @@ -2,7 +2,7 @@ package patch import ( "bytes" - "os" + "errors" ) type TextDiff []TextChunk @@ -16,7 +16,7 @@ type TextChunk struct { New []byte } -func ParseTextDiff(raw []byte) (TextDiff, os.Error) { +func ParseTextDiff(raw []byte) (TextDiff, error) { var chunkHeader []byte // Copy raw so it is safe to keep references to slices. @@ -151,11 +151,11 @@ ErrChunkHdr: return nil, SyntaxError("unexpected chunk header line: " + string(chunkHeader)) } -var ErrPatchFailure = os.NewError("patch did not apply cleanly") +var ErrPatchFailure = errors.New("patch did not apply cleanly") // Apply applies the changes listed in the diff // to the data, returning the new version. -func (d TextDiff) Apply(data []byte) ([]byte, os.Error) { +func (d TextDiff) Apply(data []byte) ([]byte, error) { var buf bytes.Buffer line := 1 for _, c := range d { |