diff options
Diffstat (limited to 'libgo/go/patch/textdiff.go')
-rw-r--r-- | libgo/go/patch/textdiff.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libgo/go/patch/textdiff.go b/libgo/go/patch/textdiff.go index c7e693fc669..482bd678163 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") |