/* getpwd.c - get the working directory */
#include "config.h"
-
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#ifndef errno
-extern int errno;
-#endif
+#include "system.h"
/* Virtually every UN*X system now in common use (except for pre-4.3-tahoe
BSD systems) now provides getcwd as called for by POSIX. Allow for
the few exceptions to the general rule here. */
-#if !(defined (POSIX) || defined (USG) || defined (VMS))
-#include <sys/param.h>
-extern char *getwd ();
+#if !(defined (POSIX) || defined (USG) || defined (VMS)) || defined (HAVE_GETWD)
#define getcwd(buf,len) getwd(buf)
#ifdef MAXPATHLEN
#define GUESSPATHLEN (MAXPATHLEN + 1)
#define GUESSPATHLEN 100
#endif
#else /* (defined (USG) || defined (VMS)) */
-extern char *getcwd ();
/* We actually use this as a starting point, not a limit. */
#define GUESSPATHLEN 100
#endif /* (defined (USG) || defined (VMS)) */
-#ifdef WINNT
-#include <direct.h>
-#endif
-
-char *getenv ();
-char *xmalloc ();
-#ifndef VMS
+#if !(defined (VMS) || (defined(_WIN32) && !defined(__CYGWIN__)))
/* Get the working directory. Use the PWD environment variable if it's
set correctly, since this is faster and gives more uniform answers
return p;
}
-#else /* VMS */
+#else /* VMS || _WIN32 && !__CYGWIN__ */
#ifndef MAXPATHLEN
#define MAXPATHLEN 255
{
static char *pwd = 0;
- if (!pwd) pwd = getcwd (xmalloc (MAXPATHLEN+1), MAXPATHLEN+1);
+ if (!pwd)
+ pwd = getcwd (xmalloc (MAXPATHLEN + 1), MAXPATHLEN + 1
+#ifdef VMS
+ , 0
+#endif
+ );
return pwd;
}
-#endif /* VMS */
+#endif /* VMS || _WIN32 && !__CYGWIN__ */