~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/patch/textdiff.go

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-08-03 17:04:59 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110803170459-wzd99m3567y80ila
Tags: 1:59-1
* Imported Upstream version 59
* Refresh patches to a new release
* Fix FTBFS on ARM (Closes: #634270)
* Update version.bash to work with Debian packaging and not hg
  repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
}
18
18
 
19
19
func ParseTextDiff(raw []byte) (TextDiff, os.Error) {
 
20
        var chunkHeader []byte
 
21
 
20
22
        // Copy raw so it is safe to keep references to slices.
21
23
        _, chunks := sections(raw, "@@ -")
22
24
        delta := 0
26
28
 
27
29
                // Parse start line: @@ -oldLine,oldCount +newLine,newCount @@ junk
28
30
                chunk := splitLines(raw)
29
 
                chunkHeader := chunk[0]
 
31
                chunkHeader = chunk[0]
30
32
                var ok bool
31
33
                var oldLine, oldCount, newLine, newCount int
32
34
                s := chunkHeader
33
35
                if oldLine, s, ok = atoi(s, "@@ -", 10); !ok {
34
 
                ErrChunkHdr:
35
 
                        return nil, SyntaxError("unexpected chunk header line: " + string(chunkHeader))
 
36
                        goto ErrChunkHdr
36
37
                }
37
38
                if len(s) == 0 || s[0] != ',' {
38
39
                        oldCount = 1
145
146
                }
146
147
        }
147
148
        return diff, nil
 
149
 
 
150
ErrChunkHdr:
 
151
        return nil, SyntaxError("unexpected chunk header line: " + string(chunkHeader))
148
152
}
149
153
 
150
154
var ErrPatchFailure = os.NewError("patch did not apply cleanly")