3 # Copyright (C) 2001, 2003, 2005, 2006, 2009 Free Software Foundation, Inc.
4 # This file is free software; the Free Software Foundation
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
8 dnl From Volker Borchert.
9 dnl Determine whether rename works for source file names with a trailing slash.
10 dnl The rename from SunOS 4.1.1_U1 doesn't.
12 dnl If it doesn't, then define RENAME_TRAILING_SLASH_BUG and arrange
13 dnl to compile the wrapper function.
16 AC_DEFUN([gl_FUNC_RENAME],
18 AC_REQUIRE([AC_CANONICAL_HOST])
19 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
21 dnl Solaris 10 mistakenly allows rename("file","name/").
22 dnl This particular condition can be worked around without stripping
24 AC_CACHE_CHECK([whether rename honors trailing slash on destination],
25 [gl_cv_func_rename_slash_dst_works],
26 [rm -rf conftest.f conftest.f1
28 AC_MSG_ERROR([cannot create temporary files])
29 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
32 ]], [return !rename ("conftest.f", "conftest.f1/");])],
33 [gl_cv_func_rename_slash_dst_works=yes],
34 [gl_cv_func_rename_slash_dst_works=no],
35 dnl When crosscompiling, assume rename is broken.
36 [gl_cv_func_rename_slash_dst_works="guessing no"])
37 rm -rf conftest.f conftest.f1
39 if test "x$gl_cv_func_rename_slash_dst_works" != xyes; then
42 AC_DEFINE([RENAME_TRAILING_SLASH_DEST_BUG], [1],
43 [Define if rename does not correctly handle slashes on the destination
44 argument, such as on Solaris 10.])
47 dnl SunOS 4.1.1_U1 mistakenly forbids rename("dir/","name").
48 dnl Solaris 9 mistakenly allows rename("file/","name").
49 dnl These bugs require stripping trailing slash to avoid corrupting
50 dnl symlinks with a trailing slash.
51 AC_CACHE_CHECK([whether rename honors trailing slash on source],
52 [gl_cv_func_rename_slash_src_works],
53 [rm -rf conftest.f conftest.d1 conftest.d2
54 touch conftest.f && mkdir conftest.d1 ||
55 AC_MSG_ERROR([cannot create temporary files])
56 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
59 ]], [if (rename ("conftest.f/", "conftest.d2") == 0) return 1;
60 if (rename ("conftest.d1/", "conftest.d2") != 0) return 2;])],
61 [gl_cv_func_rename_slash_src_works=yes],
62 [gl_cv_func_rename_slash_src_works=no],
63 dnl When crosscompiling, assume rename is broken.
64 [gl_cv_func_rename_slash_src_works="guessing no"])
65 rm -rf conftest.f conftest.d1 conftest.d2
67 if test "x$gl_cv_func_rename_slash_src_works" != xyes; then
70 AC_DEFINE([RENAME_TRAILING_SLASH_SOURCE_BUG], [1],
71 [Define if rename does not correctly handle slashes on the source
72 argument, such as on Solaris 9 or cygwin 1.5.])
75 AC_CACHE_CHECK([whether rename is broken when the destination exists],
76 [gl_cv_func_rename_dest_exists_bug],
78 mingw*) gl_cv_func_rename_dest_exists_bug=yes ;;
79 *) gl_cv_func_rename_dest_exists_bug=no ;;
82 if test $gl_cv_func_rename_dest_exists_bug = yes; then
85 AC_DEFINE([RENAME_DEST_EXISTS_BUG], [1],
86 [Define if rename does not work when the destination file exists,