+2020-09-16 Bruno Haible <bruno@clisp.org>
+
+ stat, fstat: Fix when compiling for versions older than Windows Vista.
+ Reported by Eli Zaretskii <eliz@gnu.org> in
+ <https://lists.gnu.org/archive/html/bug-gnulib/2020-09/msg00027.html>.
+ * lib/stat-w32.c: Include <sdkddkver.h>. Test the value of _WIN32_WINNT
+ that was originally set before we redefined it.
+ * m4/stat.m4 (gl_PREREQ_STAT_W32): New macro.
+ (gl_PREREQ_STAT): Require it.
+ * m4/fstat.m4 (gl_PREREQ_FSTAT): Likewise.
+
2020-09-15 Paul Eggert <eggert@cs.ucla.edu>
dfa: remove dfa-heap-overrun workaround
#if defined _WIN32 && ! defined __CYGWIN__
-/* Ensure that <windows.h> defines FILE_ID_INFO. */
-#if !defined _WIN32_WINNT || (_WIN32_WINNT < _WIN32_WINNT_WIN8)
-# undef _WIN32_WINNT
-# define _WIN32_WINNT _WIN32_WINNT_WIN8
+/* Attempt to make <windows.h> define FILE_ID_INFO.
+ But ensure that the redefinition of _WIN32_WINNT does not make us assume
+ Windows Vista or newer when building for an older version of Windows. */
+#if HAVE_SDKDDKVER_H
+# include <sdkddkver.h>
+# if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+# define WIN32_ASSUME_VISTA 1
+# else
+# define WIN32_ASSUME_VISTA 0
+# endif
+# if !defined _WIN32_WINNT || (_WIN32_WINNT < _WIN32_WINNT_WIN8)
+# undef _WIN32_WINNT
+# define _WIN32_WINNT _WIN32_WINNT_WIN8
+# endif
+#else
+# define WIN32_ASSUME_VISTA (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
#endif
#include <sys/types.h>
#undef GetFinalPathNameByHandle
#define GetFinalPathNameByHandle GetFinalPathNameByHandleA
-#if !(_WIN32_WINNT >= _WIN32_WINNT_VISTA)
+#if !WIN32_ASSUME_VISTA
/* Avoid warnings from gcc -Wcast-function-type. */
# define GetProcAddress \
DWORD type = GetFileType (h);
if (type == FILE_TYPE_DISK)
{
-#if !(_WIN32_WINNT >= _WIN32_WINNT_VISTA)
+#if !WIN32_ASSUME_VISTA
if (!initialized)
initialize ();
#endif
-# fstat.m4 serial 6
+# fstat.m4 serial 7
dnl Copyright (C) 2011-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
# Prerequisites of lib/fstat.c and lib/stat-w32.c.
AC_DEFUN([gl_PREREQ_FSTAT], [
AC_REQUIRE([gl_HEADER_SYS_STAT_H])
+ AC_REQUIRE([gl_PREREQ_STAT_W32])
:
])
-# serial 16
+# serial 17
# Copyright (C) 2009-2020 Free Software Foundation, Inc.
#
# Prerequisites of lib/stat.c and lib/stat-w32.c.
AC_DEFUN([gl_PREREQ_STAT], [
AC_REQUIRE([gl_HEADER_SYS_STAT_H])
+ AC_REQUIRE([gl_PREREQ_STAT_W32])
:
])
+
+# Prerequisites of lib/stat-w32.c.
+AC_DEFUN([gl_PREREQ_STAT_W32], [
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ case "$host_os" in
+ mingw*)
+ AC_CHECK_HEADERS([sdkddkver.h])
+ ;;
+ esac
+])