X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Funlink.m4;h=4adf76238b21cb64d406e9cdcd0b68243910407f;hb=a4d796fb141dac5d85328872e2fefbd5c44870e1;hp=b20af63ed4d9599346abcd45f8c922936307b214;hpb=fdf2397badd50a21656d88878a8f1e4eae58e9bb;p=gnulib.git diff --git a/m4/unlink.m4 b/m4/unlink.m4 index b20af63ed..4adf76238 100644 --- a/m4/unlink.m4 +++ b/m4/unlink.m4 @@ -1,14 +1,14 @@ -# unlink.m4 serial 5 -dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc. +# unlink.m4 serial 9 +dnl Copyright (C) 2009-2012 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. AC_DEFUN([gl_FUNC_UNLINK], [ - AC_REQUIRE([gl_AC_DOS]) AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_HEADERS_ONCE([unistd.h]) dnl Detect FreeBSD 7.2, AIX 7.1, Solaris 9 bug. AC_CACHE_CHECK([whether unlink honors trailing slashes], [gl_cv_func_unlink_honors_slashes], @@ -19,20 +19,33 @@ AC_DEFUN([gl_FUNC_UNLINK], fi AC_RUN_IFELSE( [AC_LANG_PROGRAM( - [[#include + [[#if HAVE_UNISTD_H + # include + #else /* on Windows with MSVC */ + # include + #endif #include -]], [[if (!unlink ("conftest.file/") || errno != ENOTDIR) return 1; + ]], + [[int result = 0; + if (!unlink ("conftest.file/")) + result |= 1; + else if (errno != ENOTDIR) + result |= 2; #if HAVE_LSTAT - if (!unlink ("conftest.lnk/") || errno != ENOTDIR) return 2; + if (!unlink ("conftest.lnk/")) + result |= 4; + else if (errno != ENOTDIR) + result |= 8; #endif - ]])], + return result; + ]])], [gl_cv_func_unlink_honors_slashes=yes], [gl_cv_func_unlink_honors_slashes=no], [gl_cv_func_unlink_honors_slashes="guessing no"]) rm -f conftest.file conftest.lnk]) dnl Detect MacOS X 10.5.6 bug: On read-write HFS mounts, unlink("..") or dnl unlink("../..") succeeds without doing anything. - AC_CACHE_CHECK([whether unlink of a parent directory fails is it should], + AC_CACHE_CHECK([whether unlink of a parent directory fails as it should], [gl_cv_func_unlink_parent_fails], [case "$host_os" in darwin*) @@ -62,12 +75,20 @@ AC_DEFUN([gl_FUNC_UNLINK], AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include - #include + #if HAVE_UNISTD_H + # include + #else /* on Windows with MSVC */ + # include + # include + #endif int main () { + int result = 0; if (chdir (getenv ("GL_SUBDIR_FOR_UNLINK")) != 0) - return 1; - return unlink ("..") == 0; + result |= 1; + else if (unlink ("..") == 0) + result |= 2; + return result; } ]])], [gl_cv_func_unlink_parent_fails=yes], @@ -97,6 +118,5 @@ AC_DEFUN([gl_FUNC_UNLINK], esac }; then REPLACE_UNLINK=1 - AC_LIBOBJ([unlink]) fi ])