Convert range to the "ed" format
(start, stop int)
| 850 | |
| 851 | // Convert range to the "ed" format |
| 852 | func formatRangeUnified(start, stop int) []byte { |
| 853 | // Per the diff spec at http://www.unix.org/single_unix_specification/ |
| 854 | beginning := start + 1 // lines start numbering with one |
| 855 | length := stop - start |
| 856 | if length == 1 { |
| 857 | return []byte(fmt.Sprintf("%d", beginning)) |
| 858 | } |
| 859 | if length == 0 { |
| 860 | beginning -= 1 // empty ranges begin at line just before the range |
| 861 | } |
| 862 | return []byte(fmt.Sprintf("%d,%d", beginning, length)) |
| 863 | } |
| 864 | |
| 865 | // UnifiedDiff contains unified diff parameters |
| 866 | type UnifiedDiff struct { |