summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2017-08-16 08:34:41 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2017-08-16 08:35:19 -0700
commit6980ecee9d86e1f99f7acd403d696da96bbed0a6 (patch)
tree0738718131144c5acaca07e3066263b1ec8fe0bc
parentbf9412ab2e5878f2b64c8ba5d496d7a26ac4d374 (diff)
downloadgnulib-6980ecee9d86e1f99f7acd403d696da96bbed0a6.tar.gz
rename: port better to NetBSD
* doc/posix-functions/rename.texi (rename): NetBSD 7 does not have the link-count bug. * m4/rename.m4 (gl_FUNC_RENAME): Don’t consider NetBSD to be broken merely because rename ("a", "b") removes "a" when the two names are hard links to the same file.
-rw-r--r--ChangeLog9
-rw-r--r--doc/posix-functions/rename.texi2
-rw-r--r--m4/rename.m419
3 files changed, 24 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 259b9992d5..422d0a3723 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-08-16 Paul Eggert <eggert@cs.ucla.edu>
+
+ rename: port better to NetBSD
+ * doc/posix-functions/rename.texi (rename): NetBSD 7
+ does not have the link-count bug.
+ * m4/rename.m4 (gl_FUNC_RENAME): Don’t consider NetBSD to be
+ broken merely because rename ("a", "b") removes "a" when the two
+ names are hard links to the same file.
+
2017-08-16 Bruno Haible <bruno@clisp.org>
iconv_open, uni*: Add support for VPATH builds with OpenBSD 'make'.
diff --git a/doc/posix-functions/rename.texi b/doc/posix-functions/rename.texi
index 12c3be4d61..97c44a5666 100644
--- a/doc/posix-functions/rename.texi
+++ b/doc/posix-functions/rename.texi
@@ -28,7 +28,7 @@ Solaris 9.
@item
This function incorrectly reduces the link count when comparing two
spellings of a hard link on some platforms:
-NetBSD 1.6, NetBSD 7.0 without @code{-D_XOPEN_SOURCE=500}, Cygwin 1.5.x.
+NetBSD 1.6, Cygwin 1.5.x.
@item
This function will not always replace an existing destination on some
platforms:
diff --git a/m4/rename.m4 b/m4/rename.m4
index 9a3730735c..a702b3eee6 100644
--- a/m4/rename.m4
+++ b/m4/rename.m4
@@ -1,4 +1,4 @@
-# serial 27
+# serial 28
# Copyright (C) 2001, 2003, 2005-2006, 2009-2017 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
@@ -136,11 +136,12 @@ AC_DEFUN([gl_FUNC_RENAME],
AC_CACHE_CHECK([whether rename manages hard links correctly],
[gl_cv_func_rename_link_works],
[if test $ac_cv_func_link = yes; then
- rm -rf conftest.f conftest.f1
- if touch conftest.f && ln conftest.f conftest.f1 &&
+ rm -rf conftest.f conftest.f1 conftest.f2
+ if touch conftest.f conftest.f2 && ln conftest.f conftest.f1 &&
set x `ls -i conftest.f conftest.f1` && test "$2" = "$4"; then
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
+# include <errno.h>
# include <stdio.h>
# include <stdlib.h>
# include <unistd.h>
@@ -150,10 +151,18 @@ AC_DEFUN([gl_FUNC_RENAME],
result |= 1;
if (unlink ("conftest.f1"))
result |= 2;
- if (rename ("conftest.f", "conftest.f"))
+
+ /* Allow either the POSIX-required behavior, where the
+ previous rename kept conftest.f, or the (better) NetBSD
+ behavior, where it removed conftest.f. */
+ if (rename ("conftest.f", "conftest.f") != 0
+ && errno != ENOENT)
result |= 4;
+
if (rename ("conftest.f1", "conftest.f1") == 0)
result |= 8;
+ if (rename ("conftest.f2", "conftest.f2") != 0)
+ result |= 16;
return result;
]])],
[gl_cv_func_rename_link_works=yes],
@@ -171,7 +180,7 @@ AC_DEFUN([gl_FUNC_RENAME],
else
gl_cv_func_rename_link_works="guessing no"
fi
- rm -rf conftest.f conftest.f1
+ rm -rf conftest.f conftest.f1 conftest.f2
else
gl_cv_func_rename_link_works=yes
fi