Mail Archives: djgpp-workers/1998/09/18/05:47:34
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 -