Re: list, set, oset, map, omap: avoid imperative voice in documentation

2020-02-08 Thread Bruno Haible
Paul Eggert wrote:
> Plus, it's odd to use one style before a "{" and a different style after.

I think it's useful to make this emphasis - in order to write a function
specification that can be understood without reading the function body.

When I write code, I'm of course a bit annoyed to make the difference
between the specification (in the .h file) and the implementation (in the
.c file). But this annoyance is rewarded with a 10 times higher value:
the ability to read the specification without looking into the implementation
(which is often 3 to 20 times larger than the specification).

> perhaps "'clearerr (STREAM)' clears the 
> error indicator for STREAM." which is in reverse order of what the text 
> says

That's only because we are writing the specification before the declaration,
and directly looking at the .h file. If you were reading Doxygen generated
HTML [1], it would present the declaration first and the specification
immediately following it.

> the "Clears" of the comment disagrees with the "clear" of the function name.

Yes, function names use the imperative, like C does: we write
   goto label;   NOT   goesto label;
and
   return x; NOT   returns x;
- because inside the function's body the imperative aspects are predominant.

Bruno

[1] http://xerces.apache.org/xerces-c/apiDocs-3/classBase64.html




Re: bug#39236: [musl] coreutils cp mishandles error return from lchmod

2020-02-08 Thread Bruno Haible
Hi Paul,

> similarly for lchmod on non-symlinks.

When I see a new autoconf test that activates an override, in order to
guarantee a certain documented behaviour, I like to add a unit test -
because in the past we several times had an override that would not
have passed the autoconf test either.

So I added a unit test for 'lchown', and found that on HP-UX 11.31 the function
could not be used because it is not declared. Which leads to these patches:


2020-02-08  Bruno Haible  

lchmod: Add tests.
* tests/test-lchmod.c: New file.
* modules/lchmod-tests: New file.

2020-02-08  Bruno Haible  

lchmod: Ensure declaration on HP-UX.
* lib/sys_stat.in.h (lchown): Declare also on HP-UX.
* doc/glibc-functions/lchmod.texi: Mention the HP-UX problem.

>From d863fc54623c497e0ed51fb0d7011415dc943434 Mon Sep 17 00:00:00 2001
From: Bruno Haible 
Date: Sat, 8 Feb 2020 21:22:15 +0100
Subject: [PATCH 1/2] lchmod: Ensure declaration on HP-UX.

* lib/sys_stat.in.h (lchown): Declare also on HP-UX.
* doc/glibc-functions/lchmod.texi: Mention the HP-UX problem.
---
 ChangeLog   | 6 ++
 doc/glibc-functions/lchmod.texi | 3 +++
 lib/sys_stat.in.h   | 2 +-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index fc07914..ffb2096 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2020-02-08  Bruno Haible  
 
+	lchmod: Ensure declaration on HP-UX.
+	* lib/sys_stat.in.h (lchown): Declare also on HP-UX.
+	* doc/glibc-functions/lchmod.texi: Mention the HP-UX problem.
+
+2020-02-08  Bruno Haible  
+
 	fchmodat: Strengthen tests.
 	* tests/test-fchmodat.c (BASE): New macro.
 	(main): Use it, to avoid conflicts with other unit tests. Verify that
diff --git a/doc/glibc-functions/lchmod.texi b/doc/glibc-functions/lchmod.texi
index 6cc48b4..7a2e9d0 100644
--- a/doc/glibc-functions/lchmod.texi
+++ b/doc/glibc-functions/lchmod.texi
@@ -10,6 +10,9 @@ Portability problems fixed by Gnulib:
 This function is missing on some platforms:
 OpenBSD 3.8, Minix 3.1.8, AIX 5.1, IRIX 6.5, Solaris 11.4, Cygwin, mingw, MSVC 14, Android 9.0.
 @item
+This function is not declared on some platforms:
+HP-UX 11.31.
+@item
 This function always fails with @code{errno} set to @code{ENOSYS},
 even when the file is not a symbolic link:
 GNU/Linux with glibc 2.31.
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 4f9eb59..65661f4 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -525,7 +525,7 @@ _GL_FUNCDECL_RPL (lchmod, int,
 _GL_CXXALIAS_RPL (lchmod, int,
   (char const *filename, mode_t mode));
 # else
-#  if !@HAVE_LCHMOD@
+#  if !@HAVE_LCHMOD@ || defined __hpux
 _GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
_GL_ARG_NONNULL ((1)));
 #  endif
-- 
2.7.4

>From 8cc34c349afc79e2728093e109a09f9f0aaa4b50 Mon Sep 17 00:00:00 2001
From: Bruno Haible 
Date: Sat, 8 Feb 2020 21:24:35 +0100
Subject: [PATCH 2/2] lchmod: Add tests.

* tests/test-lchmod.c: New file.
* modules/lchmod-tests: New file.
---
 ChangeLog|  6 +
 modules/lchmod-tests | 13 ++
 tests/test-lchmod.c  | 67 
 3 files changed, 86 insertions(+)
 create mode 100644 modules/lchmod-tests
 create mode 100644 tests/test-lchmod.c

diff --git a/ChangeLog b/ChangeLog
index ffb2096..a4ee3dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2020-02-08  Bruno Haible  
 
+	lchmod: Add tests.
+	* tests/test-lchmod.c: New file.
+	* modules/lchmod-tests: New file.
+
+2020-02-08  Bruno Haible  
+
 	lchmod: Ensure declaration on HP-UX.
 	* lib/sys_stat.in.h (lchown): Declare also on HP-UX.
 	* doc/glibc-functions/lchmod.texi: Mention the HP-UX problem.
diff --git a/modules/lchmod-tests b/modules/lchmod-tests
new file mode 100644
index 000..cbb2537
--- /dev/null
+++ b/modules/lchmod-tests
@@ -0,0 +1,13 @@
+Files:
+tests/test-lchmod.c
+tests/signature.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-lchmod
+check_PROGRAMS += test-lchmod
+test_lchmod_LDADD = $(LDADD) @LIBINTL@
diff --git a/tests/test-lchmod.c b/tests/test-lchmod.c
new file mode 100644
index 000..783e608
--- /dev/null
+++ b/tests/test-lchmod.c
@@ -0,0 +1,67 @@
+/* Test changing the protections of a file.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along 

Re: fchmodat with AT_SYMLINK_NOFOLLOW

2020-02-08 Thread Bruno Haible
Hi Paul,

> I installed the attached patch to Gnulib in preparation for the upcoming 
> glibc fix. The patch causes fchmodat with AT_SYMLINK_NOFOLLOW to work on 
> non-symlinks, and similarly for lchmod on non-symlinks. The idea is to 
> avoid this sort of problem in the future, and to let Coreutils etc. work 
> on older platforms as if glibc 2.32 (or whatever) is already in place.

Some improvements:

1) Improve the cross-compilation guesses. The result of the
"fchmodat+AT_SYMLINK_NOFOLLOW works on non-symlinks" test is:
  - yes on kFreeBSD/glibc, Hurd/glibc, FreeBSD 12, AIX 7.2, Solaris 11, Haiku,
  - no on Linux/glibc, Cygwin 2.9.

2) On Cygwin, the functions fchmodat and lchown crash. The cause is an endless
recursion, because some of the #includes in fchmodat.c includes the full
, including the '#define fchmodat rpl_fchmodat'.

3) Strengthen the unit test, and make sure that it does not write files that
other unit tests could possibly write as well.
This test is a bit tricky, because on native Windows, we cannot do arbitrary
chmods:
  - chmod of 700 is equivalent to 600 (since it does not have an execute bit
on the file system),
  - chmod of 600 sets the mode to 666 - since there is no distinction between
users, group, and world with this API.
  - After a chmod of 400 (= read-only), unlink() fails.


2020-02-08  Bruno Haible  

fchmodat: Strengthen tests.
* tests/test-fchmodat.c (BASE): New macro.
(main): Use it, to avoid conflicts with other unit tests. Verify that
fchmodat changed the file permission bits.

2020-02-08  Bruno Haible  

fchmodat: Fix endless recursion on Cygwin (regression from 2020-02-07).
* lib/fchmodat.c (orig_fchmodat): Move definition to immediately after
'#undef __need_system_sys_stat_h'.

2020-02-08  Bruno Haible  

fchmodat: Improve cross-compilation guesses.
* m4/fchmodat.m4 (gl_FUNC_FCHMODAT): Require AC_CANONICAL_HOST. When
cross-compiling, guess depending on the platform.
* doc/posix-functions/fchmodat.texi: Clarify.

>From a680228fe4d39f749cb819e45202c6fec6ca9d29 Mon Sep 17 00:00:00 2001
From: Bruno Haible 
Date: Sat, 8 Feb 2020 20:38:01 +0100
Subject: [PATCH 1/3] fchmodat: Improve cross-compilation guesses.

* m4/fchmodat.m4 (gl_FUNC_FCHMODAT): Require AC_CANONICAL_HOST. When
cross-compiling, guess depending on the platform.
* doc/posix-functions/fchmodat.texi: Clarify.
---
 ChangeLog |  7 +++
 doc/posix-functions/fchmodat.texi | 10 +-
 m4/fchmodat.m4| 14 +++---
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index df48e88..32d9a00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2020-02-08  Bruno Haible  
 
+	fchmodat: Improve cross-compilation guesses.
+	* m4/fchmodat.m4 (gl_FUNC_FCHMODAT): Require AC_CANONICAL_HOST. When
+	cross-compiling, guess depending on the platform.
+	* doc/posix-functions/fchmodat.texi: Clarify.
+
+2020-02-08  Bruno Haible  
+
 	Fix compilation errors in a testdir created with --with-c++-tests.
 	* lib/c++defs.h (_GL_CXXALIASWARN1_2): Do not use __typeof__ (func),
 	since it does not work any more with g++ >= 4.4.
diff --git a/doc/posix-functions/fchmodat.texi b/doc/posix-functions/fchmodat.texi
index 4d19031..a295f83 100644
--- a/doc/posix-functions/fchmodat.texi
+++ b/doc/posix-functions/fchmodat.texi
@@ -9,15 +9,15 @@ Gnulib module: fchmodat
 Portability problems fixed by Gnulib:
 @itemize
 @item
-When given the @code{AT_SYMLINK_NOFOLLOW} flag,
-this function fails with @code{errno} set to @code{ENOTSUP},
-even when the file is not a symbolic link:
-GNU/Linux and Cygwin with glibc 2.31.
-@item
 This function is missing on some platforms:
 glibc 2.3.6, Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8,
 AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 10, Cygwin 1.5.x, mingw, MSVC 14.
 But the replacement function is not safe to be used in libraries and is not multithread-safe.
+@item
+When given the @code{AT_SYMLINK_NOFOLLOW} flag,
+this function fails with @code{errno} set to @code{ENOTSUP},
+even when the file is not a symbolic link:
+GNU/Linux with glibc 2.31, Cygwin 2.9.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/m4/fchmodat.m4 b/m4/fchmodat.m4
index 8195ef6..f284485 100644
--- a/m4/fchmodat.m4
+++ b/m4/fchmodat.m4
@@ -1,4 +1,4 @@
-# fchmodat.m4 serial 2
+# fchmodat.m4 serial 3
 dnl Copyright (C) 2004-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,6 +10,7 @@ AC_DEFUN([gl_FUNC_FCHMODAT],
 [
   AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   AC_CHECK_FUNCS_ONCE([fchmodat lchmod])
   if test $ac_cv_func_fchmodat != yes; then
 HAVE_FCHMODAT=0
@@ -17,7 +18,9 @@ AC_DEFUN([gl_FUNC_FCHMODAT],
 

Fix compilation errors in a testdir created with --with-c++-tests

2020-02-08 Thread Bruno Haible
In a testdir created through
  ./gnulib-tool --create-testdir --dir=... --single-configure --with-c++-tests 
lchmod fchmodat
I'm getting compilation errors, such as:

In file included from test-string-c++.cc:22:
../gllib/string.h:707: error: type of 'memrchr' is unknown
../gllib/string.h:707: error: invalid type in declaration before ';' token
../gllib/string.h:707: error: 'int memrchr' redeclared as different kind of 
symbol
/usr/include/string.h:114: error: previous declaration of 'const void* 
memrchr(const void*, int, size_t)'

This patch fixes it, unfortunately at the cost of disabling useful warnings.


2020-02-08  Bruno Haible  

Fix compilation errors in a testdir created with --with-c++-tests.
* lib/c++defs.h (_GL_CXXALIASWARN1_2): Do not use __typeof__ (func),
since it does not work any more with g++ >= 4.4.

diff --git a/lib/c++defs.h b/lib/c++defs.h
index 5d5da71..402cae4 100644
--- a/lib/c++defs.h
+++ b/lib/c++defs.h
@@ -301,9 +301,6 @@
 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
  "The symbol ::" #func " refers to the system 
function. " \
  "Use " #namespace "::" #func " instead.")
-# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
-#  define 
_GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
- extern __typeof__ (func) func
 # else
 #  define 
_GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
  _GL_EXTERN_C int _gl_cxxalias_dummy




doc: update for glibc 2.31

2020-02-08 Thread Bruno Haible
It's good if the gnulib documentation reflects the newest glibc release, not
some older release.


2020-02-08  Bruno Haible  

doc: Update for glibc 2.31.
* doc/glibc-functions/pthread_clockjoin_np.texi: New file.
* doc/gnulib.texi: Include it.
* doc/pastposix-functions/h_errno.texi: Update.
* doc/posix-functions/*.texi: Likewise.

diff --git a/doc/glibc-functions/pthread_clockjoin_np.texi 
b/doc/glibc-functions/pthread_clockjoin_np.texi
new file mode 100644
index 000..03ca09a
--- /dev/null
+++ b/doc/glibc-functions/pthread_clockjoin_np.texi
@@ -0,0 +1,30 @@
+@node pthread_clockjoin_np
+@subsection @code{pthread_clockjoin_np}
+@findex pthread_clockjoin_np
+
+Documentation:
+@itemize
+@item
+@ifinfo
+@ref{Default Thread Attributes,,Setting Process-wide defaults for thread 
attributes,libc}.
+@end ifinfo
+@ifnotinfo
+@url{https://www.gnu.org/software/libc/manual/html_node/Default-Thread-Attributes.html}.
+@end ifnotinfo
+@c Not yet.
+@c @item
+@c 
@uref{https://www.kernel.org/doc/man-pages/online/pages/man3/pthread_clockjoin_np.3.html,,man
 pthread_clockjoin_np}.
+@end itemize
+
+Gnulib module: ---
+
+Portability problems fixed by Gnulib:
+@itemize
+@end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@item
+This function is missing on all non-glibc platforms:
+Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, 
HP-UX 11, IRIX 6.5, Solaris 11.4, Cygwin, mingw, MSVC 14, Android 9.0.
+@end itemize
diff --git a/doc/gnulib.texi b/doc/gnulib.texi
index 45b9a8c..c9501ca 100644
--- a/doc/gnulib.texi
+++ b/doc/gnulib.texi
@@ -4743,6 +4743,7 @@ This list of functions is sorted according to the header 
that declares them.
 @menu
 * pthread_attr_getaffinity_np::
 * pthread_attr_setaffinity_np::
+* pthread_clockjoin_np::
 * pthread_cond_clockwait::
 * pthread_getaffinity_np::
 * pthread_getattr_default_np::
@@ -4768,6 +4769,7 @@ This list of functions is sorted according to the header 
that declares them.
 
 @include glibc-functions/pthread_attr_getaffinity_np.texi
 @include glibc-functions/pthread_attr_setaffinity_np.texi
+@include glibc-functions/pthread_clockjoin_np.texi
 @include glibc-functions/pthread_cond_clockwait.texi
 @include glibc-functions/pthread_getaffinity_np.texi
 @include glibc-functions/pthread_getattr_default_np.texi
diff --git a/doc/pastposix-functions/h_errno.texi 
b/doc/pastposix-functions/h_errno.texi
index 77fa2a4..6d2a2d2 100644
--- a/doc/pastposix-functions/h_errno.texi
+++ b/doc/pastposix-functions/h_errno.texi
@@ -14,5 +14,5 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-glibc 2.30, IRIX 6.5, Cygwin, mingw, MSVC 14, Android 9.0.
+glibc 2.31, IRIX 6.5, Cygwin, mingw, MSVC 14, Android 9.0.
 @end itemize
diff --git a/doc/posix-functions/crypt.texi b/doc/posix-functions/crypt.texi
index d48f0fa..b060696 100644
--- a/doc/posix-functions/crypt.texi
+++ b/doc/posix-functions/crypt.texi
@@ -14,7 +14,7 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-glibc 2.30, FreeBSD 6.0, NetBSD 5.0, Cygwin, mingw, MSVC 14, Android 9.0.
+glibc 2.31, FreeBSD 6.0, NetBSD 5.0, Cygwin, mingw, MSVC 14, Android 9.0.
 @item
 This function is not declared in @code{}
 (without @code{-D_GNU_SOURCE}) on some platforms:
diff --git a/doc/posix-functions/setkey.texi b/doc/posix-functions/setkey.texi
index 8e05f3a..6128c58 100644
--- a/doc/posix-functions/setkey.texi
+++ b/doc/posix-functions/setkey.texi
@@ -14,7 +14,7 @@ Portability problems not fixed by Gnulib:
 @itemize
 @item
 This function is missing on some platforms:
-glibc 2.30, NetBSD 5.0, Minix 3.1.8, Cygwin, mingw, MSVC 14, Android 9.0.
+glibc 2.31, NetBSD 5.0, Minix 3.1.8, Cygwin, mingw, MSVC 14, Android 9.0.
 @item
 This function is not declared in @code{}
 (without @code{-D_GNU_SOURCE}) on some platforms:
diff --git a/doc/posix-functions/totalorder.texi 
b/doc/posix-functions/totalorder.texi
index 447b20e..9df04df 100644
--- a/doc/posix-functions/totalorder.texi
+++ b/doc/posix-functions/totalorder.texi
@@ -21,4 +21,7 @@ Portability problems not fixed by Gnulib:
 @item
 This function is missing on all non-glibc platforms:
 glibc 2.24, Mac OS X 10.5, FreeBSD 12.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, 
AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.4, Cygwin, mingw, MSVC 14, Android 
9.0.
+@item
+This function has a different signature on some platforms:
+glibc 2.30.
 @end itemize
diff --git a/doc/posix-functions/totalorderf.texi 
b/doc/posix-functions/totalorderf.texi
index 06b1d91..456c1a2 100644
--- a/doc/posix-functions/totalorderf.texi
+++ b/doc/posix-functions/totalorderf.texi
@@ -21,4 +21,7 @@ Portability problems not fixed by Gnulib:
 @item
 This function is missing on all non-glibc platforms:
 glibc 2.24, Mac OS X 10.5, FreeBSD 12.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, 
AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.4, Cygwin, mingw, MSVC 14, Android 
9.0.

Re: [PATCH] [PATCH] mountlist: Consider smb3 filesystems as remote.

2020-02-08 Thread Pádraig Brady

On 05/02/2020 14:16, Kenneth D'souza wrote:

Recognize filesystems of type smb3 as remote.

Signed-off-by: Kenneth D'souza 
---
  lib/mountlist.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/lib/mountlist.c b/lib/mountlist.c
index 61063ce91..969fedf8b 100644
--- a/lib/mountlist.c
+++ b/lib/mountlist.c
@@ -227,6 +227,7 @@ me_remote (char const *fs_name, char const *fs_type 
_GL_UNUSED)
   || ((Fs_name)[0] == '/'\
   && (Fs_name)[1] == '/' \
   && (strcmp (Fs_type, "smbfs") == 0 \
+|| strcmp (Fs_type, "smb3") == 0   \
   || strcmp (Fs_type, "cifs") == 0)) \
   || (strcmp("-hosts", Fs_name) == 0))
  #endif



Yes I see .name = "smb3" in the kernel source for cifs.
Pushed.

thanks,
Pádraig