summaryrefslogtreecommitdiff
path: root/gnulib/m4/getcwd.m4
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2012-02-01 23:46:33 +0000
committerColin Watson <cjwatson@debian.org>2012-02-01 23:46:33 +0000
commit8410a03575f1a8550498f3d0b4ea51ff72edd780 (patch)
tree98b88fbce129cb9c69e3461394ead94c12731466 /gnulib/m4/getcwd.m4
parent91c495389105a4cb6214fe176f703f498e4f0d91 (diff)
Upgrade to Automake 1.11.2 and Gnulib 20111211-stable.
* gnulib: Import closedir, fstat, and opendir modules.
Diffstat (limited to 'gnulib/m4/getcwd.m4')
-rw-r--r--gnulib/m4/getcwd.m456
1 files changed, 42 insertions, 14 deletions
diff --git a/gnulib/m4/getcwd.m4 b/gnulib/m4/getcwd.m4
index d3bbe597..8f3af321 100644
--- a/gnulib/m4/getcwd.m4
+++ b/gnulib/m4/getcwd.m4
@@ -6,15 +6,20 @@
# with or without modifications, as long as this notice is preserved.
# Written by Paul Eggert.
-# serial 8
+# serial 11
AC_DEFUN([gl_FUNC_GETCWD_NULL],
[
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CHECK_HEADERS_ONCE([unistd.h])
AC_CACHE_CHECK([whether getcwd (NULL, 0) allocates memory for result],
[gl_cv_func_getcwd_null],
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
-# include <unistd.h>
+# if HAVE_UNISTD_H
+# include <unistd.h>
+# else /* on Windows with MSVC */
+# include <direct.h>
+# endif
# ifndef getcwd
char *getcwd ();
# endif
@@ -103,20 +108,43 @@ AC_DEFUN([gl_FUNC_GETCWD],
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
gl_abort_bug=no
- case $gl_cv_func_getcwd_null,$host_os in
- *,mingw*)
- gl_cv_func_getcwd_path_max=yes;;
- yes,*)
- gl_FUNC_GETCWD_PATH_MAX
- gl_FUNC_GETCWD_ABORT_BUG([gl_abort_bug=yes]);;
+ case "$host_os" in
+ mingw*)
+ gl_cv_func_getcwd_path_max=yes
+ ;;
+ *)
+ gl_FUNC_GETCWD_PATH_MAX
+ case "$gl_cv_func_getcwd_null" in
+ *yes)
+ gl_FUNC_GETCWD_ABORT_BUG([gl_abort_bug=yes])
+ ;;
+ esac
+ ;;
esac
-
- case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_posix_signature$gl_cv_func_getcwd_path_max,$gl_abort_bug in
- *yes,yes,yes,no) ;;
- *)
- dnl Full replacement lib/getcwd.c, overrides LGPL replacement.
- REPLACE_GETCWD=1;;
+ dnl Define HAVE_MINIMALLY_WORKING_GETCWD and HAVE_PARTLY_WORKING_GETCWD
+ dnl if appropriate.
+ case "$gl_cv_func_getcwd_path_max" in
+ "no, it has the AIX bug") ;;
+ *)
+ AC_DEFINE([HAVE_MINIMALLY_WORKING_GETCWD], [1],
+ [Define to 1 if getcwd minimally works, that is, its result can be
+ trusted when it succeeds.])
+ ;;
esac
+ case "$gl_cv_func_getcwd_path_max" in
+ "no, but it is partly working")
+ AC_DEFINE([HAVE_PARTLY_WORKING_GETCWD], [1],
+ [Define to 1 if getcwd works, except it sometimes fails when it
+ shouldn't, setting errno to ERANGE, ENAMETOOLONG, or ENOENT.])
+ ;;
+ esac
+
+ if { case "$gl_cv_func_getcwd_null" in *yes) false;; *) true;; esac; } \
+ || test $gl_cv_func_getcwd_posix_signature != yes \
+ || test "$gl_cv_func_getcwd_path_max" != yes \
+ || test $gl_abort_bug = yes; then
+ REPLACE_GETCWD=1
+ fi
])
# Prerequisites of lib/getcwd.c, when full replacement is in effect.