Mail Archives: cygwin/2005/01/18/09:03:56
Corinna, why did you change od in coreutils 5.2.1? When I proposed your
patch upstream, the maintainers pointed out that 12 lines later in the
same method, the code is calling setmode(fd, O_BINARY) for all non-tty
input filenames that were just fopen'd. Does cygwin have a working
setmode (and if not, does fcntl(fd, F_SETFL, O_BINARY | fcntl(fd,
F_GETFL)) work as expected)?
-------- Original Message --------
Subject: Re: more 5.3.0 issues on cygwin
Date: Tue, 18 Jan 2005 00:09:52 +0100
From: Jim Meyering <jim at meyering dot net>
To: Eric Blake <ebb9 AT byu DOT net>
CC: bug-coreutils at gnu dot org
Eric Blake <ebb9 AT byu DOT net> wrote:
...
> * src/od.c (OPENMODE): New macro.
> (open_next_file): Use OPENMODE in fopen call.
...
> Index: src/od.c
> ===================================================================
> RCS file: /cvsroot/coreutils/coreutils/src/od.c,v
> retrieving revision 1.152
> diff -u -p -r1.152 od.c
> --- src/od.c 28 Sep 2004 01:09:03 -0000 1.152
> +++ src/od.c 17 Jan 2005 13:09:07 -0000
> @@ -70,6 +70,12 @@ typedef unsigned long long int ulonglong
> typedef unsigned long int ulonglong_t;
> #endif
>
> +#ifdef O_BINARY
> +# define OPENMODE "rb"
> +#else
> +# define OPENMODE "r"
> +#endif
> +
> enum size_spec
> {
> NO_SIZE,
> @@ -906,7 +912,7 @@ open_next_file (void)
> }
> else
> {
> - in_stream = fopen (input_filename, "r");
> + in_stream = fopen (input_filename, OPENMODE);
> if (in_stream == NULL)
> {
> error (0, errno, "%s", input_filename);
Why is that needed?
od.c already does this:
SET_BINARY (fileno (in_stream));
where that macro is defined in system.h:
#if O_BINARY
# ifndef __DJGPP__
# define setmode _setmode
# define fileno(_fp) _fileno (_fp)
# endif /* not DJGPP */
# define SET_MODE(_f, _m) setmode (_f, _m)
# define SET_BINARY(_f) do {if (!isatty(_f)) setmode (_f, O_BINARY);}
while (0)
Maybe those #if directives don't work on your system?
--
Life is short - so eat dessert first!
Eric Blake ebb9 AT byu DOT net
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -