Bruno Haible [Sat, 22 Jun 2024 19:59:50 +0000 (21:59 +0200)]
obstack-zprintf: Add tests.
* tests/test-obstack-printf.h: New file, based on
tests/test-obstack-printf.c.
* tests/test-obstack-printf.c: Include test-obstack-printf.h.
(obstack_chunk_alloc, obstack_chunk_free, test_function): Moved to
tests/test-obstack-printf.h.
(test_obstack_vprintf, test_obstack_printf): Remove functions.
(main): Inline them here.
* tests/test-obstack-zprintf.c: New file, based on
tests/test-obstack-printf.c.
* modules/obstack-printf-tests (Files): Add tests/test-obstack-printf.h.
* modules/obstack-zprintf-tests: New file.
Bruno Haible [Sat, 22 Jun 2024 10:21:51 +0000 (12:21 +0200)]
c-vasprintf: Make return convention consistent with other modules.
* lib/c-vasprintf.h (c_asprintf, c_vasprintf): Add specification.
* lib/c-asprintf.c: Replaced with code based on lib/asprintf.c.
* lib/c-vasprintf.c: Replaced with code based on lib/vasprintf.c.
* modules/c-vasprintf (Depends-on): Add stdint.
(License): Change to LGPLv2+.
Bruno Haible [Sat, 22 Jun 2024 10:21:46 +0000 (12:21 +0200)]
c-vazsprintf: New module.
* lib/c-vasprintf.h: Change license to LGPLv2+.
Include <stddef.h>.
(c_azsprintf, c_vazsprintf): New declarations.
* lib/c-azsprintf.c: New file, based on lib/azsprintf.c.
* lib/c-vazsprintf.c: New file, based on lib/vazsprintf.c.
* modules/c-vazsprintf: New file.
Bruno Haible [Sat, 22 Jun 2024 10:21:29 +0000 (12:21 +0200)]
c-zsnprintf: New module.
* lib/c-snprintf.h: Change license to LGPLv2+.
(c_zsnprintf): New declaration.
* lib/c-zsnprintf.c: New file, based on lib/zsnprintf.c.
* modules/c-zsnprintf: New file.
Bruno Haible [Sat, 22 Jun 2024 10:21:11 +0000 (12:21 +0200)]
c-vzsnprintf: New module.
* lib/c-vsnprintf.h: Change license to LGPLv2+.
(c_vzsnprintf): New declaration.
* lib/c-vzsnprintf.c: New file, based on lib/vzsnprintf.c.
* modules/c-vzsnprintf: New file.
Bruno Haible [Sat, 22 Jun 2024 10:17:51 +0000 (12:17 +0200)]
xvasprintf: Guarantee a non-NULL result.
* lib/xvasprintf.h: Clarify the programmer's responsibilities.
(xasprintf, xvasprintf): Declare as returning non-NULL.
* lib/xvasprintf.c: Include <stdlib.h>.
(xstrcat): Allow results longer than INT_MAX characters. Upon size
overflow, invoke xalloc_die.
(xvasprintf): Call vazsprintf instead of vasprintf. When some other
error occurs, emit an error message and abort.
* m4/strerrorname_np.m4 (gl_CHECK_STRERRORNAME_NP): New macro, extracted
from gl_FUNC_STRERRORNAME_NP.
(gl_FUNC_STRERRORNAME_NP): Invoke it.
(gl_OPTIONAL_STRERRORNAME_NP): New macro.
* m4/xvasprintf.m4 (gl_XVASPRINTF): Invoke gl_OPTIONAL_STRERRORNAME_NP.
* modules/xvasprintf (Files): Add m4/strerrorname_np.m4.
(Depends-on): Add extensions, vazsprintf. Remove vasprintf.
* NEWS: Mention the change.
Bruno Haible [Sat, 22 Jun 2024 10:17:10 +0000 (12:17 +0200)]
vasprintf: Make return convention consistent with other modules.
* lib/vasprintf.c: Include <stdint.h>.
(vasprintf): If the length is > PTRDIFF_MAX, fail with ENOMEM, not
EOVERFLOW.
* modules/vasprintf (Depends-on): Add stdint.
Bruno Haible [Sat, 22 Jun 2024 10:17:02 +0000 (12:17 +0200)]
vazsprintf: New module.
* lib/stdio.in.h (azsprintf, vazsprintf): New declarations.
* lib/vazsprintf.c: New file, based on lib/vasprintf.c.
* lib/azsprintf.c: New file, based on lib/asprintf.c.
* m4/stdio_h.m4 (gl_STDIO_H_REQUIRE_DEFAULTS): Initialize
GNULIB_VAZSPRINTF.
* modules/stdio (Makefile.am): Substitute GNULIB_VAZSPRINTF.
* modules/vazsprintf: New file.
Bruno Haible [Sat, 22 Jun 2024 10:16:24 +0000 (12:16 +0200)]
zsprintf: New module.
* lib/stdio.in.h (zsprintf): New declaration, based on
lib/sprintf.c.
* lib/zsprintf.c: New file, based on lib/sprintf.c.
* m4/stdio_h.m4 (gl_STDIO_H_REQUIRE_DEFAULTS): Initialize
GNULIB_ZSPRINTF.
* modules/stdio (Makefile.am): Substitute GNULIB_ZSPRINTF.
* modules/zsprintf: New file.
Bruno Haible [Sat, 22 Jun 2024 10:16:00 +0000 (12:16 +0200)]
vzsprintf: New module.
* lib/stdio.in.h (vzsprintf): New declaration, based on
lib/vsprintf.c.
* lib/vzsprintf.c: New file, based on lib/vsprintf.c.
* m4/stdio_h.m4 (gl_STDIO_H_REQUIRE_DEFAULTS): Initialize
GNULIB_VZSPRINTF.
* modules/stdio (Makefile.am): Substitute GNULIB_VZSPRINTF.
* modules/vzsprintf: New file.
Bruno Haible [Sat, 22 Jun 2024 10:15:32 +0000 (12:15 +0200)]
zsnprintf: New module.
* lib/stdio.in.h (zsnprintf): New declaration, based on
lib/snprintf.c.
* lib/zsnprintf.c: New file, based on lib/snprintf.c.
* m4/stdio_h.m4 (gl_STDIO_H_REQUIRE_DEFAULTS): Initialize
GNULIB_ZSNPRINTF.
* modules/stdio (Makefile.am): Substitute GNULIB_ZSNPRINTF.
* modules/zsnprintf: New file.
Bruno Haible [Sat, 22 Jun 2024 10:14:41 +0000 (12:14 +0200)]
vzsnprintf: New module.
* lib/stdio.in.h (vzsnprintf): New declaration, based on
lib/vsnprintf.c.
* lib/vzsnprintf.c: New file, based on lib/vsnprintf.c.
* m4/stdio_h.m4 (gl_STDIO_H_REQUIRE_DEFAULTS): Initialize
GNULIB_VZSNPRINTF.
* modules/stdio (Makefile.am): Substitute GNULIB_VZSNPRINTF.
* modules/vzsnprintf: New file.
Paul Eggert [Thu, 20 Jun 2024 04:19:42 +0000 (00:19 -0400)]
sigsegv: avoid unlikely undefined behavior
Problem found by Coverity for diffutils and reported by Wasser Mai in:
https://bugs.gnu.org/71535
* lib/stackvma.c (rof_open) [__linux__ || __FreeBSD__ || etc]:
Don’t assume result of ‘read’ fits in int.
Avoid undefined behavior if ‘n + MIN_LEFTOVER’ would overflow.
Also, move a test to be after an (n == 0) test, to help the compiler.
Bruno Haible [Wed, 19 Jun 2024 23:31:21 +0000 (01:31 +0200)]
vasnwprintf tests: Add test of %s directive with large arguments.
* tests/test-vasnwprintf-big.c: New file, based on
tests/test-vasnprintf-big.c.
* modules/vasnwprintf-extra-tests: New file.
* modules/vasnwprintf-tests (Depends-on): Depend on it.
Bruno Haible [Wed, 19 Jun 2024 23:27:12 +0000 (01:27 +0200)]
u8-asnprintf tests: Fix mistake.
* tests/unistdio/test-u8-asnprintf-big.c: Include <unistr.h>.
(main): Use u8_strlen instead of strlen.
* modules/unistdio/u8-asnprintf-extra-tests (Depends-on): Add
unistr/u8-strlen.
Bruno Haible [Wed, 19 Jun 2024 18:58:18 +0000 (20:58 +0200)]
ulc-asnprintf tests: Add test of %U, %s directives with large arguments.
* tests/unistdio/test-ulc-asnprintf-big.c: New file, based on
tests/test-vasnprintf-big.c.
* modules/unistdio/ulc-asnprintf-extra-tests: New file.
* modules/unistdio/ulc-asnprintf-tests (Depends-on): Depend on it.
Bruno Haible [Wed, 19 Jun 2024 18:56:17 +0000 (20:56 +0200)]
u8-asnprintf tests: Add test of %U, %s directives with large arguments.
* tests/unistdio/test-u8-asnprintf-big.c: New file, based on
tests/test-vasnprintf-big.c.
* modules/unistdio/u8-asnprintf-extra-tests: New file.
* modules/unistdio/u8-asnprintf-tests (Depends-on): Depend on it.
Bruno Haible [Wed, 19 Jun 2024 12:57:40 +0000 (14:57 +0200)]
u*-vasnprintf: Fix a rare memory leak.
* lib/vasnprintf.c (VASNPRINTF): Use ENSURE_ALLOCATION_ELSE instead of
ENSURE_ALLOCATION, to free temporary allocations before failing due to
out-of-memory.
Bruno Haible [Wed, 19 Jun 2024 00:58:34 +0000 (02:58 +0200)]
copysignl tests: Avoid failure on Solaris 11.4.
* tests/test-copysignl.c: Include <float.h>.
(LDBL_BYTES): New macro.
(main): Use it instead of sizeof (long double).
* modules/copysignl-tests (Depends-on): Add float.
Bruno Haible [Tue, 18 Jun 2024 17:18:27 +0000 (19:18 +0200)]
u*-vasnprintf: Fix handling of %ls, %lc directives on Solaris, MSVC.
* lib/vasnprintf.c (VASNPRINTF): When implementing the %ls, %lc
directives ourselves: Rename variable 'characters' to 'bytes'. Also
count characters, if necessary for the width handling. Fix
DCHAR_MBSNLEN invocation.
Bruno Haible [Tue, 18 Jun 2024 12:27:18 +0000 (14:27 +0200)]
c-nstrftime: Fix warning on platforms without strftime_l.
* lib/strftime.c: Add comment regarding HAVE_STRFTIME_L.
(underlying_strftime): Don't define if this function is not used.
Correct indentation. Simplify #if condition.
(__strftime_internal): Disable code that is not used on platforms
without strftime_l.
Paul Eggert [Tue, 18 Jun 2024 04:08:29 +0000 (21:08 -0700)]
Improve wording for Y2038 and largefile probes
This change syncs from Autoconf master.
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2024-06/msg00181.html
* m4/largefile.m4 (_AC_SYS_YEAR2038_PROBE)
(_AC_SYS_LARGEFILE_PROBE): Improve wording of chatter.
Paul Eggert [Tue, 18 Jun 2024 03:47:09 +0000 (20:47 -0700)]
nstrftime: fix bug with -0000 on Solaris 11
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2024-06/msg00201.html
* lib/strftime.c (strftime) [!_LIBC]: Move #undef up.
(underlying_strftime) [!_LIBC]: New function, containing most of
what __strftime_internal used to do at the underlying_strftime label.
(get_tm_zone): New function, containing much of what
__strftime_internal used to do for %Z.
Be consistent about using "UTC" rather than "GMT";
this changes behavior only on platforms lacking tm_zone.
(__strftime_internal): Use them to compute time zone abbreviation
when needed. Make ‘zone’ more local, and compute it only if
needed. Simplify by removing set_and_revert_tz local var and its
uses; no longer needed now that we have get_tm_zone. Do not
assume %EZ and %OZ are equivalent to %Z.
Paul Eggert [Mon, 17 Jun 2024 23:16:29 +0000 (16:16 -0700)]
nstrftime: improve fix for NetBSD link errors
This makes the NetBSD code thread-safe and presumably faster.
* lib/strftime.c (HAVE_NATIVE_TIME_Z): New macro.
(__strftime_internal): If HAVE_NATIVE_TIME_Z, use strftime_lz
or strftime_z instead of setting and reverting TZ.
* lib/time-internal.c: Remove, reverting recent change.
* lib/time_rz.c, modules/time_rz: Also revert recent changes,
since the relevant functions can now remain private to time_rz.c.
* m4/c-nstrftime.m4 (gl_C_GNU_STRFTIME): Check for strftime_lz.
* m4/nstrftime.m4 (gl_FUNC_GNU_STRFTIME): Check for strftime_z.
Bruno Haible [Mon, 17 Jun 2024 14:31:59 +0000 (16:31 +0200)]
time_rz: Fix link errors on NetBSD (regression yesterday).
* lib/time-internal.c: New file, extracted from lib/time_rz.c.
(tzgetname): New function.
* lib/time_rz.c (getenv_TZ, setenv_TZ, change_env, set_tz, revert_tz):
Moved to lib/time-internal.c.
* modules/time_rz (Files): Add lib/time-internal.c.
(Depends-on): Update.
(Makefile.am): Arrange to compile time-internal.c on all platforms.
Paul Eggert [Sun, 16 Jun 2024 22:48:24 +0000 (15:48 -0700)]
nstrftime: omit never-used code
* lib/strftime.c (__strftime_internal): Remove code protected by
‘#ifndef my_strftime’. my_strftime is always defined. This
code isn’t needed for POSIX conformance as it’s never used in glibc.
Paul Eggert [Sun, 16 Jun 2024 22:44:17 +0000 (15:44 -0700)]
nstrftime,time_rz: don’t depend on tzname
* lib/strftime.c (HAVE_TZNAME_ARRAY) [_LIBC]: Remove.
All uses removed.
(__strftime_internal): Simplify calculation of zone to be closer
to what glibc does. However, in Gnulib do not look at tzname as
this is problematic for all the usual reasons; instead, use the
underlying strftime with %Z, making sure that call to the
underlying strftime is now always compiled in the non-glibc case.
Set and revert TZ as needed around the underlying call.
* lib/time-internal.h (struct tm_zone)
[HAVE_TZNAME_ARRAY && !HAVE_STRUCT_TM_TM_ZONE]: Remove tzname_copy.
All uses removed.
(set_tz, revert_tz): Declare, as they’re now extern.
(local_tz): Move here from time_rz.c, and now a macro.
* lib/time_rz.c (save_abbr): Do not worry about tzname_copy,
since strftime.c no longer needs it. Instead, save abbrs
only from tm_zone.
* modules/c-nstrftime, modules/nstrftime, modules/time_rz:
(Depends-on): Remove tzname.
Paul Eggert [Sun, 16 Jun 2024 21:58:56 +0000 (14:58 -0700)]
parse-datetime: don’t depend on tzname
* lib/parse-datetime.y (TIME_ZONE_BUFSIZE): Move earlier.
(parser_control) [!HAVE_STRUCT_TM_TM_ZONE]:
New member tz_abbr, to save abbrs calculated by strftime %Z.
(populate_local_time_zone_table): New function, which
optimizes the HAVE_STRUCT_TM_TM_ZONE case as before,
and falls back on strftime with %Z otherwise.
Although strftime %Z can be more accurate than the old tzname
based method, the new heuristic is still wrong so often that it
probably doesn’t help all that much.
(parse_datetime_body): Use it.
* modules/parse-datetime (Depends-on): Remove tzname.
Paul Eggert [Sun, 16 Jun 2024 21:44:29 +0000 (14:44 -0700)]
time_r: refactor tm_zone tests
* m4/tm_gmtoff.m4 (gl_TM_GMTOFF): Also check for tm_zone
and define HAVE_STRUCT_TM_TM_ZONE accordingly.
* modules/time_r-tests (Files): Add m4/tm_gmtoff.m4.
(configure.ac): Simplify by using gl_TM_GMTOFF.
Bruno Haible [Sat, 15 Jun 2024 20:38:57 +0000 (22:38 +0200)]
doc: Update for glibc 2.39.
* doc/glibc-functions/pidfd_getpid.texi: New file.
* doc/glibc-functions/pidfd_spawn.texi: New file.
* doc/glibc-functions/pidfd_spawnp.texi: New file.
* doc/glibc-functions/posix_spawnattr_getcgroup_np.texi: New file.
* doc/glibc-functions/posix_spawnattr_setcgroup_np.texi: New file.
* doc/gnulib.texi: Include them.
Bruno Haible [Sat, 15 Jun 2024 14:49:54 +0000 (16:49 +0200)]
doc: Update for glibc 2.36.
* doc/posix-functions/c8rtomb.texi: Update.
* doc/posix-functions/mbrtoc8.texi: Update.
* doc/glibc-functions/arc4random.texi: New file.
* doc/glibc-functions/arc4random_buf.texi: New file.
* doc/glibc-functions/arc4random_uniform.texi: New file.
* doc/glibc-functions/fsconfig.texi: New file.
* doc/glibc-functions/fsmount.texi: New file.
* doc/glibc-functions/fsopen.texi: New file.
* doc/glibc-functions/fspick.texi: New file.
* doc/glibc-functions/mount_setattr.texi: New file.
* doc/glibc-functions/move_mount.texi: New file.
* doc/glibc-functions/open_tree.texi: New file.
* doc/glibc-functions/pidfd_getfd.texi: New file.
* doc/glibc-functions/pidfd_open.texi: New file.
* doc/glibc-functions/pidfd_send_signal.texi: New file.
* doc/glibc-functions/process_madvise.texi: New file.
* doc/glibc-functions/process_mrelease.texi: New file.
* doc/gnulib.texi: Include them.
(Glibc sys/pidfd.h): New section.
Paul Eggert [Sat, 15 Jun 2024 06:11:05 +0000 (23:11 -0700)]
timespec-add,timespec-sub: tune
* lib/timespec-add.c (timespec_add):
* lib/timespec-sub.c (timespec_sub):
Simplify by detecting overflow when the two overflow bits of the
underlying operation differ. This avoids some gotos and labels
and conditional branches; GCC 14 x86-64 now generates just one
conditional branch for the resulting code. Idea stolen from
my recent changes to the glibc manual’s time chapter.
* modules/timespec-add (Depends-on):
* modules/timespec-sub (Depends-on): Add stdbool.
Bruno Haible [Sat, 15 Jun 2024 01:51:50 +0000 (03:51 +0200)]
doc: Update for glibc 2.35.
* doc/glibc-functions/_dl_find_object.texi: New file.
* doc/glibc-functions/epoll_pwait2.texi: New file.
* doc/glibc-functions/posix_spawn_file_actions_addtcsetpgrp_np.texi: New
file.
* doc/posix-functions/dfmal.texi: New file.
* doc/posix-functions/dsqrtl.texi: New file.
* doc/posix-functions/ffma.texi: New file.
* doc/posix-functions/ffmal.texi: New file.
* doc/posix-functions/fmaximum.texi: New file.
* doc/posix-functions/fmaximum_mag.texi: New file.
* doc/posix-functions/fmaximum_mag_num.texi: New file.
* doc/posix-functions/fmaximum_mag_numf.texi: New file.
* doc/posix-functions/fmaximum_mag_numl.texi: New file.
* doc/posix-functions/fmaximum_magf.texi: New file.
* doc/posix-functions/fmaximum_magl.texi: New file.
* doc/posix-functions/fmaximum_num.texi: New file.
* doc/posix-functions/fmaximum_numf.texi: New file.
* doc/posix-functions/fmaximum_numl.texi: New file.
* doc/posix-functions/fmaximumf.texi: New file.
* doc/posix-functions/fmaximuml.texi: New file.
* doc/posix-functions/fminimum.texi: New file.
* doc/posix-functions/fminimum_mag.texi: New file.
* doc/posix-functions/fminimum_mag_num.texi: New file.
* doc/posix-functions/fminimum_mag_numf.texi: New file.
* doc/posix-functions/fminimum_mag_numl.texi: New file.
* doc/posix-functions/fminimum_magf.texi: New file.
* doc/posix-functions/fminimum_magl.texi: New file.
* doc/posix-functions/fminimum_num.texi: New file.
* doc/posix-functions/fminimum_numf.texi: New file.
* doc/posix-functions/fminimum_numl.texi: New file.
* doc/posix-functions/fminimumf.texi: New file.
* doc/posix-functions/fminimuml.texi: New file.
* doc/posix-functions/fsqrt.texi: New file.
* doc/posix-functions/fsqrtl.texi: New file.
* doc/gnulib.texi: Include them.
Bruno Haible [Sat, 15 Jun 2024 00:23:01 +0000 (02:23 +0200)]
doc: More updates for glibc 2.34.
* doc/glibc-functions/ns_name_compress.texi: New file.
* doc/glibc-functions/ns_name_ntop.texi: New file.
* doc/glibc-functions/ns_name_pack.texi: New file.
* doc/glibc-functions/ns_name_pton.texi: New file.
* doc/glibc-functions/ns_name_skip.texi: New file.
* doc/glibc-functions/ns_name_uncompress.texi: New file.
* doc/glibc-functions/ns_name_unpack.texi: New file.
* doc/gnulib.texi (Glibc arpa/nameser.h): New section.
Paul Eggert [Fri, 14 Jun 2024 21:29:18 +0000 (14:29 -0700)]
xsize: port to SIZE_MAX <= INT_MAX
* lib/xsize.h (xsum): Port to oddball platforms where SIZE_MAX <=
INT_MAX. Although no such platform is a current Gnulib porting
problems, it’s easy enough to port to them.
Paul Eggert [Fri, 14 Jun 2024 17:58:24 +0000 (10:58 -0700)]
sigsegv-tests: port to plain POSIX
* tests/test-sigsegv-catch-segv1.c, tests/test-sigsegv-catch-segv2.c:
(SIGSEGV_FAULT_ADDRESS_ROUNDOFF_BITS):
Use sysconf (_SC_PAGESIZE) instead of getpagesize, as this code is
compiled only on platforms that have _SC_PAGESIZE and POSIX
prefers the latter.
Paul Eggert [Fri, 14 Jun 2024 17:54:36 +0000 (10:54 -0700)]
free-posix-tests: port to plain POSIX
* tests/test-free.c (main): Use sysconf (_SC_PAGESIZE) instead of
getpagesize, as this code is compiled only on platforms that have
_SC_PAGESIZE and POSIX prefers the latter.
Paul Eggert [Fri, 14 Jun 2024 17:47:06 +0000 (10:47 -0700)]
mprotect: don’t assume pointers fit in long
* m4/mprotect.m4 (gl_FUNC_MPROTECT_WORKS): Don’t assume pointers
fit into unsigned long, as this is not true on CheriBSD. Prefer
sysconf (_SC_PAGESIZE) to getpagesize.
Paul Eggert [Fri, 14 Jun 2024 17:42:40 +0000 (10:42 -0700)]
memchr,strncat: prefer sysconf (_SC_PAGESIZE)
* m4/memchr.m4 (gl_FUNC_MEMCHR):
* m4/strncat.m4 (gl_FUNC_STRNCAT):
Use sysconf (_SC_PAGESIZE) instead of getpagesize, as it’s
in POSIX and there’s no point to worrying about getpagesize
performance advantages here.
Paul Eggert [Fri, 14 Jun 2024 17:26:30 +0000 (10:26 -0700)]
getcwd: simplify abort bug checking
* m4/getcwd-abort-bug.m4 (gl_FUNC_GETCWD_ABORT_BUG): Don’t invoke
gl_CHECK_FUNC_GETPAGESIZE or #define or use HAVE_GETPAGESIZE.
Protect ‘bug_possible’ with ‘defined _SC_PAGESIZE’ instead.
That’s good enough as the buggy platforms all define _SC_PAGESIZE.
* modules/getcwd (Files): Remove m4/getpagesize.m4.
* tests/test-getcwd.c (getpagsize): Remove replacement macro.
(test_abort_bug): Similar fix for ‘bug_possible’.