X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fgetcwd.c;h=f8101613f2c8eb01f50364eb87176039160be5d4;hb=effe7821374f8b7e22e9de3df9cc4e5f285712bd;hp=f09fc3e8dd7cef69f6b168c3021d016682d27f19;hpb=6310fc6d3e3f086e825cbd6f53950fbdc1ac7b42;p=gnulib.git diff --git a/lib/getcwd.c b/lib/getcwd.c index f09fc3e8d..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 @@ -146,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