delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/07/02/17:13:05

Date: Sun, 2 Jul 1995 16:46:06 -0400 (EDT)
From: David Steiner Nieves <dsn AT chem DOT duke DOT edu>
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: read()?{{

> > A while ago I ran into a situation (I think it was with Borland, but it 
> > might exist in djgpp) where I wanted to treat cin and cout in "raw" 
> > mode.  Is there a way to do this that is analogous to what you wrote above?
> 
> setmode() should work in C++ as well as in C.  It sets the handle to raw
> mode as part of its operation.{> 

I was writing overloaded "<<" and ">>" operators but could not figure out 
a way to determine the handle of a stream.  Obviously, I could check for 
cin and cout and use the predefined 0 and 1, but for others I couldn't 
figure this out.

I realize that this is getting to be a general C++ rather than a 
djgpp-specific question, but allow me to stear it back to djgpp.  A few 
days ago someon{ (you?) suggested that when using a FILE* type from 
stdio, it could be set to binary by doing a setmode(fileno(file_var), 
O_BINARY).  When I used fwrite subsequently, it cleared up 99% of the 
CR->CR/LF translations, but not all of them.  Occasionally, such 
translations o{curred.  Interestingly enough, fread() continued to work 
properly.  I encountered similar problems using Borland, but the 
CR->CR/LF translations occurred in different locations. {For each 
compiler, it occurred in the same place after each execution (the site of 
translation was consistent for each compiler), but I 
would think that it shouldn't happen at all.  Ultimately, I switched to 
exclusively using file handles, read(), and write().  This cleared up the 
problem, but I'm not sure why it occurred in the first place.

Here's something that makes it even weirder: under djgpp (but not 
Borland) this translation appeared to be linked to whether I commented or 
uncommented a nearby use of cerr.  Note that in my code cerr was the only 
streams operator I used; for the rest I was using FILE * variables, 
calling setmode(), and using fwrite and fread.  Any clues?

Thanks again for your time and ideas.

David

- Raw text -


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