Thanks for the xstdopen module; it simplifies diffutils and I installed the attached patches there for it.
>From 86ece0ee216910bce0dbceb60b98190bf8f93702 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 6 Jan 2019 17:15:06 -0800
Subject: [PATCH 1/2] build: update gnulib submodule to latest

---
 gnulib | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnulib b/gnulib
index 10652b5..8089c00 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 10652b56fe5b76370187a06296168cff9cffb730
+Subproject commit 8089c00979a5b089cff592c6b91420e595657167
-- 
2.17.1

>From db6d5f7240c8a743aebb3def80b3e3fabf05f0c1 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 6 Jan 2019 17:22:37 -0800
Subject: [PATCH 2/2] diff: use xstdopen, not stdopen

* bootstrap.conf (gnulib_modules):
* src/cmp.c, src/diff.c, src/diff3.c, src/sdiff.c (main):
Use xstdopen, not stdopen.
---
 bootstrap.conf | 2 +-
 src/cmp.c      | 6 ++----
 src/diff.c     | 6 ++----
 src/diff3.c    | 6 ++----
 src/sdiff.c    | 6 ++----
 5 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index 0c9fbfe..4671349 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -67,7 +67,6 @@ stat
 stat-macros
 stat-time
 stdint
-stdopen
 strcase
 strftime
 strptime
@@ -85,6 +84,7 @@ wcwidth
 xalloc
 xfreopen
 xreadlink
+xstdopen
 xstrtoumax
 xvasprintf
 '
diff --git a/src/cmp.c b/src/cmp.c
index 811d039..ce2bdb5 100644
--- a/src/cmp.c
+++ b/src/cmp.c
@@ -31,11 +31,11 @@
 #include <hard-locale.h>
 #include <inttostr.h>
 #include <progname.h>
-#include <stdopen.h>
 #include <unlocked-io.h>
 #include <version-etc.h>
 #include <xalloc.h>
 #include <binary-io.h>
+#include <xstdopen.h>
 #include <xstrtol.h>
 
 /* The official name of this program (e.g., no 'g' prefix).  */
@@ -210,9 +210,7 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
   c_stack_action (0);
-  int stdopen_errno = stdopen ();
-  if (stdopen_errno != 0)
-    error (EXIT_TROUBLE, stdopen_errno, _("standard file descriptors"));
+  xstdopen ();
 
   /* Parse command line options.  */
 
diff --git a/src/diff.c b/src/diff.c
index 541d912..e9c2b11 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -37,11 +37,11 @@
 #include <progname.h>
 #include <sh-quote.h>
 #include <stat-time.h>
-#include <stdopen.h>
 #include <timespec.h>
 #include <version-etc.h>
 #include <xalloc.h>
 #include <xreadlink.h>
+#include <xstdopen.h>
 #include <binary-io.h>
 
 /* The official name of this program (e.g., no 'g' prefix).  */
@@ -298,9 +298,7 @@ main (int argc, char **argv)
   re_set_syntax (RE_SYNTAX_GREP | RE_NO_POSIX_BACKTRACKING);
   excluded = new_exclude ();
   presume_output_tty = false;
-  int stdopen_errno = stdopen ();
-  if (stdopen_errno != 0)
-    error (EXIT_TROUBLE, stdopen_errno, _("standard file descriptors"));
+  xstdopen ();
 
   /* Decode the options.  */
 
diff --git a/src/diff3.c b/src/diff3.c
index 8ce1a3d..037df25 100644
--- a/src/diff3.c
+++ b/src/diff3.c
@@ -30,11 +30,11 @@
 #include <file-type.h>
 #include <getopt.h>
 #include <progname.h>
-#include <stdopen.h>
 #include <system-quote.h>
 #include <version-etc.h>
 #include <xalloc.h>
 #include <xfreopen.h>
+#include <xstdopen.h>
 
 /* The official name of this program (e.g., no 'g' prefix).  */
 #define PROGRAM_NAME "diff3"
@@ -273,9 +273,7 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
   c_stack_action (0);
-  int stdopen_errno = stdopen ();
-  if (stdopen_errno != 0)
-    error (EXIT_TROUBLE, stdopen_errno, _("standard file descriptors"));
+  xstdopen ();
 
   while ((c = getopt_long (argc, argv, "aeimvx3AEL:TX", longopts, 0)) != -1)
     {
diff --git a/src/sdiff.c b/src/sdiff.c
index 605fd33..2ef83da 100644
--- a/src/sdiff.c
+++ b/src/sdiff.c
@@ -32,10 +32,10 @@
 #include <file-type.h>
 #include <getopt.h>
 #include <progname.h>
-#include <stdopen.h>
 #include <system-quote.h>
 #include <version-etc.h>
 #include <xalloc.h>
+#include <xstdopen.h>
 
 /* The official name of this program (e.g., no 'g' prefix).  */
 #define PROGRAM_NAME "sdiff"
@@ -456,9 +456,7 @@ main (int argc, char *argv[])
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
   c_stack_action (cleanup);
-  int stdopen_errno = stdopen ();
-  if (stdopen_errno != 0)
-    error (EXIT_TROUBLE, stdopen_errno, _("standard file descriptors"));
+  xstdopen ();
 
   prog = getenv ("EDITOR");
   if (prog)
-- 
2.17.1

Reply via email to