Bruno Haible [Wed, 25 Jun 2025 12:24:41 +0000 (14:24 +0200)]
kwset: New module.
* lib/kwset.h: New file, from GNU grep.
* lib/kwset.c: New file, from GNU grep.
Include <limits.h>, minmax.h. Don't include system.h.
(IGNORE_DUPLICATE_BRANCH_WARNING): New macro, from grep/src/system.h.
(NCHAR): New enum value, from grep/src/system.h.
(to_uchar): New function, from grep/src/system.h.
* modules/kwset: New file.
Paul Eggert [Wed, 25 Jun 2025 02:57:18 +0000 (19:57 -0700)]
Sort-of sync model bootstrap.conf from coreutils
* build-aux/bootstrap.conf (XGETTEXT_OPTIONS):
Sync from coreutils, providing flags for error, etc.
(gettext_external, excluded_files): Remove, as
excluded_files has not worked for a long time.
(bootstrap_post_import_hook): New function, doing
what the old excluded_files tried to do.
Paul Eggert [Tue, 17 Jun 2025 16:53:58 +0000 (09:53 -0700)]
boot-time: comment that it's for container not host
Comment that in Docker etc., get_boot_time returns the
boot time of the container, not of its host.
Also, give an example file instead of saying just “FILE”.
Paul Eggert [Tue, 17 Jun 2025 16:11:49 +0000 (09:11 -0700)]
listxattr: document Linux 6.15 bug
This bug should be fixed in Linux kernel 6.16; see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fe78e02600f83d81e55f6fc352d82c4f264a2901
For what it's worth, Coreutils decided not to work around the bug,
and instead to suggest updating to a fixed kernel or to a future
version of libattr with at least the following patches:
https://cgit.git.savannah.gnu.org/cgit/attr.git/commit/?id=58abfe6eba0d8d58a61ee8bee0615f74d393fff2
https://cgit.git.savannah.gnu.org/cgit/attr.git/commit/?id=504ab19d7b032212755ab3c7df16be98d5b5212e
Paul Eggert [Sun, 15 Jun 2025 05:45:48 +0000 (22:45 -0700)]
libgmp-mpz: require Baillie-PSW primality test
* m4/libgmp.m4 (gl_LIBGMP): Reject GMP 6.1.2 (2016) and earlier,
as these older versions had an inferior primality test and
coreutils factor.c will need Baillie-PSW. mini-gmp.c already has
Baillie-PSW, so it can serve as a fallback.
Bruno Haible [Thu, 12 Jun 2025 17:45:19 +0000 (19:45 +0200)]
stat, lstat, fstat tests: Enhance tests regarding /dev/null or NUL.
* tests/test-fstat.c: Include <fcntl.h>.
(main): Check that fstat reports /dev/null or NUL as a character device.
* tests/test-stat.h (test_stat_func): Likewise for stat.
* tests/test-lstat.h (test_lstat_func): Likewise for lstat.
Reported by Collin Funk in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-04/msg00215.html>.
* m4/fenv-environment.m4 (gl_FENV_ENVIRONMENT): Update comments for
mingw 13.
* lib/fenv-private.h (exceptions_to_x86hardware,
x86hardware_to_exceptions): On mingw >= 13, define these like on MSVC.
* lib/fenv-round.c (fegetround, fesetround): Do the safe mapping also on
mingw >= 13.
* lib/fenv-except-state-set.c (fesetexceptflag): Do the
exceptions_to_x86hardware conversion also on other platforms than MSVC.
* lib/fenv-except-tracking-clear.c (feclearexcept): Likewise.
* lib/fenv-except-tracking-set.c (fesetexcept): Likewise.
* lib/fenv-except-trapping.c (feenableexcept, fedisableexcept,
fegetexcept): Do the exceptions_to_x86hardware and
x86hardware_to_exceptions conversions also on other platforms than MSVC.
* lib/fenv-env.c (fegetenv, fesetenv): Add new implementation for
mingw >= 13.
* doc/posix-functions/fesetenv.texi: Mention the new mingw bug.
* doc/posix-functions/feupdateenv.texi: Mention the new mingw bug.
Paul Eggert [Mon, 9 Jun 2025 06:51:25 +0000 (23:51 -0700)]
parse-datetime: debug mktime failures better
* lib/parse-datetime.y (debug_mktime_not_ok):
Handle mktime failures too.
Don’t pretend that the time was normalized if mktime failed.
Don’t attempt to deduce DST shifts; it’s impractical in general
and even a reasonable heuristic is too painful.
Collin Funk [Sat, 7 Jun 2025 03:52:07 +0000 (20:52 -0700)]
doc: Add some missing Makefile targets.
* doc/Makefile (standards.pdf, maintain.info, maintain.html)
(maintain.dvi, maintain.pdf): New targets.
* doc/.gitignore: Add files generated when building GNU Maintainer
Information and GNU Standards.
Alec Brown [Wed, 4 Jun 2025 20:49:15 +0000 (20:49 +0000)]
regex: fix resource leak when searching
* lib/regex.c (merge_state_with_log):
In this function, memory is allocated for the variable next_nodes when
creating a union of the variables table_nodes and log_nodes.
However, if next_state->entrance_nodes is NULL, table_nodes becomes
NULL and we still allocate memory to copy the contents of log_nodes.
This can cause a resource leak since we only free the memory for
next_nodes if table_nodes isn't NULL. To prevent this, check that
next_state->entrance_nodes isn't NULL before allocating memory
for the union.
This issue was found by a Coverity Scan of GRUB2 under the following CID:
CID: 473887
Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
Copyright-paperwork-exempt: Yes
Paul Eggert [Fri, 6 Jun 2025 01:52:33 +0000 (18:52 -0700)]
regex: fix some leaks when pattern compilation fails
Problem reported by Alec Brown in:
https://lists.gnu.org/r/bug-gnulib/2025-06/msg00040.html
* lib/regcomp.c (create_initial_state, calc_eclosure_iter):
Fix some memory leaks when these functions fail.
Bruno Haible [Tue, 3 Jun 2025 21:28:11 +0000 (23:28 +0200)]
fcntl-h: Fix configure test on MSVC.
* m4/fcntl-o.m4 (gl_FCNTL_O_FLAGS): Reshuffle the exit code assignments
again, so that a compilation failure produces the "no" result both on
mingw and on MSVC. Fix typo in the test program.
Bruno Haible [Tue, 3 Jun 2025 02:59:58 +0000 (04:59 +0200)]
fcntl-h, open: Fix two regressions on native Windows (regr. 2025-05-26).
* m4/fcntl-o.m4 (gl_FCNTL_O_FLAGS): Reshuffle the exit code bits, so
that a compilation failure produces the "no" result.
* lib/open.c (open): Don't pass the O_DIRECTORY flag when doing
recursion with /dev/null.
Bruno Haible [Tue, 3 Jun 2025 09:26:45 +0000 (11:26 +0200)]
stdcountof-h: Always return size_t, in a better way.
* lib/stdcountof.in.h: Revert last change. Include <stddef.h>
unconditionally.
(countof): Cast value to size_t.
* tests/test-stdcountof-h.c (HAVE___TYPEOF__, HAVE__GENERIC): New
macros.
(test_func): Check the return type of countof.
Paul Eggert [Tue, 3 Jun 2025 01:58:24 +0000 (18:58 -0700)]
stdcountof-h: always return size_t
* lib/stdcountof.in.h (__SIZE_TYPE__): Define to size_t,
including stddef.h to get it, if not already defined.
This avoids a bit of namespace pollution.
All uses of size_t changed to use __SIZE_TYPE__.
(countof): Return size_t, even if size_t is narrower than int (!).
While we’re at it, simplify ‘sizeof ((a)[0])’ to ‘sizeof *(a)’
as it’s simpler and later code uses the ‘*(a)’ notation already.
Bruno Haible [Mon, 2 Jun 2025 21:44:55 +0000 (23:44 +0200)]
stdcountof-h: Add tests.
* tests/test-stdcountof-h.c: New file.
* tests/test-stdcountof-h-c++.cc: New file.
* modules/stdcountof-h-tests: New file.
* modules/stdcountof-h-c++-tests: New file.
Bruno Haible [Mon, 2 Jun 2025 16:32:26 +0000 (18:32 +0200)]
stddef-h: Fix compilation errors in C++ mode (regression 2025-05-27).
* m4/stddef_h.m4 (gl_STDDEF_H): Set and substitute HAVE_C_UNREACHABLE.
Don't test for unreachable in <stddef.h> in C++. Set
GL_GENERATE_STDDEF_H to true always.
* lib/stddef.in.h (gl_unreachable): Renamed from _gl_unreachable. Test
HAVE_C_UNREACHABLE.
(unreachable): Don't define in C++ mode. Don't define if
HAVE_C_UNREACHABLE is 1.
* modules/stddef-h (Makefile.am): Substitute HAVE_C_UNREACHABLE.
* tests/test-stddef-h.c (test_unreachable_optimization,
test_unreachable_noreturn): Don't define in C++ mode.
(test_gl_unreachable_optimization, test_gl_unreachable_noreturn): New
functions.
* tests/test-stddef-h-c++3.cc (test_cxx_unreachable_1): Test
gl_unreachable instead of unreachable.
* lib/error.in.h (__gl_error_call1): Use gl_unreachable instead of
unreachable.
Bruno Haible [Sat, 31 May 2025 23:07:53 +0000 (01:07 +0200)]
stat-time: Fix syntax errors in C++ mode on MSVC (regr. 2023-05-14).
* lib/stat-time.h (_gl_make_timespec): New macro / function.
(get_stat_atime, get_stat_ctime, get_stat_mtime, get_stat_birthtime):
Use it instead of a compound literal expression.
Bruno Haible [Sat, 31 May 2025 21:17:26 +0000 (23:17 +0200)]
Make gl_CHECK_FUNCS_MACOS work with current unreleased Autoconf.
Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-autoconf/2025-05/msg00024.html>.
* m4/gnulib-common.m4 (gl_CHECK_FUNCS_CASE_FOR_MACOS): Temporarily set
ac_c_future_darwin_options, ac_cxx_future_darwin_options to empty for
the second AC_CHECK_DECL invocation.
Paul Eggert [Fri, 30 May 2025 17:28:06 +0000 (10:28 -0700)]
listxattr: document Linux 6.14- bug
This bug is fixed in Linux kernel 6.15; see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8b0ba61d
For what it's worth, Coreutils decided not to work around the bug,
and instead to suggest updating to a fixed kernel.
Paul Eggert [Wed, 28 May 2025 19:31:45 +0000 (12:31 -0700)]
fcntl-safer-tests: also update this for fifos
* modules/fcntl-safer-tests (Depends-on): Add mkfifo.
(configure.ac) Check for alarm decl.
* tests/test-fcntl-safer.c:
Include sys/stat.h, for mkfifo.
[HAVE_DECL_ALARM]: Include signal.h, for alarm.
Paul Eggert [Wed, 28 May 2025 17:40:21 +0000 (10:40 -0700)]
open, openat: handle O_DIRECTORY on special files
On deficient platforms where we must check for directories
ourselves when opening files, check before opening as well as after.
This prevents a hang when trying to open a special file like a
fifo in a context where a directory is required. Although there
is still a race so we could still hang in a perverse situation,
it’s the best we can do and it is better than hanging in the
more-common case.
* lib/open.c (lstatif): New static function.
(open) [REPLACE_FCHDIR]: Also inspect O_CREAT.
* lib/open.c (open), lib/openat.c (rpl_openat):
When checking for directories, also do this before opening.
Also, respect O_NOFOLLOW when checking for directories.
* lib/openat.c: Remove a few more unnecessary differences from open.c.
* modules/open (Depends-on): Depend on lstat.
* modules/openat (Depends-on): Add fstatat.
* modules/open-tests, modules/openat-tests:
(configure.ac) Check for alarm decl.
* tests/test-open.c, tests/test-openat.c:
Include sys/stat.h, for mkfifo.
[HAVE_DECL_ALARM]: Include signal.h, for alarm.
* tests/test-open.h (test_open): Fail if test takes too long
because we tried to open a fifo. Test opening /dev/null,
/dev/tty and a fifo, with a trailing "/" and with O_DIRECTORY.
Bruno Haible [Wed, 28 May 2025 13:14:07 +0000 (15:14 +0200)]
gettext-h: Avoid gcc -Wformat-security warnings with --disable-nls.
Reported by Holger Hoffstätte <holger@applied-asynchrony.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-05/msg00225.html>.
* lib/gettext.h (gettext, dgettext, dcgettext): With gcc in C mode,
define these as inline functions.
* lib/sigpipe-die.c (sigpipe_die): Use translated string as a format
string, relying on the format string checking done by 'msgfmt -c'.
* lib/xmemcoll.c (collate_error): Revert commit from 2025-01-17.
* lib/xprintf.c (xvprintf, xvfprintf): Likewise.
* lib/openat-die.c (openat_save_fail, openat_restore_fail): Revert
commit from 2024-12-10.
Bruno Haible [Tue, 27 May 2025 23:59:05 +0000 (01:59 +0200)]
stddef-h: Make 'unreachable' usable in C++ mode.
Reported by Pierre Ossman <ossman@cendio.se>
at <https://savannah.gnu.org/bugs/?67152>.
* m4/stddef_h.m4 (gl_STDDEF_H): Also test whether unreachable is defined
by <stddef.h> in C++ mode.
* lib/stddef.in.h: In C++ mode, include <utility> and either import
'unreachable' from the std namespace or define it as an inline function.
* tests/test-stddef-h.c: Disable some tests in C++ mode.
* tests/test-stddef-h-c++.cc: Perform nearly the same tests in C++ mode
as in C mode.
* tests/test-stddef-h-c++2.cc: Rename some variables. Disable the NULL
test with clang on Windows.
* tests/test-stddef-h-c++3.cc: New file.
* modules/stddef-h-c++-tests (Files): Include it.
(Makefile.am): Link test-stddef-h-c++ with test-stddef-h-c++3.o.
Bruno Haible [Tue, 27 May 2025 09:24:45 +0000 (11:24 +0200)]
fcntl-h: Update platforms list re O_DIRECTORY.
* doc/posix-headers/fcntl.texi: Update platforms list.
* doc/posix-functions/open.texi: Likewise.
* doc/posix-functions/openat.texi: Likewise.
* m4/fcntl-o.m4 (gl_FCNTL_O_FLAGS): Guess that O_DIRECTORY works for
Mac OS X >= 10.5. Use prefix 'gl_', not 'ac_', for our variables.
Paul Eggert [Tue, 27 May 2025 01:30:18 +0000 (18:30 -0700)]
fcntl-h: support O_DIRECTORY
It is relatively easy to support O_DIRECTORY on platforms that
lack it, so let’s do that instead of having to work around bugs
like <https://bugs.gnu.org/78509#95>.
* lib/fcntl.in.h (O_DIRECTORY): Default to 0x20000000 not 0,
since Gnulib now supports it.
* lib/open.c, lib/openat.c (OPEN_TRAILING_SLASH_BUG):
Default to false, so that this can be used outside #if.
(open, openat): Add support for O_DIRECTORY on platforms that lack it.
If fstat fails, fail instead of assuming the file is a directory,
since failure can occur due to EOVERFLOW, etc.
Rearrange code to minimize differences between open.c and openat.c.
* m4/fcntl-o.m4 (gl_FCNTL_O_FLAGS): Also test O_DIRECTORY,
and define HAVE_WORKING_O_DIRECTORY if needed.
Prefer AS_CASE for Emacs’s benefit.
* m4/open.m4 (gl_FUNC_OPEN):
* m4/openat.m4 (gl_FUNC_OPENAT):
Require gl_FCNTL_O_FLAGS and replace the function
if O_DIRECTORY does not work.
* tests/test-open.h: Test O_DIRECTORY.
Collin Funk [Fri, 23 May 2025 02:33:05 +0000 (19:33 -0700)]
stdckdint-h: Don't generate header if it is not needed.
Suggested by Paul Eggert in:
<https://lists.gnu.org/archive/html/bug-gnulib/2025-05/msg00216.html>.
* m4/stdckdint_h.m4: New file.
* modules/stdckdint-h (Files): Add m4/stdckdint_h.m4.
(configure.ac): Remove checks and just invoke gl_STDCKDINT_H.
(Makefile.am): Replace variables set by ./configure.
* lib/stdckdint.in.h: Include the compilers header if it exists. Add
comment mentioning expected future standardization in C++26.
(ckd_add, ckd_sub, ckd_mul): Only define if the compilers definitions do
not work.
Paul Eggert [Mon, 19 May 2025 06:16:15 +0000 (23:16 -0700)]
tests: simplify test_exit_status decl
* tests/macros.h (test_exit_status) [!NO_MAIN_HERE]:
Declare test_exit_status too, as this is simpler
and we might as well check definition vs declaration.
Bruno Haible [Sun, 18 May 2025 23:53:23 +0000 (01:53 +0200)]
unigbrk/u*-grapheme-next: Support Indic, Emojis, regional indicators.
Reported by Kang-Che Sung <explorer09@gmail.com> in
<https://lists.gnu.org/archive/html/bug-libunistring/2025-03/msg00000.html>
and by Lich <author@lch361.net> in
<https://lists.gnu.org/archive/html/bug-libunistring/2025-05/msg00000.html>.
* lib/unigbrk/u-grapheme-next.h: New file, based on
lib/unigbrk/u-grapheme-breaks.h.
* lib/unigbrk/u8-grapheme-next.c: Include unictype.h and
u-grapheme-next.h.
(u8_grapheme_next): Remove function.
* lib/unigbrk/u16-grapheme-next.c: Include unictype.h and
u-grapheme-next.h.
(u16_grapheme_next): Remove function.
* lib/unigbrk/u32-grapheme-next.c: Include unictype.h and
u-grapheme-next.h.
(u32_grapheme_next): Remove function.
* modules/unigbrk/u8-grapheme-next (Files): Add
lib/unigbrk/u-grapheme-next.h.
(Depends-on): Remove unigbrk/uc-is-grapheme-break. Add unigbrk/base,
unigbrk/uc-gbrk-prop, unictype/incb-of,
unictype/property-extended-pictographic, bool.
(configure.ac): Bump required libunistring version.
* modules/unigbrk/u16-grapheme-next (Files): Add
lib/unigbrk/u-grapheme-next.h.
(Depends-on): Remove unigbrk/uc-is-grapheme-break. Add unigbrk/base,
unigbrk/uc-gbrk-prop, unictype/incb-of,
unictype/property-extended-pictographic, bool.
(configure.ac): Bump required libunistring version.
* modules/unigbrk/u32-grapheme-next (Files): Add
lib/unigbrk/u-grapheme-next.h.
(Depends-on): Remove unigbrk/uc-is-grapheme-break. Add unigbrk/base,
unigbrk/uc-gbrk-prop, unictype/incb-of,
unictype/property-extended-pictographic, bool.
(configure.ac): Bump required libunistring version.
* tests/unigbrk/test-u8-grapheme-next.c (main): Add more test cases,
from tests/unigbrk/test-u8-grapheme-breaks.c.
* tests/unigbrk/test-u16-grapheme-next.c (main): Add more test cases,
from tests/unigbrk/test-u16-grapheme-breaks.c.
* tests/unigbrk/test-u32-grapheme-next.c (main): Add more test cases,
from tests/unigbrk/test-u32-grapheme-breaks.c.
Bruno Haible [Sat, 17 May 2025 12:17:24 +0000 (14:17 +0200)]
crypto/sha512-buffer: Add some tests.
* tests/test-sha384-buffer.c: New file, based on
tests/test-sha1-buffer.c.
* tests/test-sha512-buffer.c: New file, based on
tests/test-sha1-buffer.c.
* modules/crypto/sha512-buffer-tests (Files): Add them.
(Makefile.am): Compile and test test-sha384-buffer, test-sha512-buffer.
Bruno Haible [Sat, 17 May 2025 12:16:01 +0000 (14:16 +0200)]
crypto/sha256-buffer: Add some tests.
* tests/test-sha224-buffer.c: New file, based on
tests/test-sha1-buffer.c.
* tests/test-sha256-buffer.c: New file, based on
tests/test-sha1-buffer.c.
* modules/crypto/sha256-buffer-tests (Files): Add them.
(Makefile.am): Compile and test test-sha224-buffer, test-sha256-buffer.