annotate m4/rename.m4 @ 39913:73d60b1f9c96

doc: Update for Solaris 11.4. * doc/**/*.texi: For bugs that exist in both Solaris 11.3 and 11.4, mention Solaris 11.4. * m4/printf.m4: Update comments about Solaris. * m4/log.m4: Likewise. * m4/log10.m4: Likewise. * m4/logb.m4: Likewise. * m4/logbf.m4: Likewise. * m4/logbl.m4: Likewise. * m4/rename.m4: Likewise. * m4/wcrtomb.m4: Likewise. * m4/hostent.m4: Likewise. * m4/servent.m4: Likewise.
author Bruno Haible <bruno@clisp.org>
date Sun, 14 Oct 2018 09:33:46 +0200
parents d7562698c771
children b06060465f09
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39913
73d60b1f9c96 doc: Update for Solaris 11.4.
Bruno Haible <bruno@clisp.org>
parents: 19660
diff changeset
1 # serial 31
5611
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4674
diff changeset
2
19484
10eb9086bea0 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19242
diff changeset
3 # Copyright (C) 2001, 2003, 2005-2006, 2009-2018 Free Software Foundation, Inc.
5611
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4674
diff changeset
4 # This file is free software; the Free Software Foundation
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4674
diff changeset
5 # gives unlimited permission to copy and/or distribute it,
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4674
diff changeset
6 # with or without modifications, as long as this notice is preserved.
3097
78239ec08d9d check for SunOS4.1.1U bug in rename
Jim Meyering <jim@meyering.net>
parents:
diff changeset
7
78239ec08d9d check for SunOS4.1.1U bug in rename
Jim Meyering <jim@meyering.net>
parents:
diff changeset
8 dnl From Volker Borchert.
5907
c47674a83a78 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5611
diff changeset
9 dnl Determine whether rename works for source file names with a trailing slash.
3097
78239ec08d9d check for SunOS4.1.1U bug in rename
Jim Meyering <jim@meyering.net>
parents:
diff changeset
10 dnl The rename from SunOS 4.1.1_U1 doesn't.
78239ec08d9d check for SunOS4.1.1U bug in rename
Jim Meyering <jim@meyering.net>
parents:
diff changeset
11 dnl
78239ec08d9d check for SunOS4.1.1U bug in rename
Jim Meyering <jim@meyering.net>
parents:
diff changeset
12 dnl If it doesn't, then define RENAME_TRAILING_SLASH_BUG and arrange
78239ec08d9d check for SunOS4.1.1U bug in rename
Jim Meyering <jim@meyering.net>
parents:
diff changeset
13 dnl to compile the wrapper function.
78239ec08d9d check for SunOS4.1.1U bug in rename
Jim Meyering <jim@meyering.net>
parents:
diff changeset
14 dnl
78239ec08d9d check for SunOS4.1.1U bug in rename
Jim Meyering <jim@meyering.net>
parents:
diff changeset
15
7305
7fab62b5331d [ChangeLog]
Jim Meyering <jim@meyering.net>
parents: 6744
diff changeset
16 AC_DEFUN([gl_FUNC_RENAME],
3097
78239ec08d9d check for SunOS4.1.1U bug in rename
Jim Meyering <jim@meyering.net>
parents:
diff changeset
17 [
11478
df9a59a3f8bc Make rename replace existing destinations on Windows.
Ben Pfaff <blp@cs.stanford.edu>
parents: 11007
diff changeset
18 AC_REQUIRE([AC_CANONICAL_HOST])
11972
24ed6ac9fe07 rename: modernize replacement
Eric Blake <ebb9@byu.net>
parents: 11929
diff changeset
19 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
12260
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
20 AC_CHECK_FUNCS_ONCE([lstat])
12093
b07a0a61b0c1 rename: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 11972
diff changeset
21
39913
73d60b1f9c96 doc: Update for Solaris 11.4.
Bruno Haible <bruno@clisp.org>
parents: 19660
diff changeset
22 dnl Solaris 11.3, AIX 7.1 mistakenly allow rename("file","name/").
12096
1f43035b0900 rename-dest-slash: merge into rename module
Eric Blake <ebb9@byu.net>
parents: 12095
diff changeset
23 dnl NetBSD 1.6 mistakenly forbids rename("dir","name/").
12260
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
24 dnl FreeBSD 7.2 mistakenly allows rename("file","link-to-file/").
12096
1f43035b0900 rename-dest-slash: merge into rename module
Eric Blake <ebb9@byu.net>
parents: 12095
diff changeset
25 dnl The Solaris bug can be worked around without stripping
1f43035b0900 rename-dest-slash: merge into rename module
Eric Blake <ebb9@byu.net>
parents: 12095
diff changeset
26 dnl trailing slash, while the NetBSD bug requires stripping;
1f43035b0900 rename-dest-slash: merge into rename module
Eric Blake <ebb9@byu.net>
parents: 12095
diff changeset
27 dnl the two conditions can be distinguished by whether hard
1f43035b0900 rename-dest-slash: merge into rename module
Eric Blake <ebb9@byu.net>
parents: 12095
diff changeset
28 dnl links are also broken.
12094
67458384fb3f rename: fix Solaris 10 bug
Eric Blake <ebb9@byu.net>
parents: 12093
diff changeset
29 AC_CACHE_CHECK([whether rename honors trailing slash on destination],
67458384fb3f rename: fix Solaris 10 bug
Eric Blake <ebb9@byu.net>
parents: 12093
diff changeset
30 [gl_cv_func_rename_slash_dst_works],
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
31 [rm -rf conftest.f conftest.f1 conftest.f2 conftest.d1 conftest.d2 conftest.lnk
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
32 touch conftest.f && touch conftest.f1 && mkdir conftest.d1 ||
12094
67458384fb3f rename: fix Solaris 10 bug
Eric Blake <ebb9@byu.net>
parents: 12093
diff changeset
33 AC_MSG_ERROR([cannot create temporary files])
12260
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
34 # Assume that if we have lstat, we can also check symlinks.
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
35 if test $ac_cv_func_lstat = yes; then
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
36 ln -s conftest.f conftest.lnk
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
37 fi
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
38 AC_RUN_IFELSE(
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
39 [AC_LANG_PROGRAM([[
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
40 # include <stdio.h>
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
41 # include <stdlib.h>
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
42 ]],
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
43 [[int result = 0;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
44 if (rename ("conftest.f1", "conftest.f2/") == 0)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
45 result |= 1;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
46 if (rename ("conftest.d1", "conftest.d2/") != 0)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
47 result |= 2;
12260
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
48 #if HAVE_LSTAT
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
49 if (rename ("conftest.f", "conftest.lnk/") == 0)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
50 result |= 4;
12260
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
51 #endif
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
52 return result;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
53 ]])],
12094
67458384fb3f rename: fix Solaris 10 bug
Eric Blake <ebb9@byu.net>
parents: 12093
diff changeset
54 [gl_cv_func_rename_slash_dst_works=yes],
67458384fb3f rename: fix Solaris 10 bug
Eric Blake <ebb9@byu.net>
parents: 12093
diff changeset
55 [gl_cv_func_rename_slash_dst_works=no],
67458384fb3f rename: fix Solaris 10 bug
Eric Blake <ebb9@byu.net>
parents: 12093
diff changeset
56 dnl When crosscompiling, assume rename is broken.
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
57 [case "$host_os" in
19660
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
58 # Guess yes on Linux systems.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
59 linux-* | linux) gl_cv_func_rename_slash_dst_works="guessing yes" ;;
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
60 # Guess yes on glibc systems.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
61 *-gnu*) gl_cv_func_rename_slash_dst_works="guessing yes" ;;
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
62 # Guess no on native Windows.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
63 mingw*) gl_cv_func_rename_slash_dst_works="guessing no" ;;
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
64 # If we don't know, assume the worst.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
65 *) gl_cv_func_rename_slash_dst_works="guessing no" ;;
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
66 esac
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
67 ])
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
68 rm -rf conftest.f conftest.f1 conftest.f2 conftest.d1 conftest.d2 conftest.lnk
12094
67458384fb3f rename: fix Solaris 10 bug
Eric Blake <ebb9@byu.net>
parents: 12093
diff changeset
69 ])
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
70 case "$gl_cv_func_rename_slash_dst_works" in
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
71 *yes) ;;
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
72 *)
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
73 REPLACE_RENAME=1
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
74 AC_DEFINE([RENAME_TRAILING_SLASH_DEST_BUG], [1],
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
75 [Define if rename does not correctly handle slashes on the destination
19242
11af6bbd6df5 doc: Update for Solaris 11.3.
Bruno Haible <bruno@clisp.org>
parents: 19064
diff changeset
76 argument, such as on Solaris 11 or NetBSD 1.6.])
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
77 ;;
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
78 esac
12094
67458384fb3f rename: fix Solaris 10 bug
Eric Blake <ebb9@byu.net>
parents: 12093
diff changeset
79
12093
b07a0a61b0c1 rename: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 11972
diff changeset
80 dnl SunOS 4.1.1_U1 mistakenly forbids rename("dir/","name").
b07a0a61b0c1 rename: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 11972
diff changeset
81 dnl Solaris 9 mistakenly allows rename("file/","name").
12260
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
82 dnl FreeBSD 7.2 mistakenly allows rename("link-to-file/","name").
12094
67458384fb3f rename: fix Solaris 10 bug
Eric Blake <ebb9@byu.net>
parents: 12093
diff changeset
83 dnl These bugs require stripping trailing slash to avoid corrupting
67458384fb3f rename: fix Solaris 10 bug
Eric Blake <ebb9@byu.net>
parents: 12093
diff changeset
84 dnl symlinks with a trailing slash.
12093
b07a0a61b0c1 rename: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 11972
diff changeset
85 AC_CACHE_CHECK([whether rename honors trailing slash on source],
b07a0a61b0c1 rename: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 11972
diff changeset
86 [gl_cv_func_rename_slash_src_works],
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
87 [rm -rf conftest.f conftest.f1 conftest.d1 conftest.d2 conftest.d3 conftest.lnk
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
88 touch conftest.f && touch conftest.f1 && mkdir conftest.d1 ||
12093
b07a0a61b0c1 rename: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 11972
diff changeset
89 AC_MSG_ERROR([cannot create temporary files])
12260
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
90 # Assume that if we have lstat, we can also check symlinks.
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
91 if test $ac_cv_func_lstat = yes; then
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
92 ln -s conftest.f conftest.lnk
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
93 fi
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
94 AC_RUN_IFELSE(
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
95 [AC_LANG_PROGRAM([[
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
96 # include <stdio.h>
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
97 # include <stdlib.h>
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
98 ]],
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
99 [[int result = 0;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
100 if (rename ("conftest.f1/", "conftest.d3") == 0)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
101 result |= 1;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
102 if (rename ("conftest.d1/", "conftest.d2") != 0)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
103 result |= 2;
12260
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
104 #if HAVE_LSTAT
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
105 if (rename ("conftest.lnk/", "conftest.f") == 0)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
106 result |= 4;
12260
18ce29e54b9f rename: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12097
diff changeset
107 #endif
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
108 return result;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
109 ]])],
12093
b07a0a61b0c1 rename: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 11972
diff changeset
110 [gl_cv_func_rename_slash_src_works=yes],
b07a0a61b0c1 rename: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 11972
diff changeset
111 [gl_cv_func_rename_slash_src_works=no],
3105
20833ed0761f Remove conftestdir{,2} before trying to create the directory.
Jim Meyering <jim@meyering.net>
parents: 3100
diff changeset
112 dnl When crosscompiling, assume rename is broken.
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
113 [case "$host_os" in
19660
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
114 # Guess yes on Linux systems.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
115 linux-* | linux) gl_cv_func_rename_slash_src_works="guessing yes" ;;
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
116 # Guess yes on glibc systems.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
117 *-gnu*) gl_cv_func_rename_slash_src_works="guessing yes" ;;
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
118 # Guess yes on native Windows.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
119 mingw*) gl_cv_func_rename_slash_src_works="guessing yes" ;;
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
120 # If we don't know, assume the worst.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
121 *) gl_cv_func_rename_slash_src_works="guessing no" ;;
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
122 esac
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
123 ])
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
124 rm -rf conftest.f conftest.f1 conftest.d1 conftest.d2 conftest.d3 conftest.lnk
3097
78239ec08d9d check for SunOS4.1.1U bug in rename
Jim Meyering <jim@meyering.net>
parents:
diff changeset
125 ])
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
126 case "$gl_cv_func_rename_slash_src_works" in
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
127 *yes) ;;
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
128 *)
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
129 REPLACE_RENAME=1
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
130 AC_DEFINE([RENAME_TRAILING_SLASH_SOURCE_BUG], [1],
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
131 [Define if rename does not correctly handle slashes on the source
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
132 argument, such as on Solaris 9 or cygwin 1.5.])
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
133 ;;
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
134 esac
12093
b07a0a61b0c1 rename: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 11972
diff changeset
135
12097
bb32464985d7 rename: fix another cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents: 12096
diff changeset
136 dnl NetBSD 1.6 and cygwin 1.5.x mistakenly reduce hard link count
bb32464985d7 rename: fix another cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents: 12096
diff changeset
137 dnl on rename("h1","h2").
bb32464985d7 rename: fix another cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents: 12096
diff changeset
138 dnl This bug requires stat'ting targets prior to attempting rename.
15606
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
139 AC_CHECK_FUNCS_ONCE([link])
12097
bb32464985d7 rename: fix another cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents: 12096
diff changeset
140 AC_CACHE_CHECK([whether rename manages hard links correctly],
bb32464985d7 rename: fix another cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents: 12096
diff changeset
141 [gl_cv_func_rename_link_works],
15606
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
142 [if test $ac_cv_func_link = yes; then
19064
bfdf5ca28b78 rename: port better to NetBSD
Paul Eggert <eggert@cs.ucla.edu>
parents: 18993
diff changeset
143 rm -rf conftest.f conftest.f1 conftest.f2
bfdf5ca28b78 rename: port better to NetBSD
Paul Eggert <eggert@cs.ucla.edu>
parents: 18993
diff changeset
144 if touch conftest.f conftest.f2 && ln conftest.f conftest.f1 &&
15606
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
145 set x `ls -i conftest.f conftest.f1` && test "$2" = "$4"; then
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
146 AC_RUN_IFELSE(
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
147 [AC_LANG_PROGRAM([[
19064
bfdf5ca28b78 rename: port better to NetBSD
Paul Eggert <eggert@cs.ucla.edu>
parents: 18993
diff changeset
148 # include <errno.h>
15606
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
149 # include <stdio.h>
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
150 # include <stdlib.h>
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
151 # include <unistd.h>
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
152 ]],
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
153 [[int result = 0;
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
154 if (rename ("conftest.f", "conftest.f1"))
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
155 result |= 1;
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
156 if (unlink ("conftest.f1"))
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
157 result |= 2;
19064
bfdf5ca28b78 rename: port better to NetBSD
Paul Eggert <eggert@cs.ucla.edu>
parents: 18993
diff changeset
158
bfdf5ca28b78 rename: port better to NetBSD
Paul Eggert <eggert@cs.ucla.edu>
parents: 18993
diff changeset
159 /* Allow either the POSIX-required behavior, where the
bfdf5ca28b78 rename: port better to NetBSD
Paul Eggert <eggert@cs.ucla.edu>
parents: 18993
diff changeset
160 previous rename kept conftest.f, or the (better) NetBSD
bfdf5ca28b78 rename: port better to NetBSD
Paul Eggert <eggert@cs.ucla.edu>
parents: 18993
diff changeset
161 behavior, where it removed conftest.f. */
bfdf5ca28b78 rename: port better to NetBSD
Paul Eggert <eggert@cs.ucla.edu>
parents: 18993
diff changeset
162 if (rename ("conftest.f", "conftest.f") != 0
bfdf5ca28b78 rename: port better to NetBSD
Paul Eggert <eggert@cs.ucla.edu>
parents: 18993
diff changeset
163 && errno != ENOENT)
15606
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
164 result |= 4;
19064
bfdf5ca28b78 rename: port better to NetBSD
Paul Eggert <eggert@cs.ucla.edu>
parents: 18993
diff changeset
165
15606
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
166 if (rename ("conftest.f1", "conftest.f1") == 0)
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
167 result |= 8;
19064
bfdf5ca28b78 rename: port better to NetBSD
Paul Eggert <eggert@cs.ucla.edu>
parents: 18993
diff changeset
168 if (rename ("conftest.f2", "conftest.f2") != 0)
bfdf5ca28b78 rename: port better to NetBSD
Paul Eggert <eggert@cs.ucla.edu>
parents: 18993
diff changeset
169 result |= 16;
15606
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
170 return result;
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
171 ]])],
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
172 [gl_cv_func_rename_link_works=yes],
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
173 [gl_cv_func_rename_link_works=no],
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
174 dnl When crosscompiling, assume rename is broken.
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
175 [case "$host_os" in
19660
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
176 # Guess yes on Linux systems.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
177 linux-* | linux) gl_cv_func_rename_link_works="guessing yes" ;;
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
178 # Guess yes on glibc systems.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
179 *-gnu*) gl_cv_func_rename_link_works="guessing yes" ;;
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
180 # Guess yes on native Windows.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
181 mingw*) gl_cv_func_rename_link_works="guessing yes" ;;
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
182 # If we don't know, assume the worst.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
183 *) gl_cv_func_rename_link_works="guessing no" ;;
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
184 esac
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
185 ])
15606
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
186 else
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
187 gl_cv_func_rename_link_works="guessing no"
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
188 fi
19064
bfdf5ca28b78 rename: port better to NetBSD
Paul Eggert <eggert@cs.ucla.edu>
parents: 18993
diff changeset
189 rm -rf conftest.f conftest.f1 conftest.f2
15606
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
190 else
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
191 gl_cv_func_rename_link_works=yes
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
192 fi
f62f29997e98 unistd et al.: Don't assume <unistd.h> exists.
Bruno Haible <bruno@clisp.org>
parents: 15082
diff changeset
193 ])
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
194 case "$gl_cv_func_rename_link_works" in
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
195 *yes) ;;
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
196 *)
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
197 REPLACE_RENAME=1
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
198 AC_DEFINE([RENAME_HARD_LINK_BUG], [1],
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
199 [Define if rename fails to leave hard links alone, as on NetBSD 1.6
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
200 or Cygwin 1.5.])
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
201 ;;
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
202 esac
12097
bb32464985d7 rename: fix another cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents: 12096
diff changeset
203
12095
724dd32f13f7 rename: fix cygwin 1.5.x bugs
Eric Blake <ebb9@byu.net>
parents: 12094
diff changeset
204 dnl Cygwin 1.5.x mistakenly allows rename("dir","file").
724dd32f13f7 rename: fix cygwin 1.5.x bugs
Eric Blake <ebb9@byu.net>
parents: 12094
diff changeset
205 dnl mingw mistakenly forbids rename("dir1","dir2").
724dd32f13f7 rename: fix cygwin 1.5.x bugs
Eric Blake <ebb9@byu.net>
parents: 12094
diff changeset
206 dnl These bugs require stripping trailing slash to avoid corrupting
724dd32f13f7 rename: fix cygwin 1.5.x bugs
Eric Blake <ebb9@byu.net>
parents: 12094
diff changeset
207 dnl symlinks with a trailing slash.
724dd32f13f7 rename: fix cygwin 1.5.x bugs
Eric Blake <ebb9@byu.net>
parents: 12094
diff changeset
208 AC_CACHE_CHECK([whether rename manages existing destinations correctly],
724dd32f13f7 rename: fix cygwin 1.5.x bugs
Eric Blake <ebb9@byu.net>
parents: 12094
diff changeset
209 [gl_cv_func_rename_dest_works],
724dd32f13f7 rename: fix cygwin 1.5.x bugs
Eric Blake <ebb9@byu.net>
parents: 12094
diff changeset
210 [rm -rf conftest.f conftest.d1 conftest.d2
724dd32f13f7 rename: fix cygwin 1.5.x bugs
Eric Blake <ebb9@byu.net>
parents: 12094
diff changeset
211 touch conftest.f && mkdir conftest.d1 conftest.d2 ||
724dd32f13f7 rename: fix cygwin 1.5.x bugs
Eric Blake <ebb9@byu.net>
parents: 12094
diff changeset
212 AC_MSG_ERROR([cannot create temporary files])
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
213 AC_RUN_IFELSE(
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
214 [AC_LANG_PROGRAM([[
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
215 # include <stdio.h>
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
216 # include <stdlib.h>
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
217 ]],
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
218 [[int result = 0;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
219 if (rename ("conftest.d1", "conftest.d2") != 0)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
220 result |= 1;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
221 if (rename ("conftest.d2", "conftest.f") == 0)
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
222 result |= 2;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
223 return result;
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13496
diff changeset
224 ]])],
12097
bb32464985d7 rename: fix another cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents: 12096
diff changeset
225 [gl_cv_func_rename_dest_works=yes],
bb32464985d7 rename: fix another cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents: 12096
diff changeset
226 [gl_cv_func_rename_dest_works=no],
bb32464985d7 rename: fix another cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents: 12096
diff changeset
227 dnl When crosscompiling, assume rename is broken.
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
228 [case "$host_os" in
19660
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
229 # Guess yes on Linux systems.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
230 linux-* | linux) gl_cv_func_rename_dest_works="guessing yes" ;;
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
231 # Guess yes on glibc systems.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
232 *-gnu*) gl_cv_func_rename_dest_works="guessing yes" ;;
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
233 # Guess no on native Windows.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
234 mingw*) gl_cv_func_rename_dest_works="guessing no" ;;
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
235 # If we don't know, assume the worst.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
236 *) gl_cv_func_rename_dest_works="guessing no" ;;
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
237 esac
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
238 ])
12097
bb32464985d7 rename: fix another cygwin 1.5 bug
Eric Blake <ebb9@byu.net>
parents: 12096
diff changeset
239 rm -rf conftest.f conftest.d1 conftest.d2
11478
df9a59a3f8bc Make rename replace existing destinations on Windows.
Ben Pfaff <blp@cs.stanford.edu>
parents: 11007
diff changeset
240 ])
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
241 case "$gl_cv_func_rename_dest_works" in
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
242 *yes) ;;
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
243 *)
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
244 REPLACE_RENAME=1
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
245 AC_DEFINE([RENAME_DEST_EXISTS_BUG], [1],
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
246 [Define if rename does not work when the destination file exists,
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
247 as on Cygwin 1.5 or Windows.])
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
248 ;;
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
249 esac
3097
78239ec08d9d check for SunOS4.1.1U bug in rename
Jim Meyering <jim@meyering.net>
parents:
diff changeset
250 ])