Bruno Haible [Sun, 7 Feb 2021 18:31:02 +0000 (19:31 +0100)]
relocatable-prog: Add support for MidnightBSD.
* m4/relocatable.m4 (gl_RELOCATABLE_BODY): Use the ELF $ORIGIN trick
also on MidnightBSD >= 1.1.
* build-aux/config.libpath: Treat MidnightBSD like FreeBSD.
* build-aux/reloc-ldflags: Likewise.
Paul Eggert [Sat, 6 Feb 2021 01:08:29 +0000 (17:08 -0800)]
regex: debug check for set member duplicates
* lib/regex_internal.c (re_node_set_insert): Add a DEBUG_ASSERT
that would have caught some recently-fixed performance bugs
that caused sets to contain duplicate members.
Paul Eggert [Sat, 6 Feb 2021 01:08:10 +0000 (17:08 -0800)]
regex: fix longstanding backref match bug
This fixes a longstanding glibc bug concerning backreferences
<https://sourceware.org/11053> (2009-12-04).
* lib/regexec.c (proceed_next_node, push_fail_stack)
(pop_fail_stack): Push and pop the previous registers
as well as the current ones. All callers changed.
(set_regs): Also pop if CUR_NODE has already been checked,
so that it does not get added as a duplicate set entry.
(update_regs): Fix comment location.
* tests/test-regex.c (tests): New constant.
(bug_regex11): New test function.
(main): Bump alarm value. Call new test function.
Paul Eggert [Sat, 6 Feb 2021 00:35:46 +0000 (16:35 -0800)]
regex: avoid duplicate in espilon closure
* lib/regcomp.c (calc_eclosure_iter): Insert NODE into epsilon
closure first rather than last. Otherwise, the epsilon closure
might contain a duplicate of NODE.
Paul Eggert [Sat, 6 Feb 2021 00:35:45 +0000 (16:35 -0800)]
regex: avoid undefined behavior
* lib/regexec.c (pop_fail_stack): If the stack is empty, return -1
instead of indulging in undefined behavior. This simplifies
callers, and avoids undefined behavior in some cases (see glibc
bug 11053, though this change does not fix that overall bug).
Paul Eggert [Sat, 23 Jan 2021 18:19:24 +0000 (10:19 -0800)]
libc-config: port to Xcode 7
Problem reported by Mattias Engdegård in:
https://lists.gnu.org/r/emacs-devel/2021-01/msg01089.html
* lib/cdefs.h (__nonnull): If already defined but glibc is not in
use, override the definition with Gnulib’s _GL_ATTRIBUTE_NONNULL.
This is needed for Xcode 7, which has a ‘#define __nonnull
_Nonnull’ builtin for backwards-compatibility with an older Xcode
syntax that GNUish code never uses.
Paul Eggert [Thu, 21 Jan 2021 21:40:16 +0000 (13:40 -0800)]
Port FALLTHROUGH to clang 3.4 and earlier
Problem reported by Akim Demaille in:
https://lists.gnu.org/r/bug-gnulib/2021-01/msg00241.html
* lib/cdefs.h (__glibc_has_attribute):
* m4/gnulib-common.m4 (gl_COMMON_BODY):
Do not trust __has_attribute in clang 3.4 and earlier, as
<https://releases.llvm.org/3.5.0/tools/clang/docs/ReleaseNotes.html>
says that __has_attribute is unreliable in these old versions.
Simon Josefsson [Wed, 20 Jan 2021 10:50:21 +0000 (11:50 +0100)]
gc-random: Replace implementation with call to getrandom.
* lib/gc-gnulib.c [GNULIB_GC_RANDOM]: Replace #include's with
those needed for getrandom.
(gc_init): Remove old randomness code.
(gc_done): Likewise.
(randomize): Rewrite using getrandom, inspired by getentropy.
* m4/gc-random.m4: Remove file.
* modules/crypto/gc-random: Drop gc-random.m4, gl_GC_RANDOM, and
LIB_GC_RANDOM. Add conditional dependency on getrandom.
* modules/crypto/gc-tests (test_gc_LDADD): Drop LIB_GC_RANDOM.
Bruno Haible [Wed, 20 Jan 2021 08:39:55 +0000 (09:39 +0100)]
exec*e tests: Avoid test failures on Cygwin.
* tests/test-execle-main.c (main): On Cygwin, add /bin to the new PATH.
* tests/test-execve-main.c (main): Likewise.
* tests/test-execvpe-main.c (main): Likewise.
Bruno Haible [Wed, 20 Jan 2021 08:14:18 +0000 (09:14 +0100)]
canonicalize-lgpl: Work around a Cygwin bug.
* m4/canonicalize.m4 (gl_FUNC_REALPATH_WORKS): Test for lstat. Add a
test case that involves a symbolic link to an existing file.
* doc/posix-functions/realpath.texi: Mention the Cygwin bug.
Paul Eggert [Wed, 20 Jan 2021 02:35:30 +0000 (18:35 -0800)]
fnmatch, regex, fts: FALLTHROUGH consistency
Be more consistent about how FALLTHROUGH is defined.
For Gnulib, use attribute.h. For glibc, use __GNUC__ >= 7.
Problem for glibc reported by Vaseeharan Vinayagamoorthy in:
https://sourceware.org/pipermail/libc-alpha/2021-January/121778.html
* lib/fnmatch.c (FALLTHROUGH) [_LIBC]:
* lib/regex_internal.h (FALLTHROUGH) [_LIBC]:
Don’t worry about Clang, as it’s not needed and provokes GCC.
* lib/fts.c (FALLTHROUGH) [!_LIBC]:
* lib/regex_internal.h (FALLTHROUGH) [!_LIBC]:
Rely on attribute.h for FALLTHROUGH
* modules/regex: Depend on attribute module.
Bruno Haible [Sun, 17 Jan 2021 23:32:52 +0000 (00:32 +0100)]
immutable: Implement on native Windows.
* lib/immutable.h (IMMUTABLE_EFFECTIVE): Set to 1 on native Windows.
* lib/immutable.c: Include <windows.h>.
(CreateFileMapping): New macro.
(init_pagesize, init_mmap_file, alloc_pages, free_pages): Add
implementation for native Windows.
Bruno Haible [Sun, 17 Jan 2021 21:07:14 +0000 (22:07 +0100)]
canonicalize-lgpl: Work around // handling in realpath() of musl 1.2.2.
Reported by Natanael Copa <ncopa@alpinelinux.org> in
<https://lists.gnu.org/archive/html/bug-gettext/2021-01/msg00021.html>.
* m4/canonicalize.m4 (gl_FUNC_REALPATH_WORKS): Add a test whether // is
the same as /, on Linux only.
* lib/canonicalize-lgpl.c: Correct indentation of preprocessor
directives.
* doc/posix-functions/realpath.texi: Mention the musl 1.2.2 bug.
Bruno Haible [Sun, 17 Jan 2021 08:22:11 +0000 (09:22 +0100)]
argp tests: Avoid test failures on Alpine Linux.
* tests/test-argp-2.sh: Use the test framework (init.sh). Use the
'compare' function instead of 'diff -c'.
* tests/test-argp-version-etc-1.sh: Likewise.
Paul Eggert [Wed, 13 Jan 2021 23:46:33 +0000 (15:46 -0800)]
verify: simplify static_assert configuration
* lib/verify.h (_GL_HAVE__STATIC_ASSERT, _GL_HAVE__STATIC_ASSERT1):
Do not define for C++. This should be good enough nowadays,
since recent-enough C++ compilers have static_assert.
(_GL_HAVE_STATIC_ASSERT_CXX11, _GL_HAVE_STATIC_ASSERT_CXX17):
Remove. All uses replaced by simply checking __cpp_static_assert.
* doc/ld-output-def.texi (Visual Studio Compatibility): Install
.def files into libdir, not bindir. Have libfoo-*.def file depend
on libfoo.la to fix parallell builds.
Bruno Haible [Tue, 12 Jan 2021 20:11:13 +0000 (21:11 +0100)]
verify: Use C++11 static_assert when available.
Reported by Alexandre Duret-Lutz <adl@lrde.epita.fr> in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00177.html>.
* lib/verify.h (_GL_HAVE_STATIC_ASSERT_CXX11): New macro.
(_GL_HAVE_STATIC_ASSERT_CXX17): Renamed from _GL_HAVE_STATIC_ASSERT1.
(_GL_VERIFY): Use static_assert when available with C++11 syntax.
Paul Eggert [Tue, 12 Jan 2021 00:46:12 +0000 (16:46 -0800)]
tempname: consume less entropy
Derived from a glibc patch proposed by Adhemerval Zanella in:
https://sourceware.org/pipermail/libc-alpha/2021-January/121302.html
* lib/tempname.c: Include stdbool.h.
(random_bits): New arg use_getrandom.
(try_tempname_len): Skip getrandom on the first try,
unless __GT_NOCREATE.
* modules/tempname (Depends-on): Add stdbool.
Bruno Haible [Sun, 10 Jan 2021 00:13:04 +0000 (01:13 +0100)]
immutable: New module.
* lib/immutable.h: New file.
* lib/immutable.c: New file.
* m4/immutable.m4: New file.
* m4/mprotect.m4: New file, based on libffcall/m4/codeexec.m4.
* modules/immutable: New file.
Paul Eggert [Sat, 9 Jan 2021 22:17:32 +0000 (14:17 -0800)]
snippet/_Noreturn: port to pedantic clang
Problem reported by Joe Nelson in:
https://lists.gnu.org/r/bug-gnulib/2021-01/msg00152.html
* doc/noreturn.texi: Improve.
* lib/_Noreturn.h (_Noreturn):
* m4/gnulib-common.m4 (gl_COMMON_BODY):
Do not assume _Noreturn works as-is when __STRICT_ANSI__ is
defined, unless __STDC_VERSION__ indicates C11 or later.
* lib/_Noreturn.h (_Noreturn): Fall back on __attribute__
((__noreturn__)) if Clang; this merges the
2020-08-10T23:53:13Zbruno@clisp.org patch to m4/gnulib-common.m4.