[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an
From: |
KO Myung-Hun |
Subject: |
[PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2 |
Date: |
Fri, 24 May 2019 20:31:38 +0900 |
Setting stdin/out/err to binary mode is allowed on OS/2. But it's not
useful, because it generates stair-output hard to read.
Instead, let's set them to text mode all the time.
This fixes that tee always crashes at startup if stdin or stdout
are not piped.
* lib/binary-io.c (__gl_setmode_check) [__EMX__]: Remove __EMX__ guard.
* lib/binary-io.h (__gl_setmode_check) [__EMX__]: Remove __EMX__ guard.
(set_binary_mode) [__EMX__]: Override mode with O_TEXT if tty.
---
lib/binary-io.c | 2 +-
lib/binary-io.h | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/binary-io.c b/lib/binary-io.c
index 01e0bf647..03b98681b 100644
--- a/lib/binary-io.c
+++ b/lib/binary-io.c
@@ -19,7 +19,7 @@
#define BINARY_IO_INLINE _GL_EXTERN_INLINE
#include "binary-io.h"
-#if defined __DJGPP__ || defined __EMX__
+#if defined __DJGPP__
# include <errno.h>
# include <unistd.h>
diff --git a/lib/binary-io.h b/lib/binary-io.h
index 720b08c75..75881bd1c 100644
--- a/lib/binary-io.h
+++ b/lib/binary-io.h
@@ -53,7 +53,7 @@ __gl_setmode (int fd _GL_UNUSED, int mode _GL_UNUSED)
}
#endif
-#if defined __DJGPP__ || defined __EMX__
+#if defined __DJGPP__
extern int __gl_setmode_check (int);
#else
BINARY_IO_INLINE int
@@ -70,6 +70,12 @@ BINARY_IO_INLINE int
set_binary_mode (int fd, int mode)
{
int r = __gl_setmode_check (fd);
+#if defined __EMX__
+ /* On OS/2, setting stdin/out/err to binary is not an error, but
+ non-sense. */
+ if (isatty (fd))
+ mode = O_TEXT;
+#endif
return r != 0 ? r : __gl_setmode (fd, mode);
}
--
2.13.3
- [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2,
KO Myung-Hun <=
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, Paul Eggert, 2019/05/24
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, Bruno Haible, 2019/05/25
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, KO Myung-Hun, 2019/05/25
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, Bruno Haible, 2019/05/25
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, Paul Eggert, 2019/05/25
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, KO Myung-Hun, 2019/05/25
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, Bruno Haible, 2019/05/28
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, KO Myung-Hun, 2019/05/29
- Re: [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2, Paul Eggert, 2019/05/29