Hash :
69dba6d7
Author :
Date :
2011-11-21T00:56:11
getcwd: Work around getcwd bug on AIX 5..7. * m4/getcwd-path-max.m4 (gl_FUNC_GETCWD_PATH_MAX): Require AC_CANONICAL_HOST. Assign exit code 31 to the bug seen on AIX 5.1..7.1. Use a different value for gl_cv_func_getcwd_path_max. Move the definition of HAVE_PARTLY_WORKING_GETCWD from here... * m4/getcwd.m4 (gl_FUNC_GETCWD): ... to here. Invoke gl_FUNC_GETCWD_PATH_MAX also when $gl_cv_func_getcwd_null is 'no'. Define HAVE_MINIMALLY_WORKING_GETCWD. * lib/getcwd.c (__getcwd): Don't use the system's getcwd on platforms where it is not even minimally working, that is, on AIX. * tests/test-getcwd.c (test_long_name): Distinguish the same cases as m4/getcwd-path-max.m4. (main): Update exit code computation. * doc/posix-functions/getcwd.texi: Mention list of platforms where getcwd does not handle long file names.
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 44 45 46 47 48 49
@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
This function is declared in different header files (namely, @code{<io.h>} or
@code{<direct.h>}) on some platforms:
mingw, MSVC 9.
@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 when using non-standard
headers, and the declaration is missing from @code{<unistd.h>}:
mingw, MSVC 9.
@item
On some platforms, @code{getcwd (buf, 0)} fails with @code{ERANGE}
instead of the required @code{EINVAL}:
mingw, MSVC 9.
@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:
glibc on Linux 2.4.20, MacOS X 10.5, FreeBSD 6.4, NetBSD 5.1, OpenBSD 4.9, AIX 7.1.
@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, mingw, or MSVC 9, 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