Mail Archives: djgpp-workers/2009/08/09/14:00:37
> From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
> Date: Sun, 9 Aug 2009 15:51:18 +0200
>
> While I was trying to port m4 I have noticed that the configure script complains
> that both functions fopen() and open() do not handle correctly the case when the
> pathnames end with a slash.
Does that do any harm? Or does M4 include work-arounds for such
systems?
> 1) According to POSIX: If the filename contains at least one non-slash character
> and ends with one or more trailing slashes and one of the modes O_CREAT,
> O_WRONLY or O_RDWR is specified, then open() must fail with EISDIR.
> The same applies for fopen() if the modes w or a have been specified.
> 2) According to POSIX: If the filename ends in a slash and the file descriptor
> of the named file without the slash does not refer to a directory, then open()
> must fail with ENOTDIR.
> See: <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>,
> <http://www.opengroup.org/susv3/functions/fopen.html> and
> <http://www.opengroup.org/susv3/functions/open.html>
I think this is a version of Posix standard to which DJGPP doesn't
conform, anyway.
> Because open() is also called by fopen() to do the job, the issue needs only to
> be fixed there.
Do we really need to fix it? It sounds like a potential to break
existing programs is high, while the benefits are vague at best.
> + if (((oflag & (O_RDONLY | O_CREAT | O_WRONLY | O_RDWR)) != O_RDONLY) && \
> + !is_root_dir && IS_SLASH(filename[length - 1]))
If we do accept this change of behavior, I think it's definitely wrong
to support it when the last character is a backslash. Posix file
names should end with a forward slash, so I don't think we should
support Posix rules for non-Posix file names.
- Raw text -