diff: correctness

This commit is contained in:
mappu 2017-07-11 18:25:49 +12:00
parent 697c8faa67
commit f560430efe

View File

@ -46,6 +46,7 @@ type twoints struct {
}
func Diff(o, n []string) []Instruction {
if len(o) == 0 && len(n) == 0 {
return []Instruction{}
}
@ -91,9 +92,7 @@ func Diff(o, n []string) []Instruction {
}
ret := Diff(o[:omax], n[:nmax])
if maxl != nmax {
ret = append(ret, Instruction{OP_UNCHANGED, n[nmax : maxl-nmax]})
}
ret = append(ret, Instruction{OP_UNCHANGED, n[nmax : nmax+maxl]})
ret = append(ret, Diff(o[omax+maxl:], n[nmax+maxl:])...)
return ret