|
version 1.1, 2012/05/29 09:29:44
|
version 1.1.1.2, 2021/03/17 13:38:46
|
|
Line 1
|
Line 1
|
| # serial 8 | # serial 15 |
| |
|
| # Copyright (C) 2009-2011 Free Software Foundation, Inc. | # Copyright (C) 2009-2019 Free Software Foundation, Inc. |
| # |
# |
| # This file is free software; the Free Software Foundation |
# This file is free software; the Free Software Foundation |
| # gives unlimited permission to copy and/or distribute it, |
# gives unlimited permission to copy and/or distribute it, |
|
Line 8
|
Line 8
|
| |
|
| AC_DEFUN([gl_FUNC_STAT], |
AC_DEFUN([gl_FUNC_STAT], |
| [ |
[ |
| AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | AC_REQUIRE([AC_CANONICAL_HOST]) |
| AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) |
AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) |
| AC_CHECK_FUNCS_ONCE([lstat]) |
AC_CHECK_FUNCS_ONCE([lstat]) |
| dnl mingw is the only known platform where stat(".") and stat("./") differ | case "$host_os" in |
| AC_CACHE_CHECK([whether stat handles trailing slashes on directories], | mingw*) |
| [gl_cv_func_stat_dir_slash], | dnl On this platform, the original stat() returns st_atime, st_mtime, |
| [AC_RUN_IFELSE( | dnl st_ctime values that are affected by the time zone. |
| [AC_LANG_PROGRAM( | REPLACE_STAT=1 |
| [[#include <sys/stat.h> | ;; |
| ]], [[struct stat st; return stat (".", &st) != stat ("./", &st);]])], | *) |
| [gl_cv_func_stat_dir_slash=yes], [gl_cv_func_stat_dir_slash=no], | dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/"). |
| [case $host_os in | dnl (For mingw, this is due to a broken stat() override in libmingwex.a.) |
| mingw*) gl_cv_func_stat_dir_slash="guessing no";; | dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/"). |
| *) gl_cv_func_stat_dir_slash="guessing yes";; | AC_CACHE_CHECK([whether stat handles trailing slashes on files], |
| esac])]) | [gl_cv_func_stat_file_slash], |
| dnl AIX 7.1, Solaris 9 mistakenly succeed on stat("file/") | [touch conftest.tmp |
| dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/") | # Assume that if we have lstat, we can also check symlinks. |
| AC_CACHE_CHECK([whether stat handles trailing slashes on files], | if test $ac_cv_func_lstat = yes; then |
| [gl_cv_func_stat_file_slash], | ln -s conftest.tmp conftest.lnk |
| [touch conftest.tmp | fi |
| # Assume that if we have lstat, we can also check symlinks. | AC_RUN_IFELSE( |
| if test $ac_cv_func_lstat = yes; then | [AC_LANG_PROGRAM( |
| ln -s conftest.tmp conftest.lnk | [[#include <sys/stat.h> |
| fi | |
| AC_RUN_IFELSE( | |
| [AC_LANG_PROGRAM( | |
| [[#include <sys/stat.h> | |
| ]], [[int result = 0; |
]], [[int result = 0; |
| struct stat st; | struct stat st; |
| if (!stat ("conftest.tmp/", &st)) | if (!stat ("conftest.tmp/", &st)) |
| result |= 1; | result |= 1; |
| #if HAVE_LSTAT |
#if HAVE_LSTAT |
| if (!stat ("conftest.lnk/", &st)) | if (!stat ("conftest.lnk/", &st)) |
| result |= 2; | result |= 2; |
| #endif |
#endif |
| return result; | return result; |
| ]])], | ]])], |
| [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no], | [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no], |
| [gl_cv_func_stat_file_slash="guessing no"]) | [case "$host_os" in |
| rm -f conftest.tmp conftest.lnk]) | # Guess yes on Linux systems. |
| case $gl_cv_func_stat_dir_slash in | linux-* | linux) gl_cv_func_stat_file_slash="guessing yes" ;; |
| *no) REPLACE_STAT=1 | # Guess yes on glibc systems. |
| AC_DEFINE([REPLACE_FUNC_STAT_DIR], [1], [Define to 1 if stat needs | *-gnu* | gnu*) gl_cv_func_stat_file_slash="guessing yes" ;; |
| help when passed a directory name with a trailing slash]);; | # If we don't know, assume the worst. |
| | *) gl_cv_func_stat_file_slash="guessing no" ;; |
| | esac |
| | ]) |
| | rm -f conftest.tmp conftest.lnk]) |
| | case $gl_cv_func_stat_file_slash in |
| | *no) |
| | REPLACE_STAT=1 |
| | AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs |
| | help when passed a file name with a trailing slash]);; |
| | esac |
| | case $host_os in |
| | dnl Solaris stat can return a negative tv_nsec. |
| | solaris*) |
| | REPLACE_FSTAT=1 ;; |
| | esac |
| | ;; |
| esac |
esac |
| case $gl_cv_func_stat_file_slash in |
|
| *no) REPLACE_STAT=1 |
|
| AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs |
|
| help when passed a file name with a trailing slash]);; |
|
| esac |
|
| ]) |
]) |
| |
|
| # Prerequisites of lib/stat.c. | # Prerequisites of lib/stat.c and lib/stat-w32.c. |
| AC_DEFUN([gl_PREREQ_STAT], | AC_DEFUN([gl_PREREQ_STAT], [ |
| [ | AC_REQUIRE([gl_HEADER_SYS_STAT_H]) |
| AC_REQUIRE([AC_C_INLINE]) | |
| : |
: |
| ]) |
]) |