]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
xbinary-io: rename from xsetmode
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 16 Feb 2017 08:17:56 +0000 (00:17 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 16 Feb 2017 08:19:20 +0000 (00:19 -0800)
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
NEWS
lib/binary-io.c
lib/binary-io.h
lib/xbinary-io.c [moved from lib/xsetmode.c with 95% similarity]
lib/xbinary-io.h [moved from lib/xsetmode.h with 67% similarity]
modules/xbinary-io [moved from modules/xsetmode with 65% similarity]
tests/test-binary-io.sh

index f7bccee8ca0fe2855fd295f8d16644bdaf2f16c1..ec7c004857932c625c1167cb4bdad2b5e76e2b0d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2017-02-16  Paul Eggert  <eggert@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  <eggert@cs.ucla.edu>
 
        tests: Adjust to recent SET_BINARY change
diff --git a/NEWS b/NEWS
index 294aa224ceccacc8696f9c84ef389fc52451ce10..bd40347174c879a671f8e9f6881f8fe28185e5cc 100644 (file)
--- 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
index c721650cc54259eb46cc1b0bcdb9fc2c54bd5f14..a7558b20fd11a80a89be12bef632fbdce84db110 100644 (file)
@@ -28,7 +28,7 @@ __gl_setmode_check (int fd)
 {
   if (isatty (fd))
     {
-      errno = ENOTTY;
+      errno = EINVAL;
       return -1;
     }
   else
index ae7690de2861b5441247903dda0cc5a974954544..9f1dde108ebc5c706a2ad398431a3b150d95d50c 100644 (file)
@@ -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 */
similarity index 95%
rename from lib/xsetmode.c
rename to lib/xbinary-io.c
index 628f4f07e2bf9c7b047074821305183bf08578e7..7fc8d0b20704d2edf304705065c53446dce4ba7a 100644 (file)
@@ -17,7 +17,7 @@
 #include <config.h>
 
 #define XSETMODE_INLINE _GL_EXTERN_INLINE
-#include "xsetmode.h"
+#include "xbinary-io.h"
 
 #include <errno.h>
 #include <error.h>
@@ -28,7 +28,7 @@
 #if O_BINARY
 
 _Noreturn void
-xsetmode_error (void)
+xset_binary_mode_error (void)
 {
   error (exit_failure, errno,
          _("failed to set file descriptor text/binary mode"));
similarity index 67%
rename from lib/xsetmode.h
rename to lib/xbinary-io.h
index c88d915901a26b9e80f00ea5ecdd822389933ae9..28b20285c48fce11e653c086f1fb63db0279c294 100644 (file)
@@ -14,8 +14,8 @@
    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
+#ifndef _XBINARY_IO_H
+#define _XBINARY_IO_H
 
 #include "binary-io.h"
 
  #error "Please include config.h first."
 #endif
 _GL_INLINE_HEADER_BEGIN
-#ifndef XSETMODE_INLINE
-# define XSETMODE_INLINE _GL_INLINE
+#ifndef XBINARY_IO_INLINE
+# define XBINARY_IO_INLINE _GL_INLINE
 #endif
 
 #if O_BINARY
-extern _Noreturn void xsetmode_error (void);
+extern _Noreturn void xset_binary_mode_error (void);
 #else
-XSETMODE_INLINE void xsetmode_error (void) {}
+XBINARY_IO_INLINE void xset_binary_mode_error (void) {}
 #endif
 
-XSETMODE_INLINE void
-xsetmode (int fd, int mode)
+/* 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)
-    xsetmode_error ();
+    xset_binary_mode_error ();
 }
 
 _GL_INLINE_HEADER_END
 
-#endif /* _XSETMODE_H */
+#endif /* _XBINARY_IO_H */
similarity index 65%
rename from modules/xsetmode
rename to modules/xbinary-io
index 360a054718848659b7760891ecbb07782512dce7..5344805fc5d622a32b33183938c24e4f2ae35e1f 100644 (file)
@@ -2,8 +2,8 @@ Description:
 Checked Binary mode I/O.
 
 Files:
-lib/xsetmode.h
-lib/xsetmode.c
+lib/xbinary-io.h
+lib/xbinary-io.c
 
 Depends-on:
 binary-io
@@ -16,13 +16,13 @@ verify
 configure.ac:
 
 Makefile.am:
-lib_SOURCES += xsetmode.h xsetmode.c
+lib_SOURCES += xbinary-io.h xbinary-io.c
 
 Include:
-"xsetmode.h"
+"xbinary-io.h"
 
 License:
-LGPLv2+
+LGPL
 
 Maintainer:
 all
index 3af53c6b8be333f087ea3c61fa77378ece42c823..38af09957b6dc21387c49489550097405bdc3917 100755 (executable)
@@ -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