# with or without modifications, as long as this notice is preserved.
# Written by Paul Eggert.
-# serial 7
+# serial 8
AC_DEFUN([gl_FUNC_GETCWD_NULL],
[
return 0;
}
#endif
- /* If size is non-zero, allocation must fail if size is too small */
- if (getcwd (NULL, 1))
- return 5;
]])],
[gl_cv_func_getcwd_null=yes],
[gl_cv_func_getcwd_null=no],
]])])
])
+AC_DEFUN([gl_FUNC_GETCWD_SIGNATURE],
+[
+ AC_CACHE_CHECK([for getcwd with POSIX signature],
+ [gl_cv_func_getcwd_posix_signature],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <unistd.h>]],
+ [[extern
+ #ifdef __cplusplus
+ "C"
+ #endif
+ char *getcwd (char *, size_t);
+ ]])
+ ],
+ [gl_cv_func_getcwd_posix_signature=yes],
+ [gl_cv_func_getcwd_posix_signature=no])
+ ])
+])
dnl Guarantee that getcwd will malloc with a NULL first argument. Assumes
dnl that either the system getcwd is robust, or that calling code is okay
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
AC_REQUIRE([gl_FUNC_GETCWD_NULL])
+ AC_REQUIRE([gl_FUNC_GETCWD_SIGNATURE])
- case $gl_cv_func_getcwd_null in
- *yes) ;;
+ case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_posix_signature in
+ *yes,yes) ;;
*)
dnl Minimal replacement lib/getcwd-lgpl.c.
REPLACE_GETCWD=1
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
AC_REQUIRE([gl_FUNC_GETCWD_NULL])
+ AC_REQUIRE([gl_FUNC_GETCWD_SIGNATURE])
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
gl_abort_bug=no
gl_FUNC_GETCWD_ABORT_BUG([gl_abort_bug=yes]);;
esac
- case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_path_max,$gl_abort_bug in
- *yes,yes,no) ;;
+ 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, overrides LGPL replacement.
- REPLACE_GETCWD=1
- AC_LIBOBJ([getcwd])
- gl_PREREQ_GETCWD;;
+ dnl Full replacement lib/getcwd.c, overrides LGPL replacement.
+ REPLACE_GETCWD=1;;
esac
])