Subject: Re: gcc for WinNT
From: [email-masked] (Jim Balter)

7 Mar 1997 21:14:25 -0800
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.01Gold (WinNT; I)
Original-To: "John R. Dennis" <[email-masked]>
Original-CC: [email-masked], [email-masked], [email-masked]
Original-Sender: [email-masked]

John R. Dennis wrote:
> 
> >>>>> "Ron" == Ron G Minnich <[email-masked]> writes:
> 
>     Ron> reading in text mode? this is a simple int fd = open("file",
>     Ron> O_RDONLY); fd = read(blah blah)
> 
>     Ron> How do you control text mode from that? new options or an
>     Ron> fcntl?  ron - For help on using this list, send a message to
>     Ron> "[email-masked]" with one line of text: "help".
> 
> There are many ways to set binary vs. text mode on a file stream.
> 
> in fopen add either the b (binary) or the t (text) character in
> the mode string, e.g. fopen(filename "rb") to open a file for binary
> reading.
> 
> In open() bitwise OR one of _O_BINARY, _O_TEXT flags.
> 
> You can call _setmode(handle, mode) where mode is
> _O_TEXT or _O_BINARY after a file is open,  for example:
> 
>    /* Set "stdin" to have binary mode: */
>    result = _setmode( _fileno( stdin ), _O_BINARY );
>    if( result == -1 )
>       perror( "Cannot set mode" );
>    else
>       printf( "'stdin' successfully changed to binary mode\n" );
> 
> You can set the global variable _fmode. The _fmode variable sets the
> default file-translation mode for text or binary translation. It is
> declared in STDLIB.H as extern int _fmode;
> 
> The default setting of _fmode is _O_TEXT, for text-mode
> translation. _O_BINARY is the setting for binary mode.  You can change
> the value of _fmode in either of two ways: Link with BINMODE.OBJ. This
> changes the initial setting of _fmode to _O_BINARY, causing all files
> except stdin, stdout, and stderr to be opened in binary mode.
> Change the value of _fmode directly by setting it in your program.
> 
> Hope that helps,

These look like instructions for MSVC, not cygwin.
In cygwin, there's no _ in front of O_TEXT, O_BINARY, or fileno,
there's no BINMODE.OBJ, and _fmode is not defined in stdlib.h
or any other header file.

Also, setmode only fails if fd doesn't represent an open file,
so it's rather a waste to check its return value.
Also, beware that in MSVC setmode returns the previous mode, whereas in
cygwin it returns 0 (there seems to have been a persistent failure by
the original author of cygwin to ever read the documentation of the
systems he was emulating, be it MSVC or POSIX).  RCS, for one, assumes
the MSVC behavior.

--
<J Q B>
-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".