#undef getcwd only after *all* included header files.
authorJim Meyering <jim@meyering.net>
Fri, 7 Mar 2003 10:13:55 +0000 (10:13 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 7 Mar 2003 10:13:55 +0000 (10:13 +0000)
Declare getcwd unconditionally.

lib/getcwd.c

index e3a73f0..2968a6e 100644 (file)
 
 #include <config.h>
 
-/* Undefine getcwd here so any prototype is not redefined to be a
-   prototype for rpl_getcwd.  */
-#undef getcwd
-
 #include <stdlib.h>
 #include <string.h>
 
@@ -43,6 +39,14 @@ extern int errno;
 
 #define MAX_SAFE_LEN (PATH_MAX - 1 - KLUDGE_POSIX_NAME_MAX - 1)
 
+/* Undefine getcwd here, as near the use as possible, in case any
+   of the files included above define it to rpl_getcwd.  */
+#undef getcwd
+
+/* Any declaration of getcwd from headers included above has
+   been changed to a declaration of rpl_getcwd.  Declare it here.  */
+extern char *getcwd (char *buf, size_t size);
+
 /* This is a wrapper for getcwd.
    Some implementations (at least GNU libc 2.3.1 + linux-2.4.20) return
    non-NULL for a working directory name longer than PATH_MAX, yet the