Re: Gnulib's freopen replacement and MinGW

Eli Zaretskii <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs,gmane.comp.lib.gnulib.bugs
Message-ID <[email protected]>
> From: Bruno Haible <[email protected]>
> Cc: [email protected]
> Date: Sat, 05 May 2012 16:26:55 +0200
> 
> > Diffutils 3.2 call xfreopen with its first argument NULL, expecting
> > the underlying reopen to handle this.  However, the MS runtime does
> > not implement the Posix semantics of such a call, and so, for example,
> > MinGW-compiled cmp fails when invoked to compare its stdin with a
> > file:
> > 
> >   D:\gnu\diffutils-3.2\src>cat cmp.c | cmp cmp.c -
> >   cmp: failed to reopen `stdin' with mode `rb': No such file or directory
> > 
> > The following change fixes this:
> > 
> > 2012-05-05  Eli Zaretskii  <[email protected]>
> > 
> > 	* lib/freopen.c [_WIN32]: Include io.h and fcntl.h.
> > 	(rpl_freopen) [_WIN32]: If the first argument is NULL, call
> > 	_setmode to switch STREAM to either binary or text mode, as
> > 	specified by MODE.
> 
> Thanks for the proposed patch, but the problem has already been fixed
> differently, by avoiding to use xfreopen() [1].

Thanks, that's good to know.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.