|
Packit Service |
4684c1 |
# open-slash.m4 serial 1
|
|
Packit Service |
4684c1 |
dnl Copyright (C) 2007-2020 Free Software Foundation, Inc.
|
|
Packit Service |
4684c1 |
dnl This file is free software; the Free Software Foundation
|
|
Packit Service |
4684c1 |
dnl gives unlimited permission to copy and/or distribute it,
|
|
Packit Service |
4684c1 |
dnl with or without modifications, as long as this notice is preserved.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
dnl Tests whether open() and creat() recognize a trailing slash.
|
|
Packit Service |
4684c1 |
dnl Sets gl_cv_func_open_slash.
|
|
Packit Service |
4684c1 |
AC_DEFUN([gl_OPEN_TRAILING_SLASH_BUG],
|
|
Packit Service |
4684c1 |
[
|
|
Packit Service |
4684c1 |
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
|
Packit Service |
4684c1 |
dnl open("foo/") should not create a file when the file name has a
|
|
Packit Service |
4684c1 |
dnl trailing slash. FreeBSD only has the problem on symlinks.
|
|
Packit Service |
4684c1 |
AC_CHECK_FUNCS_ONCE([lstat])
|
|
Packit Service |
4684c1 |
AC_CACHE_CHECK([whether open recognizes a trailing slash],
|
|
Packit Service |
4684c1 |
[gl_cv_func_open_slash],
|
|
Packit Service |
4684c1 |
[# Assume that if we have lstat, we can also check symlinks.
|
|
Packit Service |
4684c1 |
if test $ac_cv_func_lstat = yes; then
|
|
Packit Service |
4684c1 |
touch conftest.tmp
|
|
Packit Service |
4684c1 |
ln -s conftest.tmp conftest.lnk
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
AC_RUN_IFELSE(
|
|
Packit Service |
4684c1 |
[AC_LANG_SOURCE([[
|
|
Packit Service |
4684c1 |
#include <fcntl.h>
|
|
Packit Service |
4684c1 |
#if HAVE_UNISTD_H
|
|
Packit Service |
4684c1 |
# include <unistd.h>
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
int main ()
|
|
Packit Service |
4684c1 |
{
|
|
Packit Service |
4684c1 |
int result = 0;
|
|
Packit Service |
4684c1 |
#if HAVE_LSTAT
|
|
Packit Service |
4684c1 |
if (open ("conftest.lnk/", O_RDONLY) != -1)
|
|
Packit Service |
4684c1 |
result |= 1;
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
if (open ("conftest.sl/", O_CREAT, 0600) >= 0)
|
|
Packit Service |
4684c1 |
result |= 2;
|
|
Packit Service |
4684c1 |
return result;
|
|
Packit Service |
4684c1 |
}]])],
|
|
Packit Service |
4684c1 |
[gl_cv_func_open_slash=yes],
|
|
Packit Service |
4684c1 |
[gl_cv_func_open_slash=no],
|
|
Packit Service |
4684c1 |
[
|
|
Packit Service |
4684c1 |
changequote(,)dnl
|
|
Packit Service |
4684c1 |
case "$host_os" in
|
|
Packit Service |
4684c1 |
freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
|
|
Packit Service |
4684c1 |
gl_cv_func_open_slash="guessing no" ;;
|
|
Packit Service |
4684c1 |
*)
|
|
Packit Service |
4684c1 |
gl_cv_func_open_slash="guessing yes" ;;
|
|
Packit Service |
4684c1 |
esac
|
|
Packit Service |
4684c1 |
changequote([,])dnl
|
|
Packit Service |
4684c1 |
])
|
|
Packit Service |
4684c1 |
rm -f conftest.sl conftest.tmp conftest.lnk
|
|
Packit Service |
4684c1 |
])
|
|
Packit Service |
4684c1 |
case "$gl_cv_func_open_slash" in
|
|
Packit Service |
4684c1 |
*no)
|
|
Packit Service |
4684c1 |
AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
|
|
Packit Service |
4684c1 |
[Define to 1 if open() fails to recognize a trailing slash.])
|
|
Packit Service |
4684c1 |
;;
|
|
Packit Service |
4684c1 |
esac
|
|
Packit Service |
4684c1 |
])
|