Mail Archives: djgpp-workers/2012/05/07/17:06:38
Am Montag, 7. Mai 2012 schrieb Eli Zaretskii:
> > Date: Sun, 06 May 2012 20:41:30 +0300
> > From: Eli Zaretskii <eliz AT gnu DOT org>
> >
> > > From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
> > > Date: Sun, 6 May 2012 18:06:08 +0200
> > >
> > > I have tried to implement the case when a NULL pointer is passed as filename.
> > > Because DOS does not allow to change file descriptor flags of open files, only
> > > the change of textmode using setmode() is supported. Any other function call
> > > with a NULL pointer as filename argument will fail with EBADF.
> > > Please note that a different file acces mode will make the call fail,
> > > e.g.: if the new mode is O_WRONLY but the old mode was O_RDWR then the call
> > > will fail. No file access mode is allowed.
> > > Suggestions, objections, comments are welcome.
> >
> > Thanks, this looks good to me.
>
> However, this thread:
>
> http://lists.gnu.org/archive/html/bug-gnulib/2012-05/msg00063.html
>
> and in particular its last 2 messages, seem to indicate that perhaps
> we shouldn't support such a controversial feature.
>
Taken verbatim from <http://pubs.opengroup.org/onlinepubs/009695399/functions/freopen.html>:
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. 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.
Regards,
Juan M. Guerrero
- Raw text -