Thanks for the review; I installed the attached to try to address the issues you raised.
>From 820fa6ad064bf3ba81dc9e2cd7fa2b98bb270902 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Thu, 16 Feb 2017 00:17:56 -0800
Subject: [PATCH] xbinary-io: rename from xsetmode

This patch is taken from suggestions by Bruno Haible in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-02/msg00060.html
http://lists.gnu.org/archive/html/bug-gnulib/2017-02/msg00061.html
* lib/binary-io.c (__gl_setmode_check): Set errno to EINVAL,
not ENOTTY, when it is an inappropriate device.
* lib/binary-io.h (SET_BINARY): Resurrect.
* lib/xbinary-io.c: Rename from lib/xsetmode.c.
(xset_binary_mode_error): Rename from xsetmode_error.
* lib/xbinary-io.h: Rename from lib/xsetmode.h.
(xset_binary_mode): Rename from xsetmode.
All uses changed.
* modules/xbinary-io: Rename from modules/xsetmode.
Update file names.
* tests/test-binary-io.sh (tmpfiles): Remove no-longer-used file name.
* NEWS: Update to match revised behavior.
---
 ChangeLog               | 19 +++++++++++++++++++
 NEWS                    |  5 ++---
 lib/binary-io.c         |  2 +-
 lib/binary-io.h         | 12 +++++++++---
 lib/xbinary-io.c        | 38 ++++++++++++++++++++++++++++++++++++++
 lib/xbinary-io.h        | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/xsetmode.c          | 38 --------------------------------------
 lib/xsetmode.h          | 45 ---------------------------------------------
 modules/xbinary-io      | 28 ++++++++++++++++++++++++++++
 modules/xsetmode        | 28 ----------------------------
 tests/test-binary-io.sh |  2 +-
 11 files changed, 146 insertions(+), 119 deletions(-)
 create mode 100644 lib/xbinary-io.c
 create mode 100644 lib/xbinary-io.h
 delete mode 100644 lib/xsetmode.c
 delete mode 100644 lib/xsetmode.h
 create mode 100644 modules/xbinary-io
 delete mode 100644 modules/xsetmode

diff --git a/ChangeLog b/ChangeLog
index f7bccee..ec7c004 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2017-02-16  Paul Eggert  <egg...@cs.ucla.edu>
+
+	xbinary-io: rename from xsetmode
+	This patch is taken from suggestions by Bruno Haible in:
+	http://lists.gnu.org/archive/html/bug-gnulib/2017-02/msg00060.html
+	http://lists.gnu.org/archive/html/bug-gnulib/2017-02/msg00061.html
+	* lib/binary-io.c (__gl_setmode_check): Set errno to EINVAL,
+	not ENOTTY, when it is an inappropriate device.
+	* lib/binary-io.h (SET_BINARY): Resurrect.
+	* lib/xbinary-io.c: Rename from lib/xsetmode.c.
+	(xset_binary_mode_error): Rename from xsetmode_error.
+	* lib/xbinary-io.h: Rename from lib/xsetmode.h.
+	(xset_binary_mode): Rename from xsetmode.
+	All uses changed.
+	* modules/xbinary-io: Rename from modules/xsetmode.
+	Update file names.
+	* tests/test-binary-io.sh (tmpfiles): Remove no-longer-used file name.
+	* NEWS: Update to match revised behavior.
+
 2017-02-15  Paul Eggert  <egg...@cs.ucla.edu>
 
 	tests: Adjust to recent SET_BINARY change
diff --git a/NEWS b/NEWS
index 294aa22..bd40347 100644
--- a/NEWS
+++ b/NEWS
@@ -42,9 +42,8 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
-2017-02-15  binary-io       On MS-DOS and OS/2, set_binary_mode now fails
-                            on ttys, and sets errno == ENOTTY.  SET_BINARY
-                            has been removed; use set_binary_mode instead.
+2017-02-16  binary-io       On MS-DOS and OS/2, set_binary_mode now fails
+                            on ttys, and sets errno == EINVAL.
 
 2017-01-20  parse-datetime  The parse_datetime2 function now takes two
                             more arguments TZ and TZSTRING, for the
diff --git a/lib/binary-io.c b/lib/binary-io.c
index c721650..a7558b2 100644
--- a/lib/binary-io.c
+++ b/lib/binary-io.c
@@ -28,7 +28,7 @@ __gl_setmode_check (int fd)
 {
   if (isatty (fd))
     {
-      errno = ENOTTY;
+      errno = EINVAL;
       return -1;
     }
   else
diff --git a/lib/binary-io.h b/lib/binary-io.h
index ae7690d..9f1dde1 100644
--- a/lib/binary-io.h
+++ b/lib/binary-io.h
@@ -55,9 +55,6 @@ __gl_setmode (int fd, int mode)
 }
 #endif
 
-/* Set FD's mode to MODE.  Return the old mode if successful, -1
-   (setting errno) on failure.  */
-
 #if defined __DJGPP__ || defined __EMX__
 extern int __gl_setmode_check (int);
 #else
@@ -65,6 +62,12 @@ BINARY_IO_INLINE int
 __gl_setmode_check (int fd) { return 0; }
 #endif
 
+/* Set FD's mode to MODE, which should be either O_TEXT or O_BINARY.
+   Return the old mode if successful, -1 (setting errno) on failure.
+   Ordinarily this function would be called 'setmode', since that is
+   its name on MS-Windows, but it is called 'set_binary_mode' here
+   to avoid colliding with a BSD function of another name.  */
+
 BINARY_IO_INLINE int
 set_binary_mode (int fd, int mode)
 {
@@ -72,6 +75,9 @@ set_binary_mode (int fd, int mode)
   return r != 0 ? r : __gl_setmode (fd, mode);
 }
 
+/* This macro is obsolescent.  */
+#define SET_BINARY(fd) ((void) set_binary_mode (fd, O_BINARY))
+
 _GL_INLINE_HEADER_END
 
 #endif /* _BINARY_H */
diff --git a/lib/xbinary-io.c b/lib/xbinary-io.c
new file mode 100644
index 0000000..7fc8d0b
--- /dev/null
+++ b/lib/xbinary-io.c
@@ -0,0 +1,38 @@
+/* Binary mode I/O with checking
+   Copyright 2017 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#define XSETMODE_INLINE _GL_EXTERN_INLINE
+#include "xbinary-io.h"
+
+#include <errno.h>
+#include <error.h>
+#include <stdbool.h>
+#include "exitfail.h"
+#include "verify.h"
+
+#if O_BINARY
+
+_Noreturn void
+xset_binary_mode_error (void)
+{
+  error (exit_failure, errno,
+         _("failed to set file descriptor text/binary mode"));
+  assume (false);
+}
+
+#endif
diff --git a/lib/xbinary-io.h b/lib/xbinary-io.h
new file mode 100644
index 0000000..28b2028
--- /dev/null
+++ b/lib/xbinary-io.h
@@ -0,0 +1,48 @@
+/* Binary mode I/O with checking
+   Copyright 2017 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _XBINARY_IO_H
+#define _XBINARY_IO_H
+
+#include "binary-io.h"
+
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+#ifndef XBINARY_IO_INLINE
+# define XBINARY_IO_INLINE _GL_INLINE
+#endif
+
+#if O_BINARY
+extern _Noreturn void xset_binary_mode_error (void);
+#else
+XBINARY_IO_INLINE void xset_binary_mode_error (void) {}
+#endif
+
+/* Set the mode of FD to MODE, which should be either O_TEXT or O_BINARY.
+   Report an error and exit if this fails.  */
+
+XBINARY_IO_INLINE void
+xset_binary_mode (int fd, int mode)
+{
+  if (set_binary_mode (fd, mode) < 0)
+    xset_binary_mode_error ();
+}
+
+_GL_INLINE_HEADER_END
+
+#endif /* _XBINARY_IO_H */
diff --git a/lib/xsetmode.c b/lib/xsetmode.c
deleted file mode 100644
index 628f4f0..0000000
--- a/lib/xsetmode.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Binary mode I/O with checking
-   Copyright 2017 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-#define XSETMODE_INLINE _GL_EXTERN_INLINE
-#include "xsetmode.h"
-
-#include <errno.h>
-#include <error.h>
-#include <stdbool.h>
-#include "exitfail.h"
-#include "verify.h"
-
-#if O_BINARY
-
-_Noreturn void
-xsetmode_error (void)
-{
-  error (exit_failure, errno,
-         _("failed to set file descriptor text/binary mode"));
-  assume (false);
-}
-
-#endif
diff --git a/lib/xsetmode.h b/lib/xsetmode.h
deleted file mode 100644
index c88d915..0000000
--- a/lib/xsetmode.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Binary mode I/O with checking
-   Copyright 2017 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#ifndef _XSETMODE_H
-#define _XSETMODE_H
-
-#include "binary-io.h"
-
-#ifndef _GL_INLINE_HEADER_BEGIN
- #error "Please include config.h first."
-#endif
-_GL_INLINE_HEADER_BEGIN
-#ifndef XSETMODE_INLINE
-# define XSETMODE_INLINE _GL_INLINE
-#endif
-
-#if O_BINARY
-extern _Noreturn void xsetmode_error (void);
-#else
-XSETMODE_INLINE void xsetmode_error (void) {}
-#endif
-
-XSETMODE_INLINE void
-xsetmode (int fd, int mode)
-{
-  if (set_binary_mode (fd, mode) < 0)
-    xsetmode_error ();
-}
-
-_GL_INLINE_HEADER_END
-
-#endif /* _XSETMODE_H */
diff --git a/modules/xbinary-io b/modules/xbinary-io
new file mode 100644
index 0000000..5344805
--- /dev/null
+++ b/modules/xbinary-io
@@ -0,0 +1,28 @@
+Description:
+Checked Binary mode I/O.
+
+Files:
+lib/xbinary-io.h
+lib/xbinary-io.c
+
+Depends-on:
+binary-io
+error
+exitfail
+extern-inline
+stdbool
+verify
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += xbinary-io.h xbinary-io.c
+
+Include:
+"xbinary-io.h"
+
+License:
+LGPL
+
+Maintainer:
+all
diff --git a/modules/xsetmode b/modules/xsetmode
deleted file mode 100644
index 360a054..0000000
--- a/modules/xsetmode
+++ /dev/null
@@ -1,28 +0,0 @@
-Description:
-Checked Binary mode I/O.
-
-Files:
-lib/xsetmode.h
-lib/xsetmode.c
-
-Depends-on:
-binary-io
-error
-exitfail
-extern-inline
-stdbool
-verify
-
-configure.ac:
-
-Makefile.am:
-lib_SOURCES += xsetmode.h xsetmode.c
-
-Include:
-"xsetmode.h"
-
-License:
-LGPLv2+
-
-Maintainer:
-all
diff --git a/tests/test-binary-io.sh b/tests/test-binary-io.sh
index 3af53c6..38af099 100755
--- a/tests/test-binary-io.sh
+++ b/tests/test-binary-io.sh
@@ -3,7 +3,7 @@
 tmpfiles=""
 trap 'rm -fr $tmpfiles' 1 2 3 15
 
-tmpfiles="$tmpfiles t-bin-out0.tmp t-bin-out1.tmp t-bin-out2.tmp"
+tmpfiles="$tmpfiles t-bin-out0.tmp t-bin-out1.tmp"
 ./test-binary-io${EXEEXT} 1 > t-bin-out1.tmp || exit 1
 cmp t-bin-out0.tmp t-bin-out1.tmp > /dev/null || exit 1
 
-- 
2.7.4

Reply via email to