Commit 5e9c8296 authored by Karl Heuer's avatar Karl Heuer
Browse files

(etags_getcwd): Use getcwd if available.

parent 11ec7041
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment