On 15/12/2022 18:38, Carl Edquist wrote:
Aaak!  Sorry, please disregard the patchset in my previous email.  I
messed up a rebase I was doing.  I am attaching a corrected patchset now.

Really nice work on this.
Only very small syntax tweaks (attached) at this point.
I'm going to do testing with this and will add an appropriate test case.

thank you!
Pádraig
diff --git a/NEWS b/NEWS
index bd4f1d082..f33f9acdf 100644
--- a/NEWS
+++ b/NEWS
@@ -96,7 +96,8 @@ GNU coreutils NEWS                                    -*- outline -*-
   diagnosed, rather than being conflated with ENOTEMPTY.
 
   tee -p detects when all remaining outputs have become broken pipes, and
-  exits, rather than waiting for more input before producing a write failure.
+  exits, rather than waiting for more input to induce an exit when written.
+
 
 * Noteworthy changes in release 9.1 (2022-04-15) [stable]
 
diff --git a/src/iopoll.c b/src/iopoll.c
index 9424af6fa..808c39b53 100644
--- a/src/iopoll.c
+++ b/src/iopoll.c
@@ -23,17 +23,17 @@
      a readable event).  Also use poll(2) on systems we know work
      and/or are already using poll (linux).  */
 
-#define IOPOLL_USES_POLL \
-        defined _AIX || defined __sun || defined __APPLE__ || \
-        defined __linux__ || defined __ANDROID__
+#if defined _AIX || defined __sun || defined __APPLE__ || \
+    defined __linux__ || defined __ANDROID__
+# define IOPOLL_USES_POLL 1
+#endif
 
 #if IOPOLL_USES_POLL
-#include <poll.h>
+# include <poll.h>
 #else
-#include <sys/select.h>
+# include <sys/select.h>
 #endif
 
-#include "error.h"
 #include "system.h"
 #include "iopoll.h"
 #include "isapipe.h"
@@ -47,7 +47,7 @@
 #if IOPOLL_USES_POLL
 
 extern int
-iopoll(int fdin, int fdout)
+iopoll (int fdin, int fdout)
 {
   struct pollfd pfds[2] = {{fdin, POLLIN, 0}, {fdout, 0, 0}};
 
@@ -66,7 +66,7 @@ iopoll(int fdin, int fdout)
 #else  /* fall back to select()-based implementation */
 
 extern int
-iopoll(int fdin, int fdout)
+iopoll (int fdin, int fdout)
 {
   int nfds = (fdin > fdout ? fdin : fdout) + 1;
   fd_set rfds;
@@ -96,19 +96,20 @@ iopoll(int fdin, int fdout)
    which is the case for a regular file or block device.  */
 
 extern bool
-iopoll_input_ok(int fdin)
+iopoll_input_ok (int fdin)
 {
   struct stat st;
-  bool always_ready = fstat (fdin, &st) == 0 && (S_ISREG (st.st_mode) ||
-                                                 S_ISBLK (st.st_mode));
-  return !always_ready;
+  bool always_ready = fstat (fdin, &st) == 0
+                      && (S_ISREG (st.st_mode)
+                          || S_ISBLK (st.st_mode));
+  return ! always_ready;
 }
 
 /* Return true if fdout is suitable for iopoll().
    Namely, fdout refers to a pipe.  */
 
 extern bool
-iopoll_output_ok(int fdout)
+iopoll_output_ok (int fdout)
 {
   return isapipe (fdout) > 0;
 }
diff --git a/src/iopoll.h b/src/iopoll.h
index f57e3a33d..85935e960 100644
--- a/src/iopoll.h
+++ b/src/iopoll.h
@@ -1,6 +1,6 @@
 #define IOPOLL_BROKEN_OUTPUT -2
 #define IOPOLL_ERROR         -3
 
-int iopoll(int fdin, int fdout);
-bool iopoll_input_ok(int fdin);
-bool iopoll_output_ok(int fdout);
+int iopoll (int fdin, int fdout);
+bool iopoll_input_ok (int fdin);
+bool iopoll_output_ok (int fdout);
diff --git a/src/tee.c b/src/tee.c
index 6ba0dd655..c69ea9133 100644
--- a/src/tee.c
+++ b/src/tee.c
@@ -154,9 +154,9 @@ main (int argc, char **argv)
           else
             output_error = output_error_warn_nopipe;
 
-          /* Detect and close a broken pipe output when ignorning EPIPE */
-          if (output_error == output_error_warn_nopipe ||
-              output_error == output_error_exit_nopipe)
+          /* Detect and close a broken pipe output when ignoring EPIPE.  */
+          if (output_error == output_error_warn_nopipe
+              || output_error == output_error_exit_nopipe)
             pipe_check = true;
 
           break;
@@ -195,7 +195,7 @@ main (int argc, char **argv)
    or -1 if all are NULL.  */
 
 static int
-get_next_out(FILE **descriptors, int nfiles, int idx)
+get_next_out (FILE **descriptors, int nfiles, int idx)
 {
   for (idx++; idx <= nfiles; idx++)
     if (descriptors[idx])
@@ -207,11 +207,12 @@ get_next_out(FILE **descriptors, int nfiles, int idx)
    Return true if this indicates a reportable error.  */
 
 static bool
-fail_output(FILE **descriptors, char **files, int i)
+fail_output (FILE **descriptors, char **files, int i)
 {
   int w_errno = errno;
-  bool fail = errno != EPIPE || (output_error == output_error_exit
-                                || output_error == output_error_warn);
+  bool fail = errno != EPIPE
+              || output_error == output_error_exit
+              || output_error == output_error_warn;
   if (descriptors[i] == stdout)
     clearerr (stdout); /* Avoid redundant close_stdout diagnostic.  */
   if (fail)
              • ... Carl Edquist via GNU coreutils General Discussion
              • ... Carl Edquist
              • ... Carl Edquist
              • ... Arsen Arsenović
              • ... Carl Edquist via GNU coreutils General Discussion
              • ... Pádraig Brady
              • ... Carl Edquist via GNU coreutils General Discussion
              • ... Arsen Arsenović
              • ... Carl Edquist
              • ... Carl Edquist
              • ... Pádraig Brady
              • ... Arsen Arsenović
              • ... Arsen Arsenović
              • ... Pádraig Brady
              • ... Arsen Arsenović
              • ... Pádraig Brady
              • ... Rob Landley
              • ... Arsen Arsenović
              • ... Carl Edquist via GNU coreutils General Discussion
  • Re: [PATCH] tee: Add --p... Pádraig Brady

Reply via email to