X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fgetcwd.c;h=f8101613f2c8eb01f50364eb87176039160be5d4;hb=effe7821374f8b7e22e9de3df9cc4e5f285712bd;hp=e52af1856f0ce06717ad860b7649581b6be38283;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/lib/getcwd.c b/lib/getcwd.c index e52af1856..f8101613f 100644 --- a/lib/getcwd.c +++ b/lib/getcwd.c @@ -27,9 +27,10 @@ #include /* For AT_FDCWD on Solaris 9. */ -/* If this host provides the openat function, then enable - code below to make getcwd more efficient and robust. */ -#ifdef HAVE_OPENAT +/* If this host provides the openat function or if we're using the + gnulib replacement function, then enable code below to make getcwd + more efficient and robust. */ +#if defined HAVE_OPENAT || defined GNULIB_OPENAT # define HAVE_OPENAT_SUPPORT 1 #else # define HAVE_OPENAT_SUPPORT 0 @@ -57,8 +58,6 @@ # endif #endif -#include - #ifndef MAX # define MAX(a, b) ((a) < (b) ? (b) : (a)) #endif @@ -66,12 +65,12 @@ # define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif +#include "pathmax.h" + +/* In this file, PATH_MAX only serves as a threshold for choosing among two + algorithms. */ #ifndef PATH_MAX -# ifdef MAXPATHLEN -# define PATH_MAX MAXPATHLEN -# else -# define PATH_MAX 1024 -# endif +# define PATH_MAX 8192 #endif #if D_INO_IN_DIRENT @@ -148,7 +147,7 @@ __getcwd (char *buf, size_t size) # undef getcwd dir = getcwd (buf, size); - if (dir) + if (dir || (size && errno == ERANGE)) return dir; /* Solaris getcwd (NULL, 0) fails with errno == EINVAL, but it has