From 5e9c82960a05c492b144bd1c06931748ecf4e0f3 Mon Sep 17 00:00:00 2001 From: Karl Heuer Date: Fri, 16 Sep 1994 21:16:20 +0000 Subject: [PATCH] (etags_getcwd): Use getcwd if available. --- lib-src/etags.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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; -- 2.39.5