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.
Akim Demaille [Sat, 16 Mar 2019 16:16:48 +0000 (17:16 +0100)]
bitset: fix overflows
Reported by Bruno Haible.
https://lists.gnu.org/archive/html/bug-gnulib/2019-03/msg00017.html
* lib/bitset/table.c (tbitset_test): last_bit is the position of
the bit in the array of bitset_word, so be sure to take its modulo
number-of-bits-in-bitset-word (i.e., EBITSET_ELT_WORDS).
* lib/bitset/list.c (lbitset_unused_clear): Likewise.
Bruno Haible [Sat, 16 Mar 2019 21:56:21 +0000 (22:56 +0100)]
fatal-signal: Pass the signal number to the action.
* lib/fatal-signal.h (at_fatal_signal): Change the signature.
* lib/fatal-signal.c (action_t): Take the signal number as parameter.
(fatal_signal_handler): Pass the signal number to the action.
* lib/clean-temp.c (cleanup_action): Renamed from cleanup. Take the
signal number as parameter.
(create_temp_dir): Update.
* lib/wait-process.c (cleanup_slaves_action): New function.
(register_slave_subprocess): Update at_fatal_signal invocation.
* NEWS: Mention the change.
Bruno Haible [Thu, 14 Mar 2019 22:54:28 +0000 (23:54 +0100)]
isatty: Make it return true in Cygwin consoles on native Windows.
* lib/isatty.c: Include <string.h>.
(GetProcAddress): New macro.
(GetNamedPipeClientProcessIdFuncType): New type.
(GetNamedPipeClientProcessIdFunc): New variable.
(QueryFullProcessImageNameFuncType): New type.
(QueryFullProcessImageNameFunc): New variable.
(initialized): New variable.
(initialize): New function.
(IsCygwinConsoleHandle): New function.
(isatty): Invoke it.
* doc/posix-functions/isatty.texi: Mention the issue.
Paul Eggert [Mon, 11 Mar 2019 23:40:29 +0000 (16:40 -0700)]
strtod: fix clash with strtold
Problem reported for RHEL 5 by Jesse Caldwell (Bug#34817).
* lib/strtod.c (compute_minus_zero, minus_zero):
Simplify by remving the macro / external variable,
and having just a function. User changed. This avoids
the need for an external variable that might clash.
Bruno Haible [Sun, 10 Mar 2019 19:39:34 +0000 (20:39 +0100)]
alloca-opt: Fix conflict mingw's new <alloca.h> file.
Reported by Eli Zaretskii <eliz@gnu.org>.
* lib/alloca.in.h: On mingw systems that have <alloca.h>, include that.
* m4/alloca.m4 (gl_FUNC_ALLOCA): Set HAVE_ALLOCA_H.
* modules/alloca-opt (Makefile.am): Substitute HAVE_ALLOCA_H.
* lib/get-rusage-as.c (get_rusage_as): When compiled by
"gcc -fsanitize=thread", don't try get_rusage_as_via_setrlimit.
* tests/test-pthread_sigmask2.c (main): Clean up the killer_thread
before exiting.
Jim Meyering [Sun, 10 Mar 2019 05:38:03 +0000 (21:38 -0800)]
test-userspec.c: don't print NULL
* tests/test-userspec.c (main): A test release of gcc,
9.0.1 20190310, warned that this test would attempt to
print a NULL pointer via a %s printf format. Fix that
and remove the unnecessary preceding "!diag" conjunct.
Also add a comment.
Bruno Haible [Sat, 9 Mar 2019 22:30:40 +0000 (23:30 +0100)]
strfmon_l: Fix -fsanitize=address finding.
* lib/strfmon_l.c: Include <errno.h>, <stdbool.h>, <stdlib.h>,
<string.h>.
(MAX_ARGS): Renamed from MAX_ARG_WORDS.
(directive_t, directives_t): New types.
(fmon_parse): New function.
(rpl_strfmon_l): Don't call va_arg more often than needed for the
format string. Consume 'long double' arguments in places where the
format string indicates so.
* modules/strfmon_l (Depends-on): Add 'stdbool'.
Bruno Haible [Sat, 9 Mar 2019 19:32:25 +0000 (20:32 +0100)]
Fix undefined behaviour.
* lib/bitrotate.h (rotl16, rotr16, rotl8, rotr8): Case x to
'unsigned int', to avoid shift operations on 'int'.
* lib/xmemdup0.c (xmemdup0): Don't invoke memcpy with a zero size.
* tests/test-count-leading-zeros.c (main): Use a random number that has
as many bits as TYPE, not only 2*15 or 2*31 bits.
* tests/test-count-trailing-zeros.c (main): Likewise.
* tests/test-count-one-bits.c (main): Likewise.
* tests/test-memmem.c: Don't include "null-ptr.h".
(main): Use zerosize_ptr() instead of null_ptr().
* modules/memmem-tests (Files): Remove tests/null-ptr.h.
Paul Eggert [Tue, 5 Mar 2019 23:05:33 +0000 (15:05 -0800)]
git-version-gen: fix --version copyright year
* build-aux/git-version-gen, build-aux/move-if-change (version):
--version output copyright year is now taken from script year,
so that it no longer needs to be updated by hand.
Bruno Haible [Mon, 4 Mar 2019 16:25:09 +0000 (17:25 +0100)]
relocatable-prog: Use wrapper-free installation on Mac OS X, take 2.
This approach supports relocatable installation of shared libraries
which depend on other shared libraries from the same package.
* m4/relocatable.m4 (gl_RELOCATABLE_BODY): Determine use_macos_tools.
If use_macos_tools is true, use reloc-ldflags and set LIBTOOL to be a
wrapper around the original LIBTOOL.
* build-aux/reloc-ldflags: Add support for Mac OS X, which uses the
token '@loader_path' instead of '$ORIGIN'.
* build-aux/libtool-reloc: New file.
* modules/relocatable-prog (Files): Add it.
* doc/relocatable-maint.texi (Supporting Relocation): Update to match
the recent changes. Document the need to set the *_LDFLAGS of libraries.
RELOCATABLE_LIBRARY_PATH and RELOCATABLE_CONFIG_H_DIR should be set in
Makefile.am, not in configure.ac.
Paul Eggert [Mon, 25 Feb 2019 07:32:07 +0000 (23:32 -0800)]
nstrftime: support the ‘+’ flag
* lib/nstrftime.c (add, __strftime_internal):
Add support for the ‘+’ flag introduced in POSIX.1-2017.
(__strftime_internal): New arg ‘width’. All uses changed.
(DO_YEARISH, DO_MAYBE_SIGNED_NUMBER): New macros.
Bruno Haible [Sun, 24 Feb 2019 10:59:48 +0000 (11:59 +0100)]
stat, lstat: Fix conflict with relocatable-prog-wrapper module.
* lib/stat.c: On platforms other than OSF/1, include <sys/stat.h>, not
"sys/stat.h".
* lib/lstat.c: Likewise.
* lib/fstat.c: Likewise.
* lib/fstatat.c: Likewise.
Bernhard Voelker [Thu, 29 Nov 2018 08:06:26 +0000 (09:06 +0100)]
long-options: add parse_gnu_standard_options_only
Discussed in https://bugs.gnu.org/33468 .
* lib/long-options.c (parse_long_options): Use EXIT_SUCCESS instead
of 0.
(parse_gnu_standard_options_only): Add function to
process the GNU default options --help and --version and fail for any other
unknown long or short option. See
https://gnu.org/prep/standards/html_node/Command_002dLine-Interfaces.html .
* lib/long-options.h (parse_gnu_standard_options_only): Declare it.
* modules/long-options (depends-on): Add stdbool, exitfail.
* top/maint.mk (sc_prohibit_long_options_without_use): Update
syntax-check rule, add new function name.