stat: Bypass buggy override in mingw64.
authorBruno Haible <bruno@clisp.org>
Sat, 14 Apr 2012 20:27:12 +0000 (22:27 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 14 Apr 2012 20:27:12 +0000 (22:27 +0200)
* m4/stat.m4 (gl_FUNC_STAT): Update comments.
* lib/stat.c (stat) [mingw64]: Define to _stat.
* doc/posix-functions/stat.texi: Mention mingw64 bug.

ChangeLog
doc/posix-functions/stat.texi
lib/stat.c
m4/stat.m4

index 62cd270..f2e4b23 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2012-04-14  Bruno Haible  <bruno@clisp.org>
 
+       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  <bruno@clisp.org>
+
        pathmax: Fix compilation error on MSVC 9.
        * modules/pathmax (Depends-on): Add unistd.
 
index f92d3a6..33af95d 100644 (file)
@@ -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:
index 9ea53c1..29acd9a 100644 (file)
 #include <sys/stat.h>
 #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)
 {
index d67dbcd..1e0d0dd 100644 (file)
@@ -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