MCPcopy Create free account
hub / github.com/coreutils/coreutils / process_line_count

Function process_line_count

src/csplit.c:684–718  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

682 REPETITION is the repetition number. */
683
684static void
685process_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
720static void
721regexp_error (struct control *p, intmax_t repetition, bool ignore)

Callers 1

split_fileFunction · 0.85

Calls 7

create_output_fileFunction · 0.85
no_more_linesFunction · 0.85
handle_line_errorFunction · 0.85
get_first_line_in_bufferFunction · 0.85
remove_lineFunction · 0.85
save_line_to_fileFunction · 0.85
close_output_fileFunction · 0.85

Tested by

no test coverage detected