"@@ -a[,b] +c[,d] @@": the old and new line ranges. */
| 100 | |
| 101 | /* "@@ -a[,b] +c[,d] @@": the old and new line ranges. */ |
| 102 | static bool df_hunk_header(const df_line_t *line, int *old_count, int *new_start, int *new_count) { |
| 103 | static const char open[] = "@@ "; |
| 104 | const char *p = line->text + (sizeof(open) - 1); |
| 105 | const char *end = line->text + line->len; |
| 106 | int old_start = 0; |
| 107 | if (!df_starts(line, open) || !df_range(&p, end, '-', &old_start, old_count)) { |
| 108 | return false; |
| 109 | } |
| 110 | if (p >= end || *p != ' ') { |
| 111 | return false; |
| 112 | } |
| 113 | p++; |
| 114 | if (!df_range(&p, end, '+', new_start, new_count)) { |
| 115 | return false; |
| 116 | } |
| 117 | return (size_t)(end - p) >= 3 && memcmp(p, " @@", 3) == 0; |
| 118 | } |
| 119 | |
| 120 | /* The path of "diff --git a/P b/P". Without renames both sides name the same |
| 121 | * file, so the line is the path twice; that also reads a path with " b/" in |