(etags_getcwd): Use getcwd if available.

This commit is contained in:
Karl Heuer 1994-09-16 21:16:20 +00:00
parent 11ec70418c
commit 5e9c82960a

View 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;