Mail Archives: djgpp/2000/07/16/04:11:23
On Sat, 15 Jul 2000, Damian Yerrick wrote:
> >It is not always practical to change every call to `open', `fopen',
> >`fdopen', and `popen' in a large program ported from Unix. This is
> >when `_fmode' comes in handy.
>
> And so does search-and-replace.
I didn't say it was impossible, I said it was not always practical.
Try search-and-replace in a large package (such as Emacs or Web2c or
even Groff) and see what I mean.
In a sufficiently large package, you don't even know in all cases
whether a given call to open a file should use text or binary mode.
You need to have a clear understanding what kind of files are handled
by each specific instance of code. And what if the same function
handles files some of which are text and some binary?
> For instance, in Binutils one can
> mostly change "r" to "rb" and "w" to "wb". For Textutils, change "r"
> to "rt" and "w" to "wt".
I suggest a reality check: please look in these packages and see what
the ported code *really* looks like. You will be surprised, I think.
(For example, Textutils actually do binary I/O most of the time.)
The problems with blindly using "wt" and "rb" were already described
in this thread: "b" is not portable to pre-ANSI Unix platforms, and
"t" is an extension to ANSI that isn't widely supported outside
DOS/Windows compilers. So a maintainer of a GNU package will most
probably reject such patches. In contrast, adding a DOS-specific line
which sets _fmode will probably be accepted (and is IMHO much less
invasive).
The problem with _fmode is that it is most of the time inappropriate,
as Hans-Bernhard explained. (Cygwin is an exception.)
- Raw text -