Mercurial > hg > octave-lojdl > gnulib-hg
changeset 12064:e9a820d62f5a
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>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Wed, 23 Sep 2009 14:13:00 -0600 |
parents | 6b9a61fbff48 |
children | fbde8fb7f644 |
files | ChangeLog lib/lstat.c m4/lstat.m4 m4/sys_stat_h.m4 |
diffstat | 4 files changed, 34 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2009-09-23 Eric Blake <ebb9@byu.net> + lstat: avoid mingw compilation error + * 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. + link: fix test failure on Solaris 9 * lib/link.c (rpl_link): Don't assume link will catch bogus trailing slash on source.
--- 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 @@ } /* 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 @@ } return stat (file, sbuf); } + +#endif /* HAVE_LSTAT */
--- a/m4/lstat.m4 +++ b/m4/lstat.m4 @@ -1,4 +1,4 @@ -# serial 19 +# serial 20 # Copyright (C) 1997-2001, 2003-2009 Free Software Foundation, Inc. # @@ -12,15 +12,17 @@ [ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) dnl If lstat does not exist, the replacement <sys/stat.h> does - dnl "#define lstat stat", and lstat.c does not need to be compiled. + dnl "#define lstat stat", and lstat.c is a no-op. AC_CHECK_FUNCS_ONCE([lstat]) if test $ac_cv_func_lstat = yes; then - AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK - dnl Note: AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK does AC_LIBOBJ([lstat]). + AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then + dnl Note: AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK does AC_LIBOBJ([lstat]). REPLACE_LSTAT=1 fi # Prerequisites of lib/lstat.c. AC_REQUIRE([AC_C_INLINE]) + else + HAVE_LSTAT=0 fi ])
--- a/m4/sys_stat_h.m4 +++ b/m4/sys_stat_h.m4 @@ -1,4 +1,4 @@ -# sys_stat_h.m4 serial 16 -*- Autoconf -*- +# sys_stat_h.m4 serial 17 -*- Autoconf -*- dnl Copyright (C) 2006-2009 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,16 +11,6 @@ [ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) - dnl Check for lstat. Systems that lack it (mingw) also lack symlinks, so - dnl stat is a good replacement. - AC_CHECK_FUNCS_ONCE([lstat]) - if test $ac_cv_func_lstat = yes; then - HAVE_LSTAT=1 - else - HAVE_LSTAT=0 - fi - AC_SUBST([HAVE_LSTAT]) - dnl For the mkdir substitute. AC_REQUIRE([AC_C_INLINE]) @@ -61,6 +51,7 @@ HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT]) HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT]) HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD]) + HAVE_LSTAT=1; AC_SUBST([HAVE_LSTAT]) HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT]) HAVE_MKFIFOAT=1; AC_SUBST([HAVE_MKFIFOAT]) HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT])