Date: Fri, 18 Sep 1998 10:50:01 +0300 (IDT) From: Eli Zaretskii To: Charles Marslett cc: djgpp-workers AT delorie DOT com Subject: Re: auto-binary-mode? In-Reply-To: <3601502A.3BD9BD04@vlsi.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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.