bug-tar
[Top][All Lists]
Advanced

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

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


From: KO Myung-Hun
Subject: Re: [Bug-tar] [PATCH 2/2] tar: set stdin/stdout to binary mode on OS/2 if not console
Date: Tue, 09 Dec 2014 15:25:07 +0900
User-agent: Mozilla/5.0 (OS/2; Warp 4.5; rv:10.0.6esrpre) Gecko/20120715 Firefox/10.0.6esrpre SeaMonkey/2.7.2

Ping ?

KO Myung-Hun wrote:
> 
> 
> Pavel Raiskup wrote:
>> On Monday 24 of November 2014 12:25:45 KO Myung-Hun wrote:
>>> 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.
>>
>> Hi Myung-Hun KO,
>>
>> [ad 0002]
>>
>> neither you nor Paul have spoken about pros/cons of particular
>> implementation.
>>
>> From me, I also think that using binary-io makes sense.  Your patches are
>> clearly portability fixes and this is what is gnulib for (pros: you'll get
>> another portability fixes from any gnulib user in future).  What about
>> switch paxutils/tar source to use binary-io?
>>
> 
> Frankly, I don't know what I can get when using binary-io of gnulib
> instead of paxutils. Difference is that SET_BINARY is used instead of
> SET_BINARY_MODE, when using binary-io.
> 
> Anyway, whether using paxutils or using binary-io is not a problem. What
> is important is getting working codes and applying OS/2 patches.
> 
> I attach a updated patch using binary-io, and will send patches for
> paxutils separately.
> 
> Review, please...
> 
> 
> 
> 0001-tar-set-stdin-stdout-to-binary-mode-correctly-with-b.patch
> 
> 
> From c40d3f968f6ef328d3f49304fd461fbd760dc864 Mon Sep 17 00:00:00 2001
> From: KO Myung-Hun <address@hidden>
> Date: Mon, 24 Nov 2014 12:01:23 +0900
> Subject: [PATCH] tar: set stdin/stdout to binary mode correctly with binary-io
> 
> * gnulib.modules: Add binary-io.
> * 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/common.h: Include binary-io.h
> * 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.
> ---
>  gnulib.modules |  1 +
>  src/buffer.c   |  6 ++++--
>  src/common.h   |  1 +
>  src/extract.c  |  5 ++++-
>  src/misc.c     |  3 +++
>  src/system.c   | 10 ++++++++--
>  6 files changed, 21 insertions(+), 5 deletions(-)
> 
> diff --git a/gnulib.modules b/gnulib.modules
> index 0d2e76c..889a0f0 100644
> --- a/gnulib.modules
> +++ b/gnulib.modules
> @@ -24,6 +24,7 @@ argmatch
>  argp
>  argp-version-etc
>  backupfile
> +binary-io
>  closeout
>  configmake
>  dirname
> diff --git a/src/buffer.c b/src/buffer.c
> index a7d8971..31bb830 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 (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 (STDOUT_FILENO);
>            record_end = record_start; /* set up for 1st record = # 0 */
>            if (!index_file_name)
>              stdlis = stderr;
> @@ -827,7 +829,7 @@ _open_archive (enum access_mode wanted_access)
>  
>    sys_detect_dev_null_output ();
>    sys_save_archive_dev_ino ();
> -  SET_BINARY_MODE (archive);
> +  SET_BINARY (archive);
>  
>    switch (wanted_access)
>      {
> @@ -1353,7 +1355,7 @@ new_volume (enum access_mode mode)
>        goto tryagain;
>      }
>  
> -  SET_BINARY_MODE (archive);
> +  SET_BINARY (archive);
>  
>    return true;
>  }
> diff --git a/src/common.h b/src/common.h
> index 3cc2011..bed2824 100644
> --- a/src/common.h
> +++ b/src/common.h
> @@ -51,6 +51,7 @@
>  
>  #include "arith.h"
>  #include <backupfile.h>
> +#include <binary-io.h>
>  #include <exclude.h>
>  #include <full-write.h>
>  #include <modechange.h>
> diff --git a/src/extract.c b/src/extract.c
> index ca25603..f4c7033 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 (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..7eb2773 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 (fd[0]);
> +  SET_BINARY (fd[1]);
>  }
>  
>  /* Return PTR, aligned upward to the next multiple of ALIGNMENT.
> diff --git a/src/system.c b/src/system.c
> index 9414233..402fa7a 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 (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 (archive);
> +    }
>    else
>      archive = rmtopen (archive_name_array[0], O_RDONLY | O_BINARY,
>                      MODE_RW, rsh_command_option);

-- 
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




reply via email to

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