aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/patch/textdiff.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-06-17 06:07:13 -0400
committerRuss Cox <rsc@golang.org>2011-06-17 06:07:13 -0400
commit21e75da486ecdc9731d4c40253ac4246b03f5d72 (patch)
tree566597a3b9264430077c7766ff895b036e695047 /src/pkg/patch/textdiff.go
parent8155ff545201f478626a89011f2f8eb2e32923a2 (diff)
downloadgo-21e75da486ecdc9731d4c40253ac4246b03f5d72.tar.xz
respect goto restrictions
R=gri CC=golang-dev https://golang.org/cl/4625044
Diffstat (limited to 'src/pkg/patch/textdiff.go')
-rw-r--r--src/pkg/patch/textdiff.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/pkg/patch/textdiff.go b/src/pkg/patch/textdiff.go
index c7e693fc66..482bd67816 100644
--- a/src/pkg/patch/textdiff.go
+++ b/src/pkg/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")