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>
+2011-05-25 Eric Blake <eblake@redhat.com>
+
+ getcwd: work around mingw bug
+ * lib/getcwd-lgpl.c (rpl_getcwd): Guarantee correct error.
+ * doc/posix-functions/getcwd.texi (getcwd): Document it.
+ Reported by Matthias Bolte.
+
2011-05-24 Paul Eggert <eggert@cs.ucla.edu>
test-intprops: disable -Wtype-limits diagnostics
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}:
/* Handle single size operations. */
if (buf)
- return getcwd (buf, size);
+ {
+ if (!size)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+ return getcwd (buf, size);
+ }
if (size)
{