summaryrefslogtreecommitdiff
path: root/lib/lstat.c
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-09-23 14:13:00 -0600
committerEric Blake <ebb9@byu.net>2009-09-23 19:34:33 -0600
commite97114feaa74c5f0516d76dcde67601e26462e95 (patch)
treecfb175adad6f1d761299014435dee5a6951a05f4 /lib/lstat.c
parentc5ff417604d203d72360908d8daafefeb4f36812 (diff)
downloadgnulib-e97114feaa74c5f0516d76dcde67601e26462e95.tar.gz
lstat: avoid mingw compilation error
The openat module required lstat, but then repeated the checks for whether lstat worked. When cross-compiling to mingw, this led to a wrong answer and tried compiling lstat.c, even though it was not necessary, with a result of a compiler warning about undeclared lstat. * m4/lstat.m4 (gl_FUNC_LSTAT): Avoid duplicate calls to AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK, and deal with missing lstat ourselves. * lib/lstat.c [!HAVE_LSTAT]: Do nothing if <sys/stat.h> override was adequate. * m4/sys_stat_h.m4 (gl_HEADER_SYS_STAT_H): Let lstat module handle the checks for lstat. (gl_SYS_STAT_H_DEFAULTS): Set default for HAVE_LSTAT. Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'lib/lstat.c')
-rw-r--r--lib/lstat.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/lstat.c b/lib/lstat.c
index a05f6747d3..27a0cb5103 100644
--- a/lib/lstat.c
+++ b/lib/lstat.c
@@ -20,11 +20,18 @@
#include <config.h>
+#if !HAVE_LSTAT
+/* On systems that lack symlinks, our replacement <sys/stat.h> already
+ defined lstat as stat, so there is nothing further to do other than
+ avoid an empty file. */
+typedef int dummy;
+#else /* HAVE_LSTAT */
+
/* Get the original definition of lstat. It might be defined as a macro. */
-#define __need_system_sys_stat_h
-#include <sys/types.h>
-#include <sys/stat.h>
-#undef __need_system_sys_stat_h
+# define __need_system_sys_stat_h
+# include <sys/types.h>
+# include <sys/stat.h>
+# undef __need_system_sys_stat_h
static inline int
orig_lstat (const char *filename, struct stat *buf)
@@ -33,10 +40,10 @@ orig_lstat (const char *filename, struct stat *buf)
}
/* Specification. */
-#include <sys/stat.h>
+# include <sys/stat.h>
-#include <string.h>
-#include <errno.h>
+# include <string.h>
+# include <errno.h>
/* lstat works differently on Linux and Solaris systems. POSIX (see
`pathname resolution' in the glossary) requires that programs like
@@ -81,3 +88,5 @@ rpl_lstat (const char *file, struct stat *sbuf)
}
return stat (file, sbuf);
}
+
+#endif /* HAVE_LSTAT */