Hi/2.

KO Myung-Hun wrote:
> 
> 
> Paul Eggert wrote:
>> Myung-Hun KO wrote:
>>> But any special reasons why binary-io module of gnulib should
>>> be used instead of pre-existent SET_BINARY_MODE() ? In addition,
>>> SET_BINARY_MODE() is being used already.
>>
>> My impression is that the proposed patch is reimplementing binary-io,
>> which would mean it's better to bite the bullet and just use it.
>>
>>
> 
> I've updated the patches.
> 

Updated, again.

-- 
KO Myung-Hun

Using Mozilla SeaMonkey 2.7.2
Under OS/2 Warp 4 for Korean with FixPak #15
In VirtualBox v4.1.32 on Intel Core i7-3615QM 2.30GHz with 8GB RAM

Korean OS/2 User Community : http://www.ecomstation.co.kr

From cbd429286ced7332c270c86b46f048deb658ec67 Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <k...@chollian.net>
Date: Tue, 9 Sep 2014 17:43:17 +0900
Subject: [PATCH] lib: define wrapper macros for OS/2

* lib/system.h: Define wrapper macros for OS/2
---
 lib/system.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/system.h b/lib/system.h
index e7f531c..aa2404a 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -467,11 +467,15 @@ char *getenv ();
 # include <grp.h>
 #endif
 
-#if MSDOS
-# include <process.h>
+#if MSDOS || defined(__OS2__)
+# ifdef __OS2__
+#  include <io.h>    /* setmode() */
+# else
+#  include <process.h>
+#  define mkdir(file, mode) (mkdir) (file)
+# endif
 # define SET_BINARY_MODE(arc) setmode(arc, O_BINARY)
 # define ERRNO_IS_EACCES errno == EACCES
-# define mkdir(file, mode) (mkdir) (file)
 # define TTY_NAME "con"
 # define sys_reset_uid_gid()
 #else
-- 
1.8.5.2

From 20011808a19ebb63334612b7576ff09d3ee8ff98 Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <k...@chollian.net>
Date: Mon, 24 Nov 2014 12:01:23 +0900
Subject: [PATCH] tar: set stdin/stdout to binary mode correctly

* src/buffer.c (_open_archive): Ensure that stdin is binary mode
before check_compressed_archive(). Set stdout to binary mode if
writing archives to stdout.
* src/extract.c (extract_file): Set stdout to binary mode if
writing to stdout.
* src/misc.c (xpipe): Set pipes to binary mode
* src/system.c (sys_child_open_for_compress): Set stdout to binary
mode.
(sys_child_open_for_uncompress): Set stdin to binary mode.
---
 src/buffer.c  |  2 ++
 src/extract.c |  5 ++++-
 src/misc.c    |  3 +++
 src/system.c  | 10 ++++++++--
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index a7d8971..171c872 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -748,6 +748,7 @@ _open_archive (enum access_mode wanted_access)
             enum compress_type type;
 
             archive = STDIN_FILENO;
+            SET_BINARY_MODE (archive);
             type = check_compressed_archive (&shortfile);
             if (type != ct_tar && type != ct_none)
               FATAL_ERROR ((0, 0,
@@ -767,6 +768,7 @@ _open_archive (enum access_mode wanted_access)
         case ACCESS_UPDATE:
           archive = STDIN_FILENO;
           write_archive_to_stdout = true;
+          SET_BINARY_MODE (STDOUT_FILENO);
           record_end = record_start; /* set up for 1st record = # 0 */
           if (!index_file_name)
             stdlis = stderr;
diff --git a/src/extract.c b/src/extract.c
index ca25603..91b1989 100644
--- a/src/extract.c
+++ b/src/extract.c
@@ -1076,7 +1076,10 @@ extract_file (char *file_name, int typeflag)
   mode_t current_mode_mask = 0;
 
   if (to_stdout_option)
-    fd = STDOUT_FILENO;
+    {
+      fd = STDOUT_FILENO;
+      SET_BINARY_MODE (fd);
+    }
   else if (to_command_option)
     {
       fd = sys_exec_command (file_name, 'f', &current_stat_info);
diff --git a/src/misc.c b/src/misc.c
index 8e66643..7f89871 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1129,6 +1129,9 @@ xpipe (int fd[2])
 {
   if (pipe (fd) < 0)
     call_arg_fatal ("pipe", _("interprocess channel"));
+
+  SET_BINARY_MODE (fd[0]);
+  SET_BINARY_MODE (fd[1]);
 }
 
 /* Return PTR, aligned upward to the next multiple of ALIGNMENT.
diff --git a/src/system.c b/src/system.c
index 9414233..7a03748 100644
--- a/src/system.c
+++ b/src/system.c
@@ -405,7 +405,10 @@ sys_child_open_for_compress (void)
   xclose (child_pipe[PWRITE]);
 
   if (strcmp (archive_name_array[0], "-") == 0)
-    archive = STDOUT_FILENO;
+    {
+      archive = STDOUT_FILENO;
+      SET_BINARY_MODE (archive);
+    }
   else
     {
       archive = rmtcreat (archive_name_array[0], MODE_RW, rsh_command_option);
@@ -575,7 +578,10 @@ sys_child_open_for_uncompress (void)
   xclose (child_pipe[PREAD]);
 
   if (strcmp (archive_name_array[0], "-") == 0)
-    archive = STDIN_FILENO;
+    {
+      archive = STDIN_FILENO;
+      SET_BINARY_MODE (archive);
+    }
   else
     archive = rmtopen (archive_name_array[0], O_RDONLY | O_BINARY,
                       MODE_RW, rsh_command_option);
-- 
1.8.5.2

Reply via email to