[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] [PATCH 2/3] tar: set stdin/stdout to binary mode on OS/2 if th
From: |
KO Myung-Hun |
Subject: |
[Bug-tar] [PATCH 2/3] tar: set stdin/stdout to binary mode on OS/2 if they are not console |
Date: |
Mon, 22 Sep 2014 17:49:18 +0900 |
* src/tar.c: Include io.h for setmode().
(main): Subject.
---
src/tar.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/src/tar.c b/src/tar.c
index 283b1ae..059a042 100644
--- a/src/tar.c
+++ b/src/tar.c
@@ -53,6 +53,10 @@
#include <priv-set.h>
#include <savedir.h>
+#ifdef __OS2__
+# include <io.h> /* setmode() */
+#endif
+
/* Local declarations. */
#ifndef DEFAULT_ARCHIVE_FORMAT
@@ -2739,6 +2743,15 @@ main (int argc, char **argv)
/* Make sure we have first three descriptors available */
stdopen ();
+#ifdef __OS2__
+ /* Set stdin/out to binary mode if it is not a console */
+ if (!isatty (fileno (stdin)))
+ setmode (fileno (stdin), O_BINARY);
+
+ if (!isatty (fileno (stdout)))
+ setmode (fileno (stdout), O_BINARY);
+#endif
+
/* Pre-allocate a few structures. */
allocated_archive_names = 10;
--
1.7.3.2