From: Bruno Haible Date: Sat, 14 Apr 2012 20:27:12 +0000 (+0200) Subject: stat: Bypass buggy override in mingw64. X-Git-Tag: v0.1~745 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=82781cc8ba8aa1831f3fce91ce14b8538f5319f0;p=gnulib.git stat: Bypass buggy override in mingw64. * m4/stat.m4 (gl_FUNC_STAT): Update comments. * lib/stat.c (stat) [mingw64]: Define to _stat. * doc/posix-functions/stat.texi: Mention mingw64 bug. --- diff --git a/ChangeLog b/ChangeLog index 62cd270cb..f2e4b2314 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2012-04-14 Bruno Haible + stat: Bypass buggy override in mingw64. + * m4/stat.m4 (gl_FUNC_STAT): Update comments. + * lib/stat.c (stat) [mingw64]: Define to _stat. + * doc/posix-functions/stat.texi: Mention mingw64 bug. + +2012-04-14 Bruno Haible + pathmax: Fix compilation error on MSVC 9. * modules/pathmax (Depends-on): Add unistd. diff --git a/doc/posix-functions/stat.texi b/doc/posix-functions/stat.texi index f92d3a685..33af95d5b 100644 --- a/doc/posix-functions/stat.texi +++ b/doc/posix-functions/stat.texi @@ -15,7 +15,7 @@ report the size of files or block devices larger than 2 GB. @item On some platforms, @code{stat("link-to-file/",buf)} succeeds instead of failing with @code{ENOTDIR}. -FreeBSD 7.2, AIX 7.1, Solaris 9. +FreeBSD 7.2, AIX 7.1, Solaris 9, mingw64. @item On some platforms, @code{stat(".",buf)} and @code{stat("./",buf)} give different results: diff --git a/lib/stat.c b/lib/stat.c index 9ea53c1c0..29acd9a76 100644 --- a/lib/stat.c +++ b/lib/stat.c @@ -27,6 +27,15 @@ #include #undef __need_system_sys_stat_h +#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \ + && REPLACE_FUNC_STAT_FILE +/* mingw64 has a broken stat() function, based on _stat(), in libmingwex.a. + Bypass it. */ +# define stat _stat +# define REPLACE_FUNC_STAT_DIR 1 +# undef REPLACE_FUNC_STAT_FILE +#endif + static inline int orig_stat (const char *filename, struct stat *buf) { diff --git a/m4/stat.m4 b/m4/stat.m4 index d67dbcdec..1e0d0dd72 100644 --- a/m4/stat.m4 +++ b/m4/stat.m4 @@ -1,4 +1,4 @@ -# serial 8 +# serial 9 # Copyright (C) 2009-2012 Free Software Foundation, Inc. # @@ -23,8 +23,9 @@ AC_DEFUN([gl_FUNC_STAT], mingw*) gl_cv_func_stat_dir_slash="guessing no";; *) gl_cv_func_stat_dir_slash="guessing yes";; esac])]) - dnl AIX 7.1, Solaris 9 mistakenly succeed on stat("file/") - dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/") + dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/"). + dnl (For mingw, this is due to a broken stat() override in libmingwex.a.) + dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/"). AC_CACHE_CHECK([whether stat handles trailing slashes on files], [gl_cv_func_stat_file_slash], [touch conftest.tmp