~ubuntu-branches/ubuntu/natty/diffutils/natty

« back to all changes in this revision

Viewing changes to m4/open.m4

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2010-05-04 20:38:00 UTC
  • mfrom: (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100504203800-f67xd9rsa9xl9qqj
Tags: 1:3.0-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# open.m4 serial 8
 
2
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 
3
dnl This file is free software; the Free Software Foundation
 
4
dnl gives unlimited permission to copy and/or distribute it,
 
5
dnl with or without modifications, as long as this notice is preserved.
 
6
 
 
7
AC_DEFUN([gl_FUNC_OPEN],
 
8
[
 
9
  AC_REQUIRE([AC_CANONICAL_HOST])
 
10
  case "$host_os" in
 
11
    mingw* | pw*)
 
12
      gl_REPLACE_OPEN
 
13
      ;;
 
14
    *)
 
15
      dnl open("foo/") should not create a file when the file name has a
 
16
      dnl trailing slash.  FreeBSD only has the problem on symlinks.
 
17
      AC_CHECK_FUNCS_ONCE([lstat])
 
18
      AC_CACHE_CHECK([whether open recognizes a trailing slash],
 
19
        [gl_cv_func_open_slash],
 
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
 
25
          AC_TRY_RUN([
 
26
#include <fcntl.h>
 
27
#if HAVE_UNISTD_H
 
28
# include <unistd.h>
 
29
#endif
 
30
int main ()
 
31
{
 
32
#if HAVE_LSTAT
 
33
  if (open ("conftest.lnk/", O_RDONLY) != -1) return 2;
 
34
#endif
 
35
  return open ("conftest.sl/", O_CREAT, 0600) >= 0;
 
36
}], [gl_cv_func_open_slash=yes], [gl_cv_func_open_slash=no],
 
37
            [
 
38
changequote(,)dnl
 
39
             case "$host_os" in
 
40
               freebsd*)        gl_cv_func_open_slash="guessing no" ;;
 
41
               solaris2.[0-9]*) gl_cv_func_open_slash="guessing no" ;;
 
42
               hpux*)           gl_cv_func_open_slash="guessing no" ;;
 
43
               *)               gl_cv_func_open_slash="guessing yes" ;;
 
44
             esac
 
45
changequote([,])dnl
 
46
            ])
 
47
          rm -f conftest.sl conftest.tmp conftest.lnk
 
48
        ])
 
49
      case "$gl_cv_func_open_slash" in
 
50
        *no)
 
51
          AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
 
52
            [Define to 1 if open() fails to recognize a trailing slash.])
 
53
          gl_REPLACE_OPEN
 
54
          ;;
 
55
      esac
 
56
      ;;
 
57
  esac
 
58
])
 
59
 
 
60
AC_DEFUN([gl_REPLACE_OPEN],
 
61
[
 
62
  AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
 
63
  REPLACE_OPEN=1
 
64
  AC_LIBOBJ([open])
 
65
  gl_PREREQ_OPEN
 
66
])
 
67
 
 
68
# Prerequisites of lib/open.c.
 
69
AC_DEFUN([gl_PREREQ_OPEN],
 
70
[
 
71
  AC_REQUIRE([AC_C_INLINE])
 
72
  AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])
 
73
  :
 
74
])