diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-09-16 15:47:21 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-09-16 15:47:21 +0000 |
commit | adb0401dac41c81571722312d4586b2693f95aa6 (patch) | |
tree | ea2b52e3c258d6b6d9356977c683c7f72a4a5fd5 /libgo/go/patch | |
parent | 5548ca3540bccbc908a45942896d635ea5f1c23f (diff) | |
download | gcc-adb0401dac41c81571722312d4586b2693f95aa6.zip gcc-adb0401dac41c81571722312d4586b2693f95aa6.tar.gz gcc-adb0401dac41c81571722312d4586b2693f95aa6.tar.bz2 |
Update Go library to r60.
From-SVN: r178910
Diffstat (limited to 'libgo/go/patch')
-rw-r--r-- | libgo/go/patch/patch.go | 2 | ||||
-rw-r--r-- | libgo/go/patch/textdiff.go | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/libgo/go/patch/patch.go b/libgo/go/patch/patch.go index d4977dc..fcc8307 100644 --- a/libgo/go/patch/patch.go +++ b/libgo/go/patch/patch.go @@ -319,4 +319,4 @@ func hasPrefix(s []byte, t string) bool { // splitLines returns the result of splitting s into lines. // The \n on each line is preserved. -func splitLines(s []byte) [][]byte { return bytes.SplitAfter(s, newline, -1) } +func splitLines(s []byte) [][]byte { return bytes.SplitAfter(s, newline) } diff --git a/libgo/go/patch/textdiff.go b/libgo/go/patch/textdiff.go index c7e693f..482bd67 100644 --- a/libgo/go/patch/textdiff.go +++ b/libgo/go/patch/textdiff.go @@ -17,6 +17,8 @@ type TextChunk struct { } func ParseTextDiff(raw []byte) (TextDiff, os.Error) { + var chunkHeader []byte + // Copy raw so it is safe to keep references to slices. _, chunks := sections(raw, "@@ -") delta := 0 @@ -26,13 +28,12 @@ func ParseTextDiff(raw []byte) (TextDiff, os.Error) { // Parse start line: @@ -oldLine,oldCount +newLine,newCount @@ junk chunk := splitLines(raw) - chunkHeader := chunk[0] + chunkHeader = chunk[0] var ok bool var oldLine, oldCount, newLine, newCount int s := chunkHeader if oldLine, s, ok = atoi(s, "@@ -", 10); !ok { - ErrChunkHdr: - return nil, SyntaxError("unexpected chunk header line: " + string(chunkHeader)) + goto ErrChunkHdr } if len(s) == 0 || s[0] != ',' { oldCount = 1 @@ -145,6 +146,9 @@ func ParseTextDiff(raw []byte) (TextDiff, os.Error) { } } return diff, nil + +ErrChunkHdr: + return nil, SyntaxError("unexpected chunk header line: " + string(chunkHeader)) } var ErrPatchFailure = os.NewError("patch did not apply cleanly") |