Paul Eggert [Fri, 7 Nov 2025 06:38:55 +0000 (22:38 -0800)]
stdcountof-h: allow compound literal args
* lib/stdcountof.in.h (countof, _gl_verify_is_array):
Allow arguments that are compound literals, and thus
appear as multiple arguments to a C macro.
* tests/test-stdcountof-h.c: Test for this.
Paul Eggert [Thu, 6 Nov 2025 22:32:10 +0000 (14:32 -0800)]
stdio-windows: fix <stdarg.h> include position
Problem reported by Andy Moreton in:
https://lists.gnu.org/r/bug-gnulib/2025-11/msg00059.html
* lib/stdio-consolesafe.c [__MINGW32__ && __USE_MINGW_ANSI_STDIO]:
Include <stdarg.h> even if HAVE_VASPRINTF
Collin Funk [Wed, 5 Nov 2025 03:56:18 +0000 (19:56 -0800)]
nproc: Fix compilation error with Android API ≤ 20.
Reported by Po Lu in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-11/msg00027.html>.
* lib/nproc.c (cgroup2_mount): Don't assume we have setmntent if we have
mntent.h.
* m4/nproc.m4 (gl_PREREQ_NPROC): Check if setmntent is supported by the
current Android API.
Paul Eggert [Tue, 4 Nov 2025 16:10:49 +0000 (08:10 -0800)]
time_rz: tzfree now preserves errno
This is consistent with bleeding-edge TZDB and with POSIX 'free'.
* lib/time.in.h (tzfree) [!HAVE_TZALLOC]: Replace tzfree.
I suspect Android and NetBSD (the major implementations) don’t
always preserve errno, and it’s easier to replace tzfree everywhere.
* lib/time_rz.c: Always include errno.h.
(tzfree) [HAVE_TZALLOC]: New replacement function.
(set_tz): Do not bother to save and restore errno,
now that tzfree preserves errno.
* modules/time_rz (Depends-on): Add free-posix.
(configure.ac, Makefile.am): Always compile time_rz.c.
Paul Eggert [Mon, 3 Nov 2025 05:05:04 +0000 (21:05 -0800)]
fchmodat: don’t depend on openat
* modules/fchmodat (Depends-on): Remove openat. Even though
fchmodat.c calls openat, that call is used only on platforms
that do not need anything that the openat module supplies.
Removing the unnecessary dependency simplifies GNU Emacs.
Lukáš Zaoral [Thu, 23 Oct 2025 07:16:52 +0000 (09:16 +0200)]
fts: Introduce the FTS_MOUNT flag.
This mimics behaviour of the FTW_MOUNT flag described in nftw(3) which
implements the behaviour of find(1) -mount primary standardized by
POSIX.1-2024.
* lib/fts.in.h (FTS_MOUNT): New flag.
(FTS_OPTIONMASK): Adjust.
(FTS_NAMEONLY): Adjust.
(FTS_STOP): Adjust.
* lib/fts.c (fts_read): Implement FTS_MOUNT.
(fts_build): Do not skip stat(2) when FTS_MOUNT as set.
Pádraig Brady [Sat, 18 Oct 2025 20:47:52 +0000 (21:47 +0100)]
doc: mcel: give more detail on error interface
* lib/mcel.h: Mention that errors may be given on
some systems even with the "C" locale, as mcel
has explicitly disabled the workaround for:
https://sourceware.org/PR29511
Also state that len is set to 1 on any error.
Paul Eggert [Sun, 2 Nov 2025 00:45:12 +0000 (18:45 -0600)]
nstrftime: do not return PTRDIFF_MAX
Previously, nstrftime (NULL, SIZE_MAX, ...) could return
PTRDIFF_MAX, which would cause problems in the common case
where the caller adds 1 to the result in order to allocate.
To avoid this, arrange for nstrftime to return at most PTRDIFF_MAX - 1.
* lib/strftime.c (__strftime_internal) [FAILURE && !FPRINTFTIME]:
Silently ceiling MAXSIZE to PTRDIFF_MAX.
* lib/strftime.c (SBYTE_COUNT_MAX): Remove.
(incr_overflow): New macro.
(width_add): Use it.
(__strftime_internal): Omit no-longer-needed local.
Fail If the width overflows rather than substituting
SBYTE_COUNT_MAX, as the latter approach is unreliable.
Paul Eggert [Sat, 1 Nov 2025 16:54:55 +0000 (10:54 -0600)]
nstrftime: do not preserve errno on success
* NEWS: Mention this, and coalesce recent changes for the
benefit of future readers.
* lib/strftime.c (__strftime_internal):
Preserve errno only if FAILURE == 0,
for consistency with other functions returning -1 on failure.
Bruno Haible [Sat, 1 Nov 2025 13:17:10 +0000 (14:17 +0100)]
openat2 tests: Avoid test failure on native Windows.
* tests/test-openat2.c (do_prepare_symlinks): New function, extracted
from do_prepare.
(main): Invoke it before do_test_resolve, do_test_basic. Disable these
tests on native Windows.
Paul Eggert [Sat, 1 Nov 2025 04:22:50 +0000 (22:22 -0600)]
fprintftime: return negative on output error
* lib/strftime.c (FPUTC) [FPRINTFTIME]:
New macro. All uses of fputc changed to FPUTC.
(width_cpy) [FPRINTFTIME]: Do not ignore fwrite failure.
(fwrite_lowcase, fwrite_uppcase) [FPRINTFTIME]:
Remove. All uses replaced with inline code.
Bruno Haible [Fri, 31 Oct 2025 22:54:37 +0000 (23:54 +0100)]
posix_spawn_file_actions_addclose: Ignore test failure on NetBSD 10.0.
Based on comments by Collin Funk and Grisha Levit.
* m4/posix_spawn.m4 (gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE): Revert
last change.
* tests/test-posix_spawn_file_actions_addclose.c (main): Treat NetBSD
like musl and Cygwin.
* doc/posix-functions/posix_spawn_file_actions_addclose.texi: Document
the large fd bug as "not fixed".
Paul Eggert [Fri, 31 Oct 2025 00:04:48 +0000 (18:04 -0600)]
fprintftime: sbyte_count_t to fix some overflows
* lib/strftime.c: Include <stdint.h>, for PTRDIFF_MAX.
(byte_count_t): Now a typedef instead of a macro.
(sbyte_count_t): New typedef.
(SBYTE_COUNT_MAX): New macro.
(memset_byte, width_add, __strftime_internal):
(fwrite_lowcase, fwrite_uppcase) [FPRINTFTIME]:
Avoid overflow issues with fprintftime by using byte_count_t
or sbyte_count_t instead of size_t or int.
* modules/nstrftime: Depend on stdint-h.
Bruno Haible [Thu, 30 Oct 2025 11:56:21 +0000 (12:56 +0100)]
fprintftime: Avoid size_t overflow for very large outputs.
Reported by Jeff Epler <jepler@unpythonic.net> in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-10/msg00126.html>.
* lib/fprintftime.h: Include <sys/types.h>.
(fprintftime): Change return type to off64_t.
* lib/strftime.c (byte_count_t): New macro.
(my_strftime, __strftime_internal): Change return type to off64_t.
* modules/fprintftime (Depends-on): Add sys_types-h.
* NEWS: Mention the change.
Paul Eggert [Wed, 29 Oct 2025 04:15:11 +0000 (21:15 -0700)]
openat2: port O_TMPFILE check to non-GNU/Linux
* lib/openat2.c (openat2): Don’t assume !!(O_TMPFILE & O_DIRECTORY).
Although true on GNU/Linux, it is a hack and might not be true on
other systems such as Cygwin.
Paul Eggert [Wed, 29 Oct 2025 00:03:28 +0000 (17:03 -0700)]
openat2-tests: port to FreeBSD, NetBSD
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2025-10/msg00117.html
* tests/test-openat2.c (is_nofollow_error): New function.
(do_test_resolve): Use it.
Bruno Haible [Tue, 28 Oct 2025 21:11:11 +0000 (22:11 +0100)]
posix_spawn_file_actions_addclose: Fix test failure on NetBSD 10.0.
* m4/posix_spawn.m4 (gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE): Test
also against the NetBSD bug.
* doc/posix-functions/posix_spawn_file_actions_addclose.texi: Document
the NetBSD bug.
Paul Eggert [Tue, 28 Oct 2025 00:00:53 +0000 (17:00 -0700)]
openat2: new module
This supports the openat2 system call of Linux 5.6 (2020) and
later. Although not yet exposed by glibc, the call is useful for
programs like GNU Tar that need to be paranoid about traversing
file names from untrusted sources. On platforms lacking
openat2, it is emulated in user space.
* lib/openat2.c, m4/openat2.m4, modules/openat2:
* modules/openat2-tests, tests/test-openat2.c: New files.
* lib/fcntl.in.h (struct open_how, RESOLVE_NO_XDEV)
(RESOLVE_NO_MAGICLINKS, RESOLVE_NO_SYMLINKS, RESOLVE_BENEATH)
(RESOLVE_IN_ROOT, RESOLVE_CACHED):
New type and constants, if <linux/openat2.h> does not define.
(openat2): New decls.
* m4/fcntl_h.m4 (gl_FCNTL_H, gl_FCNTL_H_REQUIRE_DEFAULTS)
(gl_FCNTL_H_DEFAULTS):
* modules/fcntl-h (fcntl.h):
Also check for openat2.
Paul Eggert [Mon, 27 Oct 2025 20:38:08 +0000 (13:38 -0700)]
stdcountof-tests: pacify ODS 12.6
* tests/test-stdcountof-h.c (test_func) [__SUNPRO_C]: Omit tests
involving u"xxx" and u8"...", as Oracle Developer Studio 12.6
lacks support for this despite claiming C11 conformance.
(a, b, c) [__SUNPRO_C]: Define; ODS 12.6 has the same bug as MSVC 14.
Paul Eggert [Fri, 24 Oct 2025 06:35:36 +0000 (23:35 -0700)]
doc: mention -fsanitize-trap=all etc
* doc/gnulib-readme.texi: Mention _GLIBCXX_ASSERTIONS,
-fsanitize-trap=all, -fhardened.
Problem reported by Basil L. Contovounesios in:
https://lists.gnu.org/r/bug-gnulib/2025-10/msg00068.html
Bruno Haible [Thu, 23 Oct 2025 14:14:15 +0000 (16:14 +0200)]
stdioext: Add support for OpenBSD >= 7.8.
* lib/stdio-impl.h (fp_): Separate definitions for OpenBSD from those
for Android. Add definition for OpenBSD >= 7.8.
* lib/fflush.c (clear_ungetc_buffer, disable_seek_optimization,
update_fpos_cache, rpl_fflush): Don't test for __OpenBSD__, since
OpenBSD <= 7.7 is covered by the __sferror test and OpenBSD >= 7.8 does
not need the workarounds.
* lib/fseeko.c (fseeko): Likewise.
* lib/fpurge.c (fpurge): Likewise.
Bruno Haible [Thu, 23 Oct 2025 14:06:22 +0000 (16:06 +0200)]
stdioext: Revert unneeded changes in 2025-07-20 commit.
* lib/fpending.c (__fpending): Don't test for __OpenBSD__, since
OpenBSD >= 7.6 already has __fpending.
* lib/freadahead.c (freadahead): Don't test for __OpenBSD__, since
OpenBSD >= 7.6 already has __freadahead.
* lib/freading.c (freading): Don't test for __OpenBSD__, since
OpenBSD >= 7.6 already has __freading.
* lib/freadptr.c (freadptr): Don't test for __OpenBSD__, since
OpenBSD >= 7.6 already has __freadptr.
* lib/freadseek.c (freadptrinc): Don't test for __OpenBSD__, since
OpenBSD >= 7.6 already has __freadptrinc.
* lib/fseterr.c (fseterr): Don't test for __OpenBSD__, since
OpenBSD >= 7.6 already has __fseterr.
* lib/fwriting.c (fwriting): Don't test for __OpenBSD__, since
OpenBSD >= 7.6 already has __fwriting.
Collin Funk [Tue, 21 Oct 2025 03:50:21 +0000 (20:50 -0700)]
fenv-rounding tests: Avoid test failure on Android.
* tests/test-fenv-round.c (test_towardzero, test_upward)
(test_downward): Disable tests that are known to fail.
* doc/posix-functions/fesetround.texi: Update list of platforms.
Bruno Haible [Mon, 20 Oct 2025 19:13:39 +0000 (21:13 +0200)]
glob: Add support for Android.
Reported by Collin Funk in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-10/msg00054.html>.
* m4/glob.m4 (gl_GLOB): On Android, skip a test that assumes that
/bin/sh exists. Update cross-compilation guess.
* tests/test-glob.c (main): On Android, skip a test that assumes that
/bin/sh exists.
* doc/posix-functions/glob.texi: Mention also Android.
Collin Funk [Sat, 11 Oct 2025 05:34:19 +0000 (22:34 -0700)]
glob: Prevent a stack overflow with many slashes.
* lib/glob.c (__glob): Strip trailing slashes before making the
recursive call.
* m4/glob.m4 (gl_GLOB): Check for the glibc bug.
* doc/posix-functions/glob.texi: Mention the bug.
Bruno Haible [Mon, 13 Oct 2025 10:41:39 +0000 (12:41 +0200)]
getline: Fix compilation error in C++ mode (regression 2025-10-10).
* lib/stdio.in.h (getdelim): On glibc, define __getdelim instead of
rpl_getdelim.
(getline): In C++ mode, define getline as an inline function instead of
as a macro.
* lib/getdelim.c (getdelim): On glibc, don't test whether fp is NULL.
Collin Funk [Fri, 10 Oct 2025 03:41:09 +0000 (20:41 -0700)]
getline: Work around a glibc bug.
* m4/getline.m4 (gl_FUNC_GETLINE): Check that the buffer is terminated
with a NUL character when the first character read is EOF. Guess that
the function does not work on glibc.
* doc/posix-functions/getline.texi: Mention the bug.
Collin Funk [Fri, 10 Oct 2025 03:36:15 +0000 (20:36 -0700)]
getdelim: Work around a glibc bug.
* m4/getdelim.m4 (gl_FUNC_GETDELIM): Check that the buffer is terminated
with a NUL character when the first character read is EOF. Guess that
the function does not work on glibc.
* doc/posix-functions/getdelim.texi: Mention the bug.
Bruno Haible [Fri, 3 Oct 2025 19:51:11 +0000 (21:51 +0200)]
unimetadata/base: Add tests.
* tests/unimetadata/test-unimetadata-h.c: New file.
* modules/unimetadata/base-tests: New file.
* tests/unimetadata/test-unimetadata-h-c++.cc: New file.
* modules/unimetadata/base-c++-tests: New file.
Bruno Haible [Fri, 3 Oct 2025 19:51:08 +0000 (21:51 +0200)]
unicase/base: Add tests.
* tests/unicase/test-unicase-h.c: New file.
* modules/unicase/base-tests: New file.
* tests/unicase/test-unicase-h-c++.cc: New file.
* modules/unicase/base-c++-tests: New file.
Bruno Haible [Fri, 3 Oct 2025 19:51:05 +0000 (21:51 +0200)]
uninorm/base: Add tests.
* tests/uninorm/test-uninorm-h.c: New file.
* modules/uninorm/base-tests: New file.
* tests/uninorm/test-uninorm-h-c++.cc: New file.
* modules/uninorm/base-c++-tests: New file.
Bruno Haible [Fri, 3 Oct 2025 19:51:01 +0000 (21:51 +0200)]
unilbrk/base: Add tests.
* tests/unilbrk/test-unilbrk-h.c: New file.
* modules/unilbrk/base-tests: New file.
* tests/unilbrk/test-unilbrk-h-c++.cc: New file.
* modules/unilbrk/base-c++-tests: New file.
Bruno Haible [Fri, 3 Oct 2025 19:50:59 +0000 (21:50 +0200)]
uniwbrk/base: Add tests.
* tests/uniwbrk/test-uniwbrk-h.c: New file.
* modules/uniwbrk/base-tests: New file.
* tests/uniwbrk/test-uniwbrk-h-c++.cc: New file.
* modules/uniwbrk/base-c++-tests: New file.
Bruno Haible [Fri, 3 Oct 2025 19:50:56 +0000 (21:50 +0200)]
unigbrk/base: Add tests.
* tests/unigbrk/test-unigbrk-h.c: New file.
* modules/unigbrk/base-tests: New file.
* tests/unigbrk/test-unigbrk-h-c++.cc: New file.
* modules/unigbrk/base-c++-tests: New file.
Bruno Haible [Fri, 3 Oct 2025 19:50:53 +0000 (21:50 +0200)]
uniwidth/base: Add tests.
* tests/uniwidth/test-uniwidth-h.c: New file.
* modules/uniwidth/base-tests: New file.
* tests/uniwidth/test-uniwidth-h-c++.cc: New file.
* modules/uniwidth/base-c++-tests: New file.
Bruno Haible [Fri, 3 Oct 2025 19:50:51 +0000 (21:50 +0200)]
unictype/base: Add tests.
* tests/unictype/test-unictype-h.c: New file.
* modules/unictype/base-tests: New file.
* tests/unictype/test-unictype-h-c++.cc: New file.
* modules/unictype/base-c++-tests: New file.
Bruno Haible [Fri, 3 Oct 2025 19:50:48 +0000 (21:50 +0200)]
uniname/base: Add tests.
* tests/uniname/test-uniname-h.c: New file.
* modules/uniname/base-tests: New file.
* tests/uniname/test-uniname-h-c++.cc: New file.
* modules/uniname/base-c++-tests: New file.
Bruno Haible [Fri, 3 Oct 2025 19:50:46 +0000 (21:50 +0200)]
unistdio/base: Add tests.
* tests/unistdio/test-unistdio-h.c: New file.
* modules/unistdio/base-tests: New file.
* tests/unistdio/test-unistdio-h-c++.cc: New file.
* modules/unistdio/base-c++-tests: New file.
Bruno Haible [Fri, 3 Oct 2025 19:50:42 +0000 (21:50 +0200)]
uniconv/base: Add tests.
* tests/uniconv/test-uniconv-h.c: New file.
* modules/uniconv/base-tests: New file.
* tests/uniconv/test-uniconv-h-c++.cc: New file.
* modules/uniconv/base-c++-tests: New file.
Bruno Haible [Fri, 3 Oct 2025 19:50:29 +0000 (21:50 +0200)]
unistr/base: Add tests.
* tests/unistr/test-unistr-h.c: New file.
* modules/unistr/base-tests: New file.
* tests/unistr/test-unistr-h-c++.cc: New file.
* modules/unistr/base-c++-tests: New file.
Bruno Haible [Wed, 24 Sep 2025 21:28:18 +0000 (23:28 +0200)]
Update to Unicode 17.0.0.
* lib/gen-uni-tables.c (is_property_alphabetic): Add three
YANGQIN SIGNs.
(UC_JOINING_GROUP_THIN_NOON): New enum item.
(fill_arabicshaping, joining_group_as_c_identifier): Handle
UC_JOINING_GROUP_THIN_NOON.
(LBP_*): Split LBP_SA into LBP_SA1 and LBP_SA2.
(LBP_HH, LBP_SA): New enum items.
(get_lbp): Use them. Update such that unilbrk/lbrkprop.txt comes out as
expected.
(debug_output_lbp): Handle LBP_HH. Print either LBP_SA1, LBP_SA2 as
LBP_SA.
(fill_org_lbp, debug_output_org_lbp): Handle LBP_HH.
(lbp_value_to_string): Handle LBP_HH. Handle LBP_SA1, LBP_SA2 instead of
LBP_SA.
(output_lbrk_rules_as_tables): Update for LBP_HH change. Update rules
LBP12a, LB21 as specified by
https://www.unicode.org/reports/tr14/tr14-55.html.
(get_wbp): Update such that uniwbrk/wbrkprop.txt comes out as expected.
* lib/unictype.in.h (UC_JOINING_GROUP_THIN_NOON): New enum item.
* lib/unictype/joininggroup_byname.gperf: Handle it.
* lib/unictype/joininggroup_name.h: Likewise.
* lib/unilbrk/lbrktables.h (LBP_*): Split LBP_SA into LBP_SA1 and
LBP_SA2.
(LBP_HH): New enum item.
(unilbrk_table): Update bounds.
* lib/unilbrk/u8-possible-linebreaks.c (u8_possible_linebreaks_loop):
Use LBP_HL_HY instead of LBP_HL_BA. Use LBP_SA1 instead of LBP_SA. Treat
LBP_SA2 like LBP_CM. Update rules LB20a and LB21a, as specified by
https://www.unicode.org/reports/tr14/tr14-55.html.
* lib/unilbrk/u16-possible-linebreaks.c (u16_possible_linebreaks_loop):
Likewise.
* lib/unilbrk/u32-possible-linebreaks.c (u32_possible_linebreaks_loop):
Likewise.
* tests/unigbrk/test-u8-grapheme-breaks.c (main): Use U+2B50 instead of
U+2605, because U+2605 no longer is an Extended_Pictographic character.
* tests/unigbrk/test-u16-grapheme-breaks.c (main): Likewise.
* tests/unigbrk/test-u32-grapheme-breaks.c (main): Likewise.
* tests/unigbrk/test-u8-grapheme-next.c (main): Likewise.
* tests/unigbrk/test-u16-grapheme-next.c (main): Likewise.
* tests/unigbrk/test-u32-grapheme-next.c (main): Likewise.
* tests/unigbrk/test-u8-grapheme-prev.c (main): Likewise.
* tests/unigbrk/test-u16-grapheme-prev.c (main): Likewise.
* tests/unigbrk/test-u32-grapheme-prev.c (main): Likewise.
* tests/uniwidth/test-uc_width2.sh: Update expected test result.
* All generated files under lib/uni* and tests/uni*: Regenerate.
* tests/uniname/NameAliases.txt: Update.
* tests/uniname/UnicodeData.txt: Update.
* tests/uninorm/NormalizationTest.txt: Update.
* tests/unigbrk/GraphemeBreakTest.txt: Update.
* tests/uniwbrk/WordBreakTest.txt: Update.
* tests/unilbrk/LineBreakTest.txt: Update.
* All the affected modules: Bump required libunistring version.
Bruno Haible [Wed, 24 Sep 2025 21:28:14 +0000 (23:28 +0200)]
unilbrk: Fix handling of future emojis in rule LB30b.
* lib/unilbrk/lbrktables.h (LBP_ID): Renamed from LBP_ID1.
(LBP_EBF): Renamed from LBP_ID2.
* lib/gen-uni-tables.c (LBP_ID): Renamed from LBP_ID1.
(LBP_EBF): Renamed from LBP_ID2.
(get_lbp): Update. Move is_property_extended_pictographic invocation.
(debug_output_org_lbp): Augment the information from the LineBreak.txt
file with the Extended_Pictographic property. Print the LBP_ID and
LBP_EBF values distinctly.
(fill_org_lbp): Assign value LBP_EBF to all unassigned
Extended_Pictographic characters.
(debug_output_org_lbp): Handle LBP_EBF.
(lbp_value_to_string): Update.
(output_lbrk_rules_as_tables): Treat LBP_EBF like LBP_EB instead of like
LBP_ID.
* lib/unilbrk/u8-possible-linebreaks.c (u8_possible_linebreaks_loop):
Update.
* lib/unilbrk/u16-possible-linebreaks.c (u16_possible_linebreaks_loop):
Likewise.
* lib/unilbrk/u32-possible-linebreaks.c (u32_possible_linebreaks_loop):
Likewise.
* lib/unilbrk/lbrkprop2.h: Regenerated.
* lib/unilbrk/lbrktables.c: Regenerated.
* tests/unilbrk/test-uc-possible-linebreaks.c (main): Skip test cases
that contain the U+1F8FF character.
* modules/unilbrk/*-linebreaks: Bump required libunistring version.