>From f5931619f9e22fdf874d1b7fb7f0160da8ca5d90 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Fri, 20 May 2011 01:10:58 +0100
Subject: [PATCH] maint: split: remove --filter specific code from other paths
(lines_chunk_split): Don't use ignore_error() which
is redundant and confusing when not running with --filter.
(lines_rr): Likewise.
(ofile_open): Likewise. Add a comment to clarify that
filters aren't restarted under file descriptor pressure.
---
src/split.c | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/split.c b/src/split.c
index 05315e6..80e3386 100644
--- a/src/split.c
+++ b/src/split.c
@@ -641,8 +641,7 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
/* We don't use the stdout buffer here since we're writing
large chunks from an existing file, so it's more efficient
to write out directly. */
- if (full_write (STDOUT_FILENO, bp, to_write) != to_write
- && ! ignorable (errno))
+ if (full_write (STDOUT_FILENO, bp, to_write) != to_write)
error (EXIT_FAILURE, errno, "%s", _("write error"));
}
else
@@ -758,7 +757,12 @@ ofile_open (of_t *files, size_t i_check, size_t nfiles)
In specialised cases the consumer can keep reading
from the fifo, terminating on conditions in the data
itself, or perhaps never in the case of `tail -f`.
- I.E. for fifos it is valid to attempt this reopen. */
+ I.E. for fifos it is valid to attempt this reopen.
+
+ We don't handle the filter_command case here, as create()
+ will exit if there are not enough files in that case.
+ I.E. we don't support restarting filters, as that would
+ put too much burden on users specifying --filter commands. */
fd = open (files[i_check].of_name,
O_WRONLY | O_BINARY | O_APPEND | O_NONBLOCK);
}
@@ -780,7 +784,7 @@ ofile_open (of_t *files, size_t i_check, size_t nfiles)
error (EXIT_FAILURE, errno, "%s", files[i_check].of_name);
}
- if (fclose (files[i_reopen].ofile) != 0 && ! ignorable (errno))
+ if (fclose (files[i_reopen].ofile) != 0)
error (EXIT_FAILURE, errno, "%s", files[i_reopen].of_name);
files[i_reopen].ofile = NULL;
files[i_reopen].ofd = OFD_APPEND;
@@ -863,12 +867,10 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
{
if (line_no == k && unbuffered)
{
- if (full_write (STDOUT_FILENO, bp, to_write) != to_write
- && ! ignorable (errno))
+ if (full_write (STDOUT_FILENO, bp, to_write) != to_write)
error (EXIT_FAILURE, errno, "%s", _("write error"));
}
- else if (line_no == k && fwrite (bp, to_write, 1, stdout) != 1
- && ! ignorable (errno))
+ else if (line_no == k && fwrite (bp, to_write, 1, stdout) != 1)
{
clearerr (stdout); /* To silence close_stdout(). */
error (EXIT_FAILURE, errno, "%s", _("write error"));
@@ -893,7 +895,7 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
if (file_limit)
{
- if (fclose (files[i_file].ofile) != 0 && ! ignorable (errno))
+ if (fclose (files[i_file].ofile) != 0)
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
files[i_file].ofile = NULL;
files[i_file].ofd = OFD_APPEND;
--
1.7.4