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)
bufsize *= 2;
} while (buf[strlen (buf) - 1] != '\n');
+#endif
buf[strlen (buf) - 1] = '\0';
return buf;