delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/09/18/05:47:34

Date: Fri, 18 Sep 1998 10:50:01 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Charles Marslett <charles DOT marslett AT vlsi DOT com>
cc: djgpp-workers AT delorie DOT com
Subject: Re: auto-binary-mode?
In-Reply-To: <3601502A.3BD9BD04@vlsi.com>
Message-ID: <Pine.SUN.3.91.980918104402.17626B-100000@is>
MIME-Version: 1.0

On Thu, 17 Sep 1998, Charles Marslett wrote:

> The disadvantage (and the advantage, IMHO) of _fmode vs. a libc mod
> to guess between "rb" and "rt" is that the code must be edited (and
> examined).  That is what I've done for the last 6-7 years and it seems
> to work better.

I don't think `_fmode' solves any of the problems raised in this thread.  

For starters, its effect is global, i.e. it causes *all* files to be open 
in that mode by default.  In my experience, it's a rare program that can 
really live with that.  Usually, some files need to be open in text mode, 
others in binary mode.  Remember, we are talking about naive programs 
written by people who aren't aware of subtleties involved.

Also, `_fmode' doesn't have any effect whatsoever on the 5 standard 
streams which are already open when the program starts.  A frequent 
gotcha in programs ported from Unix is that if the program can read from 
stdin or write to stdout, these streams are left in their default (text) 
mode, and then subtle bugs ensue.  The solution is to detect when these 
streams are redirected to a file and switch them to binary with a call to 
`setmode', but `_fmode' doesn't solve this.

- Raw text -


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