Re: Comparing binary files with Diff 3.2 compiled with 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, 12 May 2012 19:41:39 +0200
> 
> But regarding <binary-io.h>, I am unhappy about another macro UNSET_BINARY.
> If you need
>   1. to reset the value to O_TEXT,
>   2. to get the previous value in return,
> then I would suggest to use a function
> 
>   int setmode (int fd, int o_mode);
> 
> exactly like in Cygwin, so that no code is needed on Cygwin.

You mean, us it directly, not through a macro?  But then why does
gnulib provide SET_BINARY as a macro?  I'm probably missing something
here.

Using UNSET_BINARY allowed me to avoid any #ifdef's in the application
code.  If I use setmode, then #ifdef's are necessary.

> If we had the chance to design a new API would prefer
> 
>   bool set_binary_mode (int fd, bool binary);

In fact, Diffutils 2.8.7 used precisely such an API.

> > --- lib/binary-io.h~1	2012-05-12 17:31:43.639250000 +0300
> > +++ lib/binary-io.h	2012-05-12 18:19:53.842375000 +0300
> 
> > -# if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__
> > +# if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__ || defined _WIN32
> >  #  include <io.h> /* declares setmode() */
> >  # else
> >  #  define setmode _setmode
> 
> This change is wrong. The MSVC headers don't unconditionally declare
> 'setmode' and 'fileno'.

Yes, that was my mistake.  I changed this to __MINGW32__ in a
followup (MinGW does have io.h that declares 'setmode').

> And, please, for consistency with the other codes, use
> "defined _WIN32 || defined __WIN32__", not just "defined _WIN32".

I think this is a moot point, since _WIN32 will be replaced by
__MINGW32__.

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