* Compare a snapshot record at `rec` to the specified NUL-terminated * refname. */
| 338 | * refname. |
| 339 | */ |
| 340 | static int cmp_record_to_refname(const char *rec, const char *refname, |
| 341 | int start, const struct snapshot *snapshot) |
| 342 | { |
| 343 | const char *r1 = rec + snapshot_hexsz(snapshot) + 1; |
| 344 | const char *r2 = refname; |
| 345 | |
| 346 | while (1) { |
| 347 | if (*r1 == '\n') |
| 348 | return *r2 ? -1 : 0; |
| 349 | if (!*r2) |
| 350 | return start ? 1 : -1; |
| 351 | if (*r1 != *r2) |
| 352 | return (unsigned char)*r1 < (unsigned char)*r2 ? -1 : +1; |
| 353 | r1++; |
| 354 | r2++; |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | /* |
| 359 | * `snapshot->buf` is not known to be sorted. Check whether it is, and |
no test coverage detected