[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
- Re: [PATCH 0/4] Cross compiling sharutils, (continued)
- Re: [PATCH 0/4] Cross compiling sharutils, Eric Blake, 2015/05/19
- Re: [PATCH 0/4] Cross compiling sharutils, Eli Zaretskii, 2015/05/19
- Re: [PATCH 0/4] Cross compiling sharutils, Bruce Korb, 2015/05/20
- Re: [PATCH 0/4] Cross compiling sharutils, Eric Blake, 2015/05/21
- Re: [PATCH 0/4] Cross compiling sharutils, Filipe Brandenburger, 2015/05/21
- Re: [PATCH 0/4] Cross compiling sharutils, Filipe Brandenburger, 2015/05/21
- [PATCH] Use O_BINARY to detect whether to pass "rb" to popen, Filipe Brandenburger, 2015/05/21
- Re: [PATCH] Use O_BINARY to detect whether to pass "rb" to popen, Eli Zaretskii, 2015/05/21
- Re: [PATCH] Use O_BINARY to detect whether to pass "rb" to popen, Filipe Brandenburger, 2015/05/21
- Re: [PATCH] Use O_BINARY to detect whether to pass "rb" to popen, Paul Eggert, 2015/05/21
- Re: [PATCH] Use O_BINARY to detect whether to pass "rb" to popen,
Filipe Brandenburger <=
- Re: [PATCH] Use O_BINARY to detect whether to pass "rb" to popen, Eli Zaretskii, 2015/05/21
- Re: [PATCH] Use O_BINARY to detect whether to pass "rb" to popen, Bruce Korb, 2015/05/21
- Re: [PATCH] Use O_BINARY to detect whether to pass "rb" to popen, Filipe Brandenburger, 2015/05/22
- Re: [PATCH] Use O_BINARY to detect whether to pass "rb" to popen, Eli Zaretskii, 2015/05/22
- Re: [PATCH] Use O_BINARY to detect whether to pass "rb" to popen, Andreas Schwab, 2015/05/22
- Re: [PATCH] Use O_BINARY to detect whether to pass "rb" to popen, Bruce Korb, 2015/05/22
- Re: [PATCH] Use O_BINARY to detect whether to pass "rb" to popen, Filipe Brandenburger, 2015/05/22
- [PATCH 1/2] Use O_BINARY to detect whether to pass "rb" to popen, Filipe Brandenburger, 2015/05/22
- [PATCH 2/2] Be more careful in guarding against pathological "begin" lines, Filipe Brandenburger, 2015/05/22
- Re: [PATCH 1/2] Use O_BINARY to detect whether to pass "rb" to popen, cowan, 2015/05/22