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

Function write_to_file

src/csplit.c:618–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

616 ARGNUM is the index in ARGV of the current pattern. */
617
618static void
619write_to_file (intmax_t last_line, bool ignore, int argnum)
620{
621 struct cstring *line;
622 intmax_t first_line; /* First available input line. */
623 intmax_t lines; /* Number of lines to output. */
624
625 first_line = get_first_line_in_buffer ();
626
627 if (! first_line || first_line > last_line)
628 {
629 error (0, 0, _("%s: line number out of range"),
630 quote (global_argv[argnum]));
631 cleanup_fatal ();
632 }
633
634 lines = last_line - first_line;
635
636 for (intmax_t i = 0; i < lines; i++)
637 {
638 line = remove_line ();
639 if (line == NULL)
640 {
641 error (0, 0, _("%s: line number out of range"),
642 quote (global_argv[argnum]));
643 cleanup_fatal ();
644 }
645 if (!ignore)
646 save_line_to_file (line);
647 }
648}
649
650/* Output any lines left after all regexps have been processed. */
651

Callers 1

process_regexpFunction · 0.85

Calls 4

get_first_line_in_bufferFunction · 0.85
cleanup_fatalFunction · 0.85
remove_lineFunction · 0.85
save_line_to_fileFunction · 0.85

Tested by

no test coverage detected