changeset 8789:81a2817b99b2

(etags_getcwd): Use getcwd if available.
author Karl Heuer <kwzh@gnu.org>
date Fri, 16 Sep 1994 21:16:20 +0000
parents 4577387fa731
children af08b3d2e30f
files lib-src/etags.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/etags.c	Fri Sep 16 20:08:33 1994 +0000
+++ b/lib-src/etags.c	Fri Sep 16 21:16:20 1994 +0000
@@ -3148,13 +3148,21 @@
 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 @@
       bufsize *= 2;
 
     } while (buf[strlen (buf) - 1] != '\n');
+#endif
 
   buf[strlen (buf) - 1] = '\0';
   return buf;