bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: [PATCH] Use O_BINARY to detect whether to pass "rb" to popen


From: Filipe Brandenburger
Subject: Re: [PATCH] Use O_BINARY to detect whether to pass "rb" to popen
Date: Thu, 21 May 2015 09:54:59 -0700

Hi Paul,

On Thu, May 21, 2015 at 9:51 AM, Paul Eggert <address@hidden> wrote:
> On 05/21/2015 09:36 AM, Filipe Brandenburger wrote:
>> Any suggestions of what's the best way to solve this?
>
> I suggest doing what Emacs does.  Put this in a header somewhere:
>
> #if O_BINARY
> # define FOPEN_BINARY "b"
> # define FOPEN_TEXT "t"
> #else
> # define FOPEN_BINARY ""
> # define FOPEN_TEXT ""
> #endif
>
> and then call 'popen (cmd, "r" FOPEN_BINARY)'.  Emacs does the same thing
> with fopen of course.  In practice this is good enough.

sharutils sources already carry a similar construct:

http://git.savannah.gnu.org/cgit/sharutils.git/tree/lib/system.h#n102

#if ! defined(O_BINARY) || (O_BINARY == 0)
# define  FOPEN_READ_BINARY   "r"
# define  FOPEN_WRITE_BINARY  "w"
#else
# define  FOPEN_READ_BINARY   "rb"
# define  FOPEN_WRITE_BINARY  "wb"
#endif

My latest patch proposes using this one instead of the one detected
from autoconf:

http://lists.gnu.org/archive/html/bug-gnu-utils/2015-05/msg00009.html

I wouldn't mind following up (or replacing the current one) with a
patch that uses FOPEN_BINARY/FOPEN_TEXT same as Emacs does and you
suggested.

Cheers,
Filipe



reply via email to

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