* 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


Reply via email to