diff options
author | Bruno Haible <bruno@clisp.org> | 2021-01-20 09:14:18 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2021-01-20 09:21:19 +0100 |
commit | 77ca5f1df13067a34c36438635b6f97fc7f49806 (patch) | |
tree | 6d6f2c3cc8e96b4b154f136c86a45725579e7084 /m4 | |
parent | fb0e2ad380d980bd9dcd88da7c748dabb532c809 (diff) | |
download | gnulib-77ca5f1df13067a34c36438635b6f97fc7f49806.tar.gz |
canonicalize-lgpl: Work around a Cygwin bug.
* m4/canonicalize.m4 (gl_FUNC_REALPATH_WORKS): Test for lstat. Add a
test case that involves a symbolic link to an existing file.
* doc/posix-functions/realpath.texi: Mention the Cygwin bug.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/canonicalize.m4 | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4 index 6821c70e6f..0dfb2da9a6 100644 --- a/m4/canonicalize.m4 +++ b/m4/canonicalize.m4 @@ -1,4 +1,4 @@ -# canonicalize.m4 serial 36 +# canonicalize.m4 serial 37 dnl Copyright (C) 2003-2007, 2009-2021 Free Software Foundation, Inc. @@ -78,15 +78,20 @@ AC_DEFUN([gl_CANONICALIZE_LGPL_SEPARATE], # so is the latter. AC_DEFUN([gl_FUNC_REALPATH_WORKS], [ - AC_CHECK_FUNCS_ONCE([realpath]) + AC_CHECK_FUNCS_ONCE([realpath lstat]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([whether realpath works], [gl_cv_func_realpath_works], [ rm -rf conftest.a conftest.d touch conftest.a + # Assume that if we have lstat, we can also check symlinks. + if test $ac_cv_func_lstat = yes; then + ln -s conftest.a conftest.l + fi mkdir conftest.d AC_RUN_IFELSE([ AC_LANG_PROGRAM([[ ]GL_NOCRASH[ + #include <errno.h> #include <stdlib.h> #include <string.h> ]], [[ @@ -98,17 +103,27 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS], result |= 1; free (name); } + /* This test fails on older versions of Cygwin. */ { char *name = realpath ("conftest.b/../conftest.a", NULL); if (name != NULL) result |= 2; free (name); } + /* This test fails on Cygwin 2.9. */ + #if HAVE_LSTAT + { + char *name = realpath ("conftest.l/../conftest.a", NULL); + if (name != NULL || errno != ENOTDIR) + result |= 4; + free (name); + } + #endif /* This test fails on Mac OS X 10.13, OpenBSD 6.0. */ { char *name = realpath ("conftest.a/", NULL); if (name != NULL) - result |= 4; + result |= 8; free (name); } /* This test fails on AIX 7, Solaris 10. */ @@ -116,7 +131,7 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS], char *name1 = realpath (".", NULL); char *name2 = realpath ("conftest.d//./..", NULL); if (! name1 || ! name2 || strcmp (name1, name2)) - result |= 8; + result |= 16; free (name1); free (name2); } @@ -127,7 +142,7 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS], { char *name = realpath ("//", NULL); if (! name || strcmp (name, "/")) - result |= 16; + result |= 32; free (name); } #endif @@ -136,7 +151,7 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS], ], [gl_cv_func_realpath_works=yes], [case $? in - 16) gl_cv_func_realpath_works=nearly ;; + 32) gl_cv_func_realpath_works=nearly ;; *) gl_cv_func_realpath_works=no ;; esac ], @@ -145,13 +160,15 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS], *-gnu* | gnu*) gl_cv_func_realpath_works="guessing yes" ;; # Guess 'nearly' on musl systems. *-musl*) gl_cv_func_realpath_works="guessing nearly" ;; + # Guess no on Cygwin. + cygwin*) gl_cv_func_realpath_works="guessing no" ;; # Guess no on native Windows. mingw*) gl_cv_func_realpath_works="guessing no" ;; # If we don't know, obey --enable-cross-guesses. *) gl_cv_func_realpath_works="$gl_cross_guess_normal" ;; esac ]) - rm -rf conftest.a conftest.d + rm -rf conftest.a conftest.l conftest.d ]) case "$gl_cv_func_realpath_works" in *yes) |