getcwd-lgpl: fix m4 to match relaxed test for BSD
[gnulib.git] / doc / posix-functions / getcwd.texi
1 @node getcwd
2 @section @code{getcwd}
3 @findex getcwd
4
5 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/getcwd.html}
6
7 Gnulib module: getcwd or getcwd-lgpl
8
9 Portability problems fixed by either Gnulib module @code{getcwd} or
10 @code{getcwd-lgpl}:
11 @itemize
12 @item
13 On glibc platforms, @code{getcwd (NULL, n)} allocates memory for the result.
14 On some other platforms, this call is not allowed.
15 @item
16 On some platforms, the prototype for @code{getcwd} uses @code{int}
17 instead of @code{size_t} for the size argument when using non-standard
18 headers, and the declaration is missing from @code{<unistd.h>}:
19 mingw.
20 @item
21 On some platforms, @code{getcwd (buf, 0)} fails with @code{ERANGE}
22 instead of the required @code{EINVAL}:
23 mingw.
24 @end itemize
25
26 Portability problems fixed by Gnulib module @code{getcwd}:
27 @itemize
28 @item
29 This function is missing on some older platforms.
30 @item
31 This function does not handle long file names (greater than @code{PATH_MAX})
32 correctly on some platforms.
33 @end itemize
34
35 Portability problems not fixed by Gnulib:
36 @itemize
37 @item
38 When using @code{getcwd(NULL, nonzero)}, some platforms, such as glibc
39 or cygwin, allocate exactly @code{nonzero} bytes and fail with
40 @code{ERANGE} if it was not big enough, while other platforms, such as
41 FreeBSD or mingw, ignore the size argument and allocate whatever size
42 is necessary.  If this call succeeds, an application cannot portably
43 access beyond the string length of the result.
44 @end itemize