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

Paul Eggert <[email protected]> Thu, 21 May 2015 09:51:42 -0700
Newsgroups gmane.comp.gnu.utils.bugs
Organization UCLA Computer Science Department
Message-ID <[email protected]>
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.