* doc/glibc-functions/eventfd.texi: New file.
* doc/glibc-functions/eventfd_read.texi: New file.
* doc/glibc-functions/eventfd_write.texi: New file.
* doc/gnulib.texi (Glibc sys/eventfd.h): New section.
Bruno Haible [Mon, 10 Jun 2019 12:08:13 +0000 (14:08 +0200)]
doc: Mention inotify_* functions.
* doc/glibc-functions/inotify_add_watch.texi: New file.
* doc/glibc-functions/inotify_init.texi: New file.
* doc/glibc-functions/inotify_init1.texi: New file.
* doc/glibc-functions/inotify_rm_watch.texi: New file.
* doc/gnulib.texi (Glibc sys/inotify.h): New section.
Bruno Haible [Mon, 10 Jun 2019 12:08:10 +0000 (14:08 +0200)]
doc: Add references to glibc documentation.
* doc/glibc-functions/add-links.sh: Renamed from
doc/glibc-functions/add-manpage-link.sh. Emit also a link to the Glibc manual.
* doc/glibc-functions/*.texi: Add references to the glibc manual.
Bruno Haible [Mon, 10 Jun 2019 12:08:09 +0000 (14:08 +0200)]
doc: Add references to Linux man pages.
* doc/glibc-functions/add-manpage-link.sh: New file.
* doc/glibc-functions/*.texi: Add reference to man page on kernel.org when it
exists.
* doc/posix-functions/aligned_alloc.texi: Likewise.
Paul Eggert [Thu, 6 Jun 2019 22:44:33 +0000 (15:44 -0700)]
copy-file-range: simplify into a stub
Based on a comment by Florian Weimer in:
https://lists.gnu.org/r/bug-gnulib/2019-06/msg00007.html
It turns out that Emacs (which will use this module) won’t need an
emulation and I suspect other programs won’t either, because these
programs will need to fall back on read+write anyway. Perhaps I
am wrong and other programs will be able to use an emulation; if
so, this patch can be reverted.
* lib/copy-file-range.c (COPY_FILE_RANGE): Replace with a stub.
Just call it copy_file_range.
* m4/copy-file-range.m4 (gl_FUNC_COPY_FILE_RANGE):
Check via AC_LINK_IFELSE.
* modules/copy-file-range (Depends-on): Remove modules no longer used.
Paul Eggert [Wed, 5 Jun 2019 02:58:23 +0000 (19:58 -0700)]
copy-file: prefer copy_file_range
* lib/copy-file.c: Do not include xalloc.h.
(qcopy_file_preserving): Allocate a buffer only if
copy_file_range does not suffice. If the allocation fails
don't give up; just use a small stack-based buffer.
Prefer copy_file_range if it works.
* modules/copy-file (Depends-on): Add copy-file-range.
Remove xalloc.
Bruno Haible [Wed, 29 May 2019 00:44:52 +0000 (02:44 +0200)]
binary-io: Attempted use of O_BINARY on consoles no longer fails.
Reported by KO Myung-Hun <komh78@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2019-05/msg00124.html>.
* lib/binary-io.h (__gl_setmode_check): Remove function.
(set_binary_mode): Declare as notinline on DJGPP and EMX.
* lib/binary-io.c (__gl_setmode_check): Remove function.
(set_binary_mode): Define here on DJGPP and EMX. Inline
__gl_setmode_check. In case of a tty, don't return an error code.
Bruno Haible [Mon, 20 May 2019 19:25:01 +0000 (21:25 +0200)]
setlocale: Improve fallback on macOS.
* lib/setlocale.c (search): Optimize away a redundant strcmp()
invocation.
(locales_with_principal_territory): New array.
(langcmp, get_main_locale_with_same_language): New functions.
(locales_with_principal_language): New array.
(terrcmp, get_main_locale_with_same_territory): New functions.
(rpl_setlocale): When setlocale_single failed, try again with a locale
that is more likely to exist. Don't warn if the environment variable
SETLOCALE_VERBOSE is not set.
Bruno Haible [Mon, 20 May 2019 00:56:53 +0000 (02:56 +0200)]
localename: Fix default on macOS.
* m4/intlmacosx.m4 (gt_INTL_MACOSX): Don't test for CFLocaleCopyCurrent.
* lib/localename.c: Remove includes for HAVE_CFLOCALECOPYCURRENT.
(gl_locale_name_environ, gl_locale_name_default): Remove code for
HAVE_CFLOCALECOPYCURRENT.
* lib/localename.h (gl_locale_name_default): Update.
Bruno Haible [Sat, 18 May 2019 12:36:33 +0000 (14:36 +0200)]
pthread_sigmask: Fix compilation error with --enable-threads=windows.
Reported by Tim Rühsen in
<https://lists.gnu.org/archive/html/bug-gnulib/2018-01/msg00018.html>
and Michele Locati in
<https://lists.gnu.org/archive/html/bug-gettext/2019-04/msg00057.html>.
* m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK): Revert change from
2015-06-01. Test whether pthread_sigmask is a macro, regardless of
$LIBMULTITHREAD. Consider it regardless whether module 'threadlib' is
in use and regardless which threads API is chosen.
Paul Eggert [Tue, 14 May 2019 15:20:29 +0000 (08:20 -0700)]
close-stream, closein, closeout: simplify
I noticed this opportunity for simplification while drafting a
new, related module that I haven’t had time to finish yet.
* m4/close-stream.m4, m4/closein.m4, m4/closeout.m4: Remove.
* modules/close-stream (Files): Remove m4/close-stream.m4.
(configure.ac): Omit gl_CLOSE_STREAM.
* modules/closein (Files): Remove m4/closein.m4
(configure.ac): Omit gl_CLOSEIN.
* modules/closeout (Files): Remove m4/closeout.m4.
(configure.ac): Omit gl_CLOSEOUT.
Bruno Haible [Fri, 10 May 2019 14:08:38 +0000 (16:08 +0200)]
base64: Avoid false positive warning from Coverity.
Reported by Kamil Dudka <kdudka@redhat.com>.
Idea by Paul Eggert.
* lib/base64.c (base64_encode_fast, base64_encode): Add a no-op
'& 0x3f' to the array index expressions. This convinces Coverity that
there is no out-of-bounds array reference, regardless of the input.
Paul Eggert [Thu, 9 May 2019 15:57:56 +0000 (08:57 -0700)]
Support C2X and C++17 static_assert
C2X and C++17 finally added support for a simple, single-argument
‘static_assert’ that implements what the Gnulib ‘verify’ macro was
doing back in 2005. Implement static_assert on older platforms.
The only remaining advantage of ‘verify’ is a shorter name.
* doc/posix-headers/assert.texi (assert.h):
* doc/verify.texi (Compile-time Assertions):
Modernize for C2X and C++17.
* lib/verify.h (_GL_HAVE__STATIC_ASSERT1, _GL_HAVE_STATIC_ASSERT1):
New macros.
(_GL_HAVE__STATIC_ASSERT): Remove.
(_GL_HAVE__STATIC_ASSERT): Rely more heavily on __STDC_VERSION__.
(_GL_VERIFY_TRUE, _GL_VERIFY_TYPE): Remove 2nd arg, the diagnostic
string. All callers changed.
(_GL_VERIFY): Require 3 or more args, of which only the first 2
are used. All callers changed.
(_Static_assert): Allow either 1 or 2 args, and define if
!_GL_HAVE__STATIC_ASSERT1 instead of defining if
!_GL_HAVE__STATIC_ASSERT.
(static_assert): Define if !_GL_HAVE_STATIC_ASSERT1 instead
of defining if !_GL_HAVE_STATIC_ASSERT.
(verify_expr, verify): Don’t bother trying to copy the expression
into the diagnostic, since 1-argument static_assert doesn’t.
(verify): Prefer 1-argument _Static_assert if it works.
* m4/assert_h.m4 (gl_ASSERT_H): Check for 1-argument static_assert.
Bruno Haible [Sun, 5 May 2019 11:18:23 +0000 (13:18 +0200)]
wcwidth: Ensure width 1, not 2, for ambiguous characters.
Reported by Kiyoshi KANAZAWA <yoi_no_myoujou@yahoo.co.jp>
via Akim Demaille <akim.demaille@gmail.com>.
* m4/wcwidth.m4 (gl_FUNC_WCWIDTH): Check the width of U+2202. Use an
en_US.UTF-8 locale, since that is more likely to be present than an
fr_FR.UTF-8 locale.
* tests/test-wcwidth.c (main): Check the width of U+2202.
* doc/posix-functions/wcwidth.texi: Mention the issue.
Bruno Haible [Sun, 28 Apr 2019 09:21:41 +0000 (11:21 +0200)]
tls tests: Prevent that the test takes too long.
* tests/test-tls.c: Include <signal.h>, <unistd.h>.
(main): Let the test fail if it takes more than 10 minutes.
* modules/tls-tests (configure.ac): Test whether 'alarm' is declared.
Bruno Haible [Sat, 27 Apr 2019 22:19:33 +0000 (00:19 +0200)]
lock tests: Prevent that the test takes too long.
* tests/test-lock.c: Include <signal.h>, <unistd.h>.
(main): Let the test fail if it takes more than 10 minutes.
* modules/lock-tests (configure.ac): Test whether 'alarm' is declared.
* lib/argmatch.h, lib/argmatch.c (argmatch, argmatch_valid)
(__xargmatch_internal, argmatch_to_argument): Use void* for pointers
to "values", keep char* for strings.
Bernhard Voelker [Thu, 18 Apr 2019 21:04:26 +0000 (23:04 +0200)]
di-set: allow free with 'ino_map' being NULL
* lib/di-set.c (di_set_free): Avoid ino_map_free() when dis->ino_map
is NULL. Bug introduced in commit 3703dbbe88dd.
* tests/test-di-set.c: Add di_set_free() right after di_set_alloc()
as a test.
mountlist: make parsing /proc/self/mountinfo more robust
Cater for the following issues with mountinfo parsing (the first
one was reported by Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
in <https://bugs.gnu.org/35137>).
1. The fields source, target, mntroot and fstype may contain characters
like '\r'; sscanf(3) fails to read such values with the %s format
specifier because it would stop at such characters.
Example: "mount -t tmpfs tmpfs /foo^Mbar".
The only true separator in that file is the ' ' character.
2. The source field may be an empty string, which happens e.g. with
"mount -t tmpfs '' /target".
3. The fstype field may contain mangled characters as well which need
unescaping.
* lib/mountlist.c (terminate_at_blank): Add utility function.
(read_file_system_list): In the block trying to read the mountinfo file,
avoid using sscanf(3) with %s format; instead, parse the above fields
separated by spaces one by one.
This also handles the case when the source field is an empty string.
Unescape the fstype field.
Bruno Haible [Sun, 24 Mar 2019 22:12:03 +0000 (23:12 +0100)]
term-style-control: New module.
* lib/term-style-control.h: New file, based on libtextstyle's
term-ostream.oo.h and term-ostream.oo.c.
* lib/term-style-control.c: New file, based on libtextstyle's
term-ostream.oo.c.
* modules/term-style-control: New file.
Bruno Haible [Sat, 23 Mar 2019 20:39:37 +0000 (21:39 +0100)]
futimens: Document musl libc bug.
* doc/posix-functions/futimens.texi: Mention the bug.
* m4/futimens.m4 (gl_FUNC_FUTIMENS): Require AC_CANONICAL_HOST. When
cross-compiling, guess no on glibc and musl systems.
Akim Demaille [Mon, 18 Mar 2019 17:27:27 +0000 (18:27 +0100)]
bitset: expose bitset_resize
* lib/bitset.h (bitset_resize): Bounce on the polymorphic implementation.
* tests/test-bitset.c (check_attributes): Check bitset_resize.
(main): Use a variable bitset as reference, since fixed does not support resize.
Bruno Haible [Tue, 19 Mar 2019 23:37:52 +0000 (00:37 +0100)]
libtextstyle-optional: Add tests.
* tests/test-libtextstyle.c: New file, based on libtextstyle's
adhoc-tests/hello.c.
* tests/test-libtextstyle-default.css: New file, copied from
libtextstyle's adhoc-tests/hello-default.css.
* modules/libtextstyle-optional-tests: New file.
Bruno Haible [Tue, 19 Mar 2019 23:35:11 +0000 (00:35 +0100)]
libtextstyle-optional: New module.
* lib/textstyle.in.h: New file, based on libtextstyle's textstyle.h.
* m4/libtextstyle-optional.m4: New file, based on m4/libtextstyle.m4.
* modules/libtextstyle-optional: New file.
Bruno Haible [Tue, 19 Mar 2019 22:32:42 +0000 (23:32 +0100)]
Help making signal handlers more reliable.
* m4/gnulib-common.m4 (gl_COMMON_BODY): Emit definition of
_GL_ASYNC_SAFE into config.h.
* lib/nanosleep.c (sighandler): Mark as _GL_ASYNC_SAFE.
* lib/fatal-signal.h (at_fatal_signal): Add _GL_ASYNC_SAFE marker to
argument.
* lib/fatal-signal.c (action_t, uninstall_handlers,
fatal_signal_handler): Mark as _GL_ASYNC_SAFE.
* lib/clean-temp.c (cleanup_action): Mark as _GL_ASYNC_SAFE.
* lib/wait-process.c (cleanup_slaves, cleanup_slaves_action): Mark as
_GL_ASYNC_SAFE.
* lib/c-stack.h (c_stack_action): Add _GL_ASYNC_SAFE marker to argument.
* lib/c-stack.c: Add _GL_ASYNC_SAFE markers.