| 682 | REPETITION is the repetition number. */ |
| 683 | |
| 684 | static void |
| 685 | process_line_count (const struct control *p, intmax_t repetition) |
| 686 | { |
| 687 | intmax_t linenum; |
| 688 | intmax_t last_line_to_save = p->lines_required * (repetition + 1); |
| 689 | |
| 690 | create_output_file (); |
| 691 | |
| 692 | /* Ensure that the line number specified is not 1 greater than |
| 693 | the number of lines in the file. |
| 694 | When suppressing matched lines, check before the loop. */ |
| 695 | if (no_more_lines () && suppress_matched) |
| 696 | handle_line_error (p, repetition); |
| 697 | |
| 698 | if (!(linenum = get_first_line_in_buffer ())) |
| 699 | handle_line_error (p, repetition); |
| 700 | |
| 701 | while (linenum++ < last_line_to_save) |
| 702 | { |
| 703 | struct cstring *line = remove_line (); |
| 704 | if (line == NULL) |
| 705 | handle_line_error (p, repetition); |
| 706 | save_line_to_file (line); |
| 707 | } |
| 708 | |
| 709 | close_output_file (); |
| 710 | |
| 711 | if (suppress_matched) |
| 712 | remove_line (); |
| 713 | |
| 714 | /* Ensure that the line number specified is not 1 greater than |
| 715 | the number of lines in the file. */ |
| 716 | if (no_more_lines () && !suppress_matched) |
| 717 | handle_line_error (p, repetition); |
| 718 | } |
| 719 | |
| 720 | static void |
| 721 | regexp_error (struct control *p, intmax_t repetition, bool ignore) |
no test coverage detected