From: KO Myung-Hun <komh78@gmail.com>
To: bug-gnulib@gnu.org
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 [thread overview]
Message-ID: <20190524113138.34458-1-komh@chollian.net> (raw)
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
next reply other threads:[~2019-05-24 11:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-24 11:31 KO Myung-Hun [this message]
2019-05-24 20:20 ` [PATCH] binary-io: do not treat set_binary_mode() on stdin/out/err as an error on OS/2 Paul Eggert
2019-05-25 3:29 ` KO Myung-Hun
2019-05-25 13:41 ` Bruno Haible
2019-05-25 14:18 ` KO Myung-Hun
2019-05-25 16:31 ` Bruno Haible
2019-05-25 17:14 ` Paul Eggert
2019-05-26 1:48 ` KO Myung-Hun
2019-05-29 0:47 ` Bruno Haible
2019-05-29 13:32 ` KO Myung-Hun
2019-05-30 0:05 ` Paul Eggert
2019-05-30 0:55 ` Bruno Haible
2019-06-02 6:03 ` Paul Eggert
2019-06-02 9:31 ` Bruno Haible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190524113138.34458-1-komh@chollian.net \
--to=komh78@gmail.com \
--cc=bug-gnulib@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).