From: Karl Heuer Date: Fri, 16 Sep 1994 21:16:20 +0000 (+0000) Subject: (etags_getcwd): Use getcwd if available. X-Git-Tag: emacs-19.34~7065 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5e9c82960a05c492b144bd1c06931748ecf4e0f3;p=emacs.git (etags_getcwd): Use getcwd if available. --- diff --git a/lib-src/etags.c b/lib-src/etags.c index e640fcdfeee..f4fea9ff1dd 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -3148,13 +3148,21 @@ etags_getcwd () char * etags_getcwd () { - FILE *pipe; char *buf; int bufsize = 256; +#ifdef HAVE_GETCWD do { buf = xnew (bufsize, char); + bufsize *= 2; + } + while (getcwd (buf, bufsize / 2) == NULL); +#else + do + { + FILE *pipe; + buf = xnew (bufsize, char); pipe = (FILE *) popen ("pwd 2>/dev/null", "r"); if (pipe == NULL) @@ -3172,6 +3180,7 @@ etags_getcwd () bufsize *= 2; } while (buf[strlen (buf) - 1] != '\n'); +#endif buf[strlen (buf) - 1] = '\0'; return buf;