summaryrefslogtreecommitdiff
path: root/lib-src
diff options
context:
space:
mode:
authorKarl Heuer <kwzh@gnu.org>1994-09-16 21:16:20 +0000
committerKarl Heuer <kwzh@gnu.org>1994-09-16 21:16:20 +0000
commit2bcabc2597b28d7e20bd635c5a20b8d597fa39bd (patch)
tree55a55a5bed52f9a024286281b5f3cf342ae961b2 /lib-src
parent2edc171118777f84f29a499b414cbce1ecde8661 (diff)
downloademacs-2bcabc2597b28d7e20bd635c5a20b8d597fa39bd.tar.gz
(etags_getcwd): Use getcwd if available.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c11
1 files changed, 10 insertions, 1 deletions
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;