parseHunkHeader extracts line numbers from @@ -old,count +new,count @@
(line string, oldNum, newNum *int)
| 123 | |
| 124 | // parseHunkHeader extracts line numbers from @@ -old,count +new,count @@ |
| 125 | func parseHunkHeader(line string, oldNum, newNum *int) { |
| 126 | parts := strings.SplitN(line, "@@", 3) |
| 127 | if len(parts) < 2 { |
| 128 | return |
| 129 | } |
| 130 | ranges := strings.TrimSpace(parts[1]) |
| 131 | for _, r := range strings.Fields(ranges) { |
| 132 | if strings.HasPrefix(r, "-") { |
| 133 | nums := strings.SplitN(r[1:], ",", 2) |
| 134 | if n, err := strconv.Atoi(nums[0]); err == nil { |
| 135 | *oldNum = n |
| 136 | } |
| 137 | } else if strings.HasPrefix(r, "+") { |
| 138 | nums := strings.SplitN(r[1:], ",", 2) |
| 139 | if n, err := strconv.Atoi(nums[0]); err == nil { |
| 140 | *newNum = n |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | const lineNumWidth = 4 |
| 147 |
no outgoing calls