summaryrefslogtreecommitdiff
path: root/m4/open.m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2008-06-12 02:17:36 +0200
committerBruno Haible <bruno@clisp.org>2008-06-12 02:17:36 +0200
commit8346ecd045f052983f69eb2c1d39e89e911aed87 (patch)
tree728f751ff1238b096997b74e93ea92f511390750 /m4/open.m4
parentd5d1928563ca79cec327bd7f1c80239e95c1b289 (diff)
downloadgnulib-8346ecd045f052983f69eb2c1d39e89e911aed87.tar.gz
Work around open() bug on HP-UX 11 and Solaris 9.
Diffstat (limited to 'm4/open.m4')
-rw-r--r--m4/open.m439
1 files changed, 37 insertions, 2 deletions
diff --git a/m4/open.m4 b/m4/open.m4
index 90d528ac19..335f4e500d 100644
--- a/m4/open.m4
+++ b/m4/open.m4
@@ -1,5 +1,5 @@
-# open.m4 serial 1
-dnl Copyright (C) 2007 Free Software Foundation, Inc.
+# open.m4 serial 2
+dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -13,5 +13,40 @@ AC_DEFUN([gl_FUNC_OPEN],
REPLACE_OPEN=1
AC_LIBOBJ([open])
;;
+ *)
+ dnl open("foo/") should not create a file when the file name has a
+ dnl trailing slash.
+ AC_CACHE_CHECK([whether open recognizes a trailing slash],
+ [gl_cv_func_open_slash],
+ [
+ AC_TRY_RUN([
+#include <fcntl.h>
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+int main ()
+{
+ return open ("conftest.sl/", O_CREAT, 0600) >= 0;
+}], [gl_cv_func_open_slash=yes], [gl_cv_func_open_slash=no],
+ [
+changequote(,)dnl
+ case "$host_os" in
+ solaris2.[0-9]*) gl_cv_func_open_slash="guessing no" ;;
+ hpux*) gl_cv_func_open_slash="guessing no" ;;
+ *) gl_cv_func_open_slash="guessing yes" ;;
+ esac
+changequote([,])dnl
+ ])
+ rm -f conftest.sl
+ ])
+ case "$gl_cv_func_open_slash" in
+ *no)
+ AC_DEFINE([OPEN_TRAILING_SLASH_BUG], 1,
+ [Define to 1 if open() fails to recognize a trailing slash.])
+ REPLACE_OPEN=1
+ AC_LIBOBJ([open])
+ ;;
+ esac
+ ;;
esac
])