summaryrefslogtreecommitdiffstats
path: root/gl/m4/open.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/open.m4')
-rw-r--r--gl/m4/open.m426
1 files changed, 17 insertions, 9 deletions
diff --git a/gl/m4/open.m4 b/gl/m4/open.m4
index 6e286c9..d705b3a 100644
--- a/gl/m4/open.m4
+++ b/gl/m4/open.m4
@@ -1,5 +1,5 @@
1# open.m4 serial 5 1# open.m4 serial 8
2dnl Copyright (C) 2007-2009 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -13,10 +13,15 @@ AC_DEFUN([gl_FUNC_OPEN],
13 ;; 13 ;;
14 *) 14 *)
15 dnl open("foo/") should not create a file when the file name has a 15 dnl open("foo/") should not create a file when the file name has a
16 dnl trailing slash. 16 dnl trailing slash. FreeBSD only has the problem on symlinks.
17 AC_CHECK_FUNCS_ONCE([lstat])
17 AC_CACHE_CHECK([whether open recognizes a trailing slash], 18 AC_CACHE_CHECK([whether open recognizes a trailing slash],
18 [gl_cv_func_open_slash], 19 [gl_cv_func_open_slash],
19 [ 20 [# Assume that if we have lstat, we can also check symlinks.
21 if test $ac_cv_func_lstat = yes; then
22 touch conftest.tmp
23 ln -s conftest.tmp conftest.lnk
24 fi
20 AC_TRY_RUN([ 25 AC_TRY_RUN([
21#include <fcntl.h> 26#include <fcntl.h>
22#if HAVE_UNISTD_H 27#if HAVE_UNISTD_H
@@ -24,18 +29,22 @@ AC_DEFUN([gl_FUNC_OPEN],
24#endif 29#endif
25int main () 30int main ()
26{ 31{
32#if HAVE_LSTAT
33 if (open ("conftest.lnk/", O_RDONLY) != -1) return 2;
34#endif
27 return open ("conftest.sl/", O_CREAT, 0600) >= 0; 35 return open ("conftest.sl/", O_CREAT, 0600) >= 0;
28}], [gl_cv_func_open_slash=yes], [gl_cv_func_open_slash=no], 36}], [gl_cv_func_open_slash=yes], [gl_cv_func_open_slash=no],
29 [ 37 [
30changequote(,)dnl 38changequote(,)dnl
31 case "$host_os" in 39 case "$host_os" in
40 freebsd*) gl_cv_func_open_slash="guessing no" ;;
32 solaris2.[0-9]*) gl_cv_func_open_slash="guessing no" ;; 41 solaris2.[0-9]*) gl_cv_func_open_slash="guessing no" ;;
33 hpux*) gl_cv_func_open_slash="guessing no" ;; 42 hpux*) gl_cv_func_open_slash="guessing no" ;;
34 *) gl_cv_func_open_slash="guessing yes" ;; 43 *) gl_cv_func_open_slash="guessing yes" ;;
35 esac 44 esac
36changequote([,])dnl 45changequote([,])dnl
37 ]) 46 ])
38 rm -f conftest.sl 47 rm -f conftest.sl conftest.tmp conftest.lnk
39 ]) 48 ])
40 case "$gl_cv_func_open_slash" in 49 case "$gl_cv_func_open_slash" in
41 *no) 50 *no)
@@ -51,16 +60,15 @@ changequote([,])dnl
51AC_DEFUN([gl_REPLACE_OPEN], 60AC_DEFUN([gl_REPLACE_OPEN],
52[ 61[
53 AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) 62 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
54 if test $REPLACE_OPEN != 1; then
55 AC_LIBOBJ([open])
56 gl_PREREQ_OPEN
57 fi
58 REPLACE_OPEN=1 63 REPLACE_OPEN=1
64 AC_LIBOBJ([open])
65 gl_PREREQ_OPEN
59]) 66])
60 67
61# Prerequisites of lib/open.c. 68# Prerequisites of lib/open.c.
62AC_DEFUN([gl_PREREQ_OPEN], 69AC_DEFUN([gl_PREREQ_OPEN],
63[ 70[
64 AC_REQUIRE([AC_C_INLINE]) 71 AC_REQUIRE([AC_C_INLINE])
72 AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])
65 : 73 :
66]) 74])