delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/02/26/01:30:45

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Sender: edwin AT delorie DOT com
Message-ID: <36D63EB0.7FF0C3E9@netwood.net>
Date: Thu, 25 Feb 1999 22:26:57 -0800
From: "E. Robert Tisdale" <edwin AT netwood DOT net>
X-Mailer: Mozilla 4.07 [en] (X11; I; Linux 2.0.36 i686)
MIME-Version: 1.0
To: cygwin AT sourceware DOT cygnus DOT com
Subject: Re: setmode (long)
References: <199902260257 DOT UAA08616 AT modi DOT xraylith DOT wisc DOT edu>

Mumit Khan wrote:

> I believe Pierre has something here.
> I took another look at your code,
> and you're changing the mode of a buffered stream!
> Could you flush the stream (stream << flush)
> before changing the mode and see what happens?

No, I can't just now.
I sent the computer with Windows 98
and the DJPP and Cygnus compilers to my brother-in-law.
You'll have to wait until I can fire up my old Windows 95.

> I don't believe that your code is well-defined,
> since changing anything for an underlying descriptor
> of a buffered stream without flushing
> is not guaranteed to produce the desired effect.

Can you tell me where I can get documentation
for this behavior in setmode?
I got the file descriptors for standard I/O from

0 == (cin.rdbuf())->_fileno
1 == (cout.rdbuf())->_fileno
2 == (cerr.rdbuf())->_fileno

because a
ostdiostream has a
stdiobuf which is a
filebuf which is a
streambuf which is a
_IO_FILE which has an
int _fileno.

Is there a portable way to get file descriptors
for cin, cout, cerr and clog?

I suspect that Pierre may indeed have part of the answer
for his Windows 95 OS and his Emacs shell
but it doesn't explain why my `test.out' files
appear to be written in binary mode
even when the last mode set is text mode.

E. Robert Tisdale <edwin AT netwood DOT net>




--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019