| 426 | A message is printed at most once per input file. */ |
| 427 | |
| 428 | static void |
| 429 | check_order (const struct line *prev, |
| 430 | const struct line *current, |
| 431 | int whatfile) |
| 432 | { |
| 433 | if (check_input_order != CHECK_ORDER_DISABLED |
| 434 | && ((check_input_order == CHECK_ORDER_ENABLED) || seen_unpairable)) |
| 435 | { |
| 436 | if (!issued_disorder_warning[whatfile - 1]) |
| 437 | { |
| 438 | idx_t join_field = whatfile == 1 ? join_field_1 : join_field_2; |
| 439 | if (keycmp (prev, current, join_field, join_field) > 0) |
| 440 | { |
| 441 | /* Exclude any trailing newline. */ |
| 442 | idx_t len = current->buf.length; |
| 443 | if (0 < len && current->buf.buffer[len - 1] == '\n') |
| 444 | --len; |
| 445 | |
| 446 | /* If the offending line is longer than INT_MAX, output |
| 447 | only the first INT_MAX bytes in this diagnostic. */ |
| 448 | len = MIN (INT_MAX, len); |
| 449 | |
| 450 | error ((check_input_order == CHECK_ORDER_ENABLED |
| 451 | ? EXIT_FAILURE : 0), |
| 452 | 0, _("%s:%ju: is not sorted: %.*s"), |
| 453 | g_names[whatfile - 1], line_no[whatfile - 1], |
| 454 | (int) len, current->buf.buffer); |
| 455 | |
| 456 | /* If we get to here, the message was merely a warning. |
| 457 | Arrange to issue it only once per file. */ |
| 458 | issued_disorder_warning[whatfile - 1] = true; |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | static inline void |
| 465 | reset_line (struct line *line) |