summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2011-11-28 00:04:12 +0100
committerBruno Haible <bruno@clisp.org>2011-11-28 00:04:12 +0100
commit176f1d1a865ee10da98321637160fc68ab51c554 (patch)
tree1a3e4f7b80897cf28052b7191d1e33f2b5a80227 /m4
parent8dccbc62431b05789d06d48ebf83b68180c7ab58 (diff)
downloadgnulib-176f1d1a865ee10da98321637160fc68ab51c554.tar.gz
getcwd: Fix bug from 2011-08-17.
* m4/getcwd.m4 (gl_FUNC_GETCWD): Set REPLACE_GETCWD to 1 only on platforms that need it. * m4/getcwd-abort-bug.m4 (gl_FUNC_GETCWD_ABORT_BUG): Consider a return code of 4 to be a failure, not a success. This ensures that REPLACE_GETCWD becomes 1 on OpenBSD 4.9 and NetBSD 5.1.
Diffstat (limited to 'm4')
-rw-r--r--m4/getcwd-abort-bug.m422
-rw-r--r--m4/getcwd.m414
2 files changed, 22 insertions, 14 deletions
diff --git a/m4/getcwd-abort-bug.m4 b/m4/getcwd-abort-bug.m4
index 60ea03cde2..057cc470b6 100644
--- a/m4/getcwd-abort-bug.m4
+++ b/m4/getcwd-abort-bug.m4
@@ -1,4 +1,4 @@
-# serial 6
+# serial 7
# Determine whether getcwd aborts when the length of the working directory
# name is unusually large. Any length between 4k and 16k trigger the bug
# when using glibc-2.4.90-9 or older.
@@ -91,7 +91,8 @@ main ()
results in a failed assertion. */
cwd = getcwd (NULL, 0);
if (cwd == NULL)
- fail = 4; /* getcwd failed. This is ok, and expected. */
+ fail = 4; /* getcwd failed: it refuses to return a string longer
+ than PATH_MAX. */
free (cwd);
/* Call rmdir first, in case the above chdir failed. */
@@ -110,11 +111,18 @@ main ()
}
]])],
[gl_cv_func_getcwd_abort_bug=no],
- dnl A "regular" nonzero return does not indicate this bug.
- dnl An abort will provoke an exit code of something like 134 (128 + 6).
- [test $? -gt 128 \
- && gl_cv_func_getcwd_abort_bug=yes \
- || gl_cv_func_getcwd_abort_bug=no],
+ [dnl An abort will provoke an exit code of something like 134 (128 + 6).
+ dnl An exit code of 4 can also occur (in OpenBSD 4.9, NetBSD 5.1 for
+ dnl example): getcwd (NULL, 0) fails rather than returning a string
+ dnl longer than PATH_MAX. This may be POSIX compliant (in some
+ dnl interpretations of POSIX). But gnulib's getcwd module wants to
+ dnl provide a non-NULL value in this case.
+ ret=$?
+ if test $ret -ge 128 || test $ret = 4; then
+ gl_cv_func_getcwd_abort_bug=yes
+ else
+ gl_cv_func_getcwd_abort_bug=no
+ fi],
[gl_cv_func_getcwd_abort_bug=yes])
])
AS_IF([test $gl_cv_func_getcwd_abort_bug = yes], [$1], [$2])
diff --git a/m4/getcwd.m4 b/m4/getcwd.m4
index dbdfcd2f41..8f3af321ee 100644
--- a/m4/getcwd.m4
+++ b/m4/getcwd.m4
@@ -6,7 +6,7 @@
# with or without modifications, as long as this notice is preserved.
# Written by Paul Eggert.
-# serial 10
+# serial 11
AC_DEFUN([gl_FUNC_GETCWD_NULL],
[
@@ -139,12 +139,12 @@ AC_DEFUN([gl_FUNC_GETCWD],
;;
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;;
- 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.