| 192 | } |
| 193 | |
| 194 | static bool changes_side_path(changes_slice_t line, const cbm_change_file_t *file, bool old) { |
| 195 | const unsigned char *bytes = line.bytes + 4; /* checked ---/+++ prefix */ |
| 196 | size_t length = line.length - 4; |
| 197 | bool absent = old ? file->status == 'A' : file->status == 'D'; |
| 198 | if (absent) { |
| 199 | return length == 9 && memcmp(bytes, "/dev/null", 9) == 0; |
| 200 | } |
| 201 | if (length < 2 || bytes[0] != (old ? 'a' : 'b') || bytes[1] != '/') { |
| 202 | return false; |
| 203 | } |
| 204 | bytes += 2; |
| 205 | length -= 2; |
| 206 | /* Accept an exact trailing TAB delimiter after the known path, never |
| 207 | * timestamps, path truncation or another spelling. */ |
| 208 | if (length > file->path_length && length - file->path_length == 1 && |
| 209 | bytes[length - 1] == '\t') { |
| 210 | length--; |
| 211 | } |
| 212 | return length == file->path_length && memcmp(bytes, file->path, length) == 0; |
| 213 | } |
| 214 | |
| 215 | /* The legacy reader discards the old start. Keep its old-side range from |
| 216 | * certifying an impossible nonempty range beginning at zero. */ |
no outgoing calls
no test coverage detected