Mail Archives: djgpp-workers/2012/05/07/22:51:52
> From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
> Date: Mon, 7 May 2012 23:06:24 +0200
>
> If filename is a null pointer, the freopen() function shall attempt to change
> the mode of the stream to that specified by mode, as if the name of the file
> currently associated with the stream had been used. In this case, the file
> descriptor associated with the stream need not be closed if the call to
> freopen() succeeds. It is implementation-defined which changes of mode are
> permitted (if any), and under what circumstances.
>
> Because POSIX says that it is implementation-defined which changes of mode are
> permitted (if any), and under what circumstances, I have tried to implement
> what is possible using DOS/DJGPP.
It seems that the Posix requirements leave so much to
implementation-defined behavior that this API is not useful in
portable programs. Therefore, its potential for being used is slim at
best.
> AFAIK only O_BINARY/O_TEXT can be changed
> for an open file. No changing of O_RDONLY, O_WRONLY and O_RDWR is supported
> at all. This means that freopen acts like setmode(fileno(SOME_FILE), O_BINARY)
> when a NULL pointer is passed as first argument. This was my intention because
> this was the required behaviour to get GNU packages that use xfreopen to work
> with DJGPP. I am not in a hurry. We can wait and see how the gnulib maintainers
> solve this issue. I will fix the port in some way soon.
The gnulib maintainers already decided not to fix freopen, and
Diffutils (in their git repository) already use a plain call to
setmode (disguised in SET_BINARY) instead of xfreopen. So you might
as well simply use setmode there.
- Raw text -