bug-gnulib
[Top][All Lists]
Advanced

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

Re: Comparing binary files with Diff 3.2 compiled with MinGW


From: Eli Zaretskii
Subject: Re: Comparing binary files with Diff 3.2 compiled with MinGW
Date: Sat, 12 May 2012 20:53:44 +0300

> From: Bruno Haible <address@hidden>
> Cc: address@hidden
> 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.



reply via email to

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