bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-tar] [PATCH 2/2] tar: set stdin/stdout to binary mode on OS/2 if no


From: KO Myung-Hun
Subject: [Bug-tar] [PATCH 2/2] tar: set stdin/stdout to binary mode on OS/2 if not console
Date: Mon, 17 Nov 2014 20:23:21 +0900

* src/tar.c: Include io.h for setmode().
(main): Set stdin/stdout to binary mode on OS/2 if not console.
---
 src/tar.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/tar.c b/src/tar.c
index 7512e98..8c50607 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
@@ -2743,6 +2747,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.8.5.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]