getcwd: support coreutils better
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 20 Feb 2013 08:04:35 +0000 (00:04 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 20 Feb 2013 08:05:15 +0000 (00:05 -0800)
Like strtod, getcwd incorrectly referred to HAVE_RAW_DECL_GETCWD,
but this might not be correct in coreutils, which disables
the raw decl checks.  Problem reported by Nagendra in
<http://bugs.gnu.org/10305#192>.
* lib/getcwd.c (__getcwd): Do not depend on HAVE_RAW_DECL_GETCWD.
* m4/getcwd-path-max.m4 (gl_FUNC_GETCWD_PATH_MAX):
Test the getcwd function, not any macro, since getcwd.c wants the
function.
* m4/getcwd.m4 (gl_FUNC_GETCWD):
Don't define HAVE_MINIMALLY_WORKING_GETCWD if the code doesn't
compile, as might happen if there's a macro but no function.

ChangeLog
lib/getcwd.c
m4/getcwd-path-max.m4
m4/getcwd.m4

index a6c50ff560881ce9f571a6ad5e63b0dbaae31376..a5b6b1363d4692f328fc30dbd75b1415d34c7b99 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2013-02-19  Paul Eggert  <eggert@cs.ucla.edu>
 
+       getcwd: support coreutils better
+       Like strtod, getcwd incorrectly referred to HAVE_RAW_DECL_GETCWD,
+       but this might not be correct in coreutils, which disables
+       the raw decl checks.  Problem reported by Nagendra in
+       <http://bugs.gnu.org/10305#192>.
+       * lib/getcwd.c (__getcwd): Do not depend on HAVE_RAW_DECL_GETCWD.
+       * m4/getcwd-path-max.m4 (gl_FUNC_GETCWD_PATH_MAX):
+       Test the getcwd function, not any macro, since getcwd.c wants the
+       function.
+       * m4/getcwd.m4 (gl_FUNC_GETCWD):
+       Don't define HAVE_MINIMALLY_WORKING_GETCWD if the code doesn't
+       compile, as might happen if there's a macro but no function.
+
        strtod: support coreutils better
        * lib/strtod.c (underlying_strtod): Just invoke the underlying strtod.
        HAVE_RAW_DECL_STRTOD might not be correct in coreutils, which
index 4b781389ba96604d136a5c429292bd1f6b556353..f31c07e1755066b7b3720249a7842413206e57e7 100644 (file)
@@ -135,7 +135,7 @@ __getcwd (char *buf, size_t size)
   size_t allocated = size;
   size_t used;
 
-#if HAVE_RAW_DECL_GETCWD && HAVE_MINIMALLY_WORKING_GETCWD
+#if HAVE_MINIMALLY_WORKING_GETCWD
   /* If AT_FDCWD is not defined, the algorithm below is O(N**2) and
      this is much slower than the system getcwd (at least on
      GNU/Linux).  So trust the system getcwd's results unless they
index d30e1b32474cac54eecde5057a26c6c61ee862e2..0b03b66aba611a60086742cbb5bc99c4cbf4c574 100644 (file)
@@ -52,6 +52,9 @@ AC_DEFUN([gl_FUNC_GETCWD_PATH_MAX],
 # define is_ENAMETOOLONG(x) 0
 #endif
 
+/* Use the getcwd function, not any macro.  */
+#undef getcwd
+
 /* Don't get link errors because mkdir is redefined to rpl_mkdir.  */
 #undef mkdir
 
index 93b3b86bd5757859923bd32aa0bc8de2890da946..6f91bd99e5f45a425697903911512bc144781151 100644 (file)
@@ -123,7 +123,7 @@ AC_DEFUN([gl_FUNC_GETCWD],
   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") ;;
+    "no"|"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