]> git.eshelyaron.com Git - emacs.git/commitdiff
(etags_getcwd): Use getcwd if available.
authorKarl Heuer <kwzh@gnu.org>
Fri, 16 Sep 1994 21:16:20 +0000 (21:16 +0000)
committerKarl Heuer <kwzh@gnu.org>
Fri, 16 Sep 1994 21:16:20 +0000 (21:16 +0000)
lib-src/etags.c

index e640fcdfeee0824cb8fd26b3f6286873965fd1c9..f4fea9ff1dd1352b5e1c203de4c040e1c9f7232e 100644 (file)
@@ -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;