Hash :
1622b36b
Author :
Date :
2011-05-25T15:15:14
getcwd: work around mingw bug mingw getcwd(buf, 0) fails with ERANGE, instead of the required EINVAL. Since we're already replacing getcwd on mingw, the workaround is trivial. * lib/getcwd-lgpl.c (rpl_getcwd): Guarantee correct error. * doc/posix-functions/getcwd.texi (getcwd): Document it. Reported by Matthias Bolte. Signed-off-by: Eric Blake <eblake@redhat.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
@node getcwd
@section @code{getcwd}
@findex getcwd
POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/getcwd.html}
Gnulib module: getcwd or getcwd-lgpl
Portability problems fixed by either Gnulib module @code{getcwd} or
@code{getcwd-lgpl}:
@itemize
@item
On glibc platforms, @code{getcwd (NULL, n)} allocates memory for the result.
On some other platforms, this call is not allowed.
@item
On some platforms, the prototype for @code{getcwd} uses @code{int}
instead of @code{size_t} for the size argument:
mingw.
@item
On some platforms, @code{getcwd (buf, 0)} fails with @code{ERANGE}
instead of the required @code{EINVAL}:
mingw.
@end itemize
Portability problems fixed by Gnulib module @code{getcwd}:
@itemize
@item
This function is missing on some older platforms.
@item
This function does not handle long file names (greater than @code{PATH_MAX})
correctly on some platforms.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
When using @code{getcwd(NULL, nonzero)}, some platforms, such as glibc
or cygwin, allocate exactly @code{nonzero} bytes and fail with
@code{ERANGE} if it was not big enough, while other platforms, such as
FreeBSD or mingw, ignore the size argument and allocate whatever size
is necessary. If this call succeeds, an application cannot portably
access beyond the string length of the result.
@end itemize