(etags_getcwd): Use getcwd if available.
This commit is contained in:
parent
11ec70418c
commit
5e9c82960a
1 changed files with 10 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue