From: Bruno Haible Date: Sun, 27 Nov 2011 23:04:12 +0000 (+0100) Subject: getcwd: Fix bug from 2011-08-17. X-Git-Tag: v0.1~1402 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=176f1d1a865ee10da98321637160fc68ab51c554;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index ab3d043ff..d0efb2ef0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2011-11-27 Bruno Haible + 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. + +2011-11-27 Bruno Haible + binary-io tests: Avoid test failure on mingw when libtool is used. * tests/test-binary-io.c (main): Don't remove t-bin-out2.tmp here. Don't verify the size of t-bin-out1.tmp here. diff --git a/m4/getcwd-abort-bug.m4 b/m4/getcwd-abort-bug.m4 index 60ea03cde..057cc470b 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 dbdfcd2f4..8f3af321e 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.