Convert range to the "ed" format
(start, stop int)
| 771 | |
| 772 | // Convert range to the "ed" format |
| 773 | func formatRangeUnified(start, stop int) string { |
| 774 | // Per the diff spec at http://www.unix.org/single_unix_specification/ |
| 775 | beginning := start + 1 // lines start numbering with one |
| 776 | length := stop - start |
| 777 | if length == 1 { |
| 778 | return fmt.Sprintf("%d", beginning) |
| 779 | } |
| 780 | if length == 0 { |
| 781 | beginning -= 1 // empty ranges begin at line just before the range |
| 782 | } |
| 783 | return fmt.Sprintf("%d,%d", beginning, length) |
| 784 | } |
| 785 | |
| 786 | // LineDiffParams contains unified diff parameters |
| 787 | type LineDiffParams struct { |