Paul Eggert [Mon, 18 Nov 2024 06:58:13 +0000 (22:58 -0800)]
savewd: set errnum for FINAL_STATE too
Problem reported by Grisha Levit in:
https://lists.gnu.org/r/bug-gnulib/2024-11/msg00137.html
* lib/savewd.c (savewd_finish):
Set errnum to 0 unless we were in an error state.
* lib/savewd.h (savewd_errno): Report final state errnum too.
* lib/md5-stream.c (GL_OPENSSL_INLINE): Remove definition, that caused
the symbols defined in md5.o to be defined in md5-stream.o as well.
* lib/sha1-stream.c (GL_OPENSSL_INLINE): Likewise.
* lib/sha256-stream.c (GL_OPENSSL_INLINE): Likewise.
* lib/sha512-stream.c (GL_OPENSSL_INLINE): Likewise.
* lib/sm3-stream.c (GL_OPENSSL_INLINE): Likewise.
Paul Eggert [Sun, 17 Nov 2024 17:30:24 +0000 (09:30 -0800)]
std-gnu23: sync from Autoconf
This fixes a problem reported from Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2024-11/msg00145.html
* m4/std-gnu23.m4 (_AC_C_C23_TEST_MAIN): Use null_ptr.
Paul Eggert [Sat, 16 Nov 2024 20:07:34 +0000 (12:07 -0800)]
std-gnu23: don’t test stdbit.h
Although freestanding C23 compilers must support <stdbit.h>,
some current sort-of-C23 environments lack it.
We still want to use options like -std=gnu23 on such platforms.
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2024-11/msg00141.html
* m4/std-gnu23.m4 (_AC_C_C23_TEST_GLOBALS): Do not test stdbit.h.
Paul Eggert [Sat, 16 Nov 2024 19:51:23 +0000 (11:51 -0800)]
std-gnu23: pacify GCC 15
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2024-11/msg00140.html
* m4/std-gnu23.m4 (_AC_C_C23_TEST_GLOBALS): Add parens.
While we’re at it, use sizeof so that the expression is a
conforming integer constant expression.
Paul Eggert [Thu, 14 Nov 2024 17:40:24 +0000 (10:40 -0700)]
mktime: don’t consult daylight
* lib/mktime.c (__mktime_internal): Do not consult __daylight
as it has unreliable contents - among other things, the user
can set it. It also wasn’t being configured properly for
mingw-w64; this problem was reported by Markus Muetzel in
<https://lists.gnu.org/r/bug-gnulib/2024-11/msg00126.html>.
* m4/mktime.m4 (gl_PREREQ_MKTIME): Do not check for ‘daylight’;
no longer needed.
Bruno Haible [Wed, 13 Nov 2024 00:25:26 +0000 (01:25 +0100)]
bootstrap: Tweak GNULIB_REFDIR related changes.
* top/bootstrap-funclib.sh (prepare_GNULIB_SRCDIR): Improve if/else
structure and comments. When cloning GNULIB_REFDIR and no submodule
'gnulib' is configured, switch to the default branch.
* top/bootstrap (usage): Update documentation.
* build-aux/bootstrap: Regenerated.
Paul Eggert [Tue, 12 Nov 2024 21:13:47 +0000 (13:13 -0800)]
bootstrap: avoid "cd"
* top/bootstrap-funclib.sh: Avoid "cd". This saves a few
subprocesses and is more likely to yield diagnostics that make
sense to the user.
* build-aux/bootstrap: Regenerate.
Paul Eggert [Tue, 12 Nov 2024 21:00:10 +0000 (13:00 -0800)]
bootstrap: go back to old non-submodule semantics
* top/bootstrap-funclib.sh (prepare_GNULIB_SRCDIR):
When cloning GNULIB_REFDIR and no submodule 'gnulib' is configured,
set the origin’s URL to $gnulib_url and fetch from remote,
so that GNULIB_REFDIR is merely an accelerant rather than
having different semantics.
* build-aux/bootstrap: Regenerate.
Paul Eggert [Tue, 12 Nov 2024 17:28:55 +0000 (09:28 -0800)]
bootstrap: tune Octave bootstrap --gnulib-refdir
* top/bootstrap-funclib.sh (prepare_GNULIB_SRCDIR):
Use GNULIB_REFDIR also when a submodule 'gnulib' is not configured.
This greatly speeds up bootstrapping Octave when using
‘./bootstrap --gnulib-refdir=...’.
* build-aux/bootstrap: Regenerate.
Paul Eggert [Tue, 12 Nov 2024 00:25:50 +0000 (16:25 -0800)]
openat: port lowest-fd to native MS-Windows
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2024-11/msg00081.html
* lib/openat.c (openat_permissive): When save_cwd allocates an FD,
allocate another one DFD and then close FD so that the later
open returns FD (the lowest available fd), as POSIX requires.
Paul Eggert [Mon, 11 Nov 2024 18:57:35 +0000 (10:57 -0800)]
file-has-acl: another nofollow fix for FreeBSD
* lib/file-has-acl.c (file_has_aclinfo): On FreeBSD, NetBSD >= 10,
if we don’t follow symlinks the first time, also don’t follow
them the second time, when it is typically a directory - so it
doesn’t matter whether symlinks are followed - but it might not be.
Paul Eggert [Mon, 11 Nov 2024 15:35:50 +0000 (07:35 -0800)]
file-has-acl: scontext even if --disable-acl
Be able to get the security context even if configured with
--disable-acl, as security contexts are not ACLs, and the
main reason for --disable-acl was for efficiency with GNU ls -l,
a concern that does not apply to security contexts (which are
needed only with ls -Z). Problem reported by Pádraig Brady
<https://bugs.gnu.org/73418#52>.
* lib/acl.h (ACL_GET_SCONTEXT): New constant.
(aclinfo_free, aclinfo_scontext_free): Declare even if !USE_ACL.
* lib/file-has-acl.c (USE_LINUX_XATTR): No longer false merely
because !USE_ACL, because we need xattr to get scontext.
(get_aclinfo): Support new ACL_GET_SCONTEXT flag.
Bruno Haible [Mon, 11 Nov 2024 08:33:11 +0000 (09:33 +0100)]
getpagesize: Fix use of 'extern inline' (regression 2012-11-20).
* lib/unistd.in.h (_GL_GETPAGESIZE_INLINE): New macro.
(getpagesize): Use it.
* lib/getpagesize.c (_GL_GETPAGESIZE_INLINE): Define.
* modules/getpagesize (configure.ac): Compile getpagesize.c also when
getpagesize is missing.
Bruno Haible [Mon, 11 Nov 2024 08:02:23 +0000 (09:02 +0100)]
realloc-posix: Fix link error (regression 2024-11-04).
* doc/extern-inline.texi (extern inline): Mention that one needs a
*_INLINE macro per compilation unit.
* lib/stdlib.in.h (_GL_REALLOC_INLINE): New macro.
(rpl_realloc): Use it. Don't test IN_GNULIB_TESTS.
* lib/realloc.c (_GL_REALLOC_INLINE): Define.
Bruno Haible [Mon, 11 Nov 2024 06:25:00 +0000 (07:25 +0100)]
file-has-acl: Fix compilation errors on macOS et al. (regr. 2024-11-09).
* m4/acl.m4 (gl_FUNC_ACL): Test whether acl_get_link_np exists.
* lib/file-has-acl.c (file_has_aclinfo): Use ACL_SYMLINK_FOLLOW, not
AC_SYMLINK_FOLLOW. Don't use acl_get_link_np if this function does not
exist.
Paul Eggert [Sat, 9 Nov 2024 22:52:05 +0000 (14:52 -0800)]
file-has-acl: symlinks can have scontext
Problem reported by Pádraig Brady <https://bugs.gnu.org/73418#35>.
* lib/file-has-acl.c (file_has_aclinfo):
With SELinux, symbolic links can have security contexts,
so omit incorrect optimizations assuming that they lack them.
When ! (flags & AC_SYMLINK_FOLLOW), prefer acl_get_link_np to
acl_get_file on platforms that have both APIs,
as this can avoid some races.
Paul Eggert [Thu, 7 Nov 2024 17:37:17 +0000 (09:37 -0800)]
file-has-acl: minor ENOMEM fixes
* lib/file-has-acl.c: Include limits.h.
(get_aclinfo): Use a saturating add rather than reporting
overflow, in the very unlikely case that the size overflows.
This is simpler and is good enough here.
Also, defend against implausible system that fails with ERANGE
even when the buffer size is SSIZE_MAX.
(file_has_aclinfo): Since we already assume elsewhere that
malloc sets errno, rely on that here too.
* modules/file-has-acl (Depends-on): Add limits.h.
Also add malloc-posix, since we rely on malloc errno.
Paul Eggert [Thu, 7 Nov 2024 17:25:43 +0000 (09:25 -0800)]
file-has-acl: remove __gl_acl_alloc member
It may have been needed in earlier versions of this code,
but it is no longer needed.
* lib/acl.h (struct aclinfo): Remove __gl_acl_alloc. All uses removed.
* lib/file-has-acl.c (get_aclinfo):
Use local, not the removed struct aclinfo slot.
Paul Eggert [Wed, 6 Nov 2024 21:33:27 +0000 (13:33 -0800)]
opendirat: don’t depend on openat-safer
* lib/opendirat.c: Include fcntl.h.
[!GNULIB_OPENAT_SAFER]: Don’t include fcntl--.h.
* modules/opendirat (Depends-on): Depend on openat, not openat-safer.
Paul Eggert [Wed, 6 Nov 2024 21:27:08 +0000 (13:27 -0800)]
getusershell: don’t depend on fopen-safer
* lib/getusershell.c: Include stdio.h.
[!GNULIB_FOPEN_SAFER]: Don’t include stdio--.h.
* modules/getusershell (Depends-on): Depend on fopen, not fopen-safer.
Paul Eggert [Wed, 6 Nov 2024 21:22:32 +0000 (13:22 -0800)]
savewd: don’t depend on fcntl-safer
* lib/savewd.c: Don’t include fcntl-safer.
[GNULIB_FCNTL_SAFER]: Include fcntl--.h.
(savewd_save): Use open, not open_safer.
* modules/savewd (Depends-on): Remove fcntl-safer.
Paul Eggert [Wed, 6 Nov 2024 21:00:52 +0000 (13:00 -0800)]
save-cwd: don’t depend on fd-safer-flag, unistd-safer
They aren’t needed in packages that use xstdopen
* lib/save-cwd.c: Do not include unistd--.h.
(GNULIB_FCNTL_SAFER): Do not define.
(save_cwd): Do not use fd_safer_flag, as the package should use
either fcntl-safer+unistd-safer or xstdopen if it cares about
closed stdin.
* modules/save-cwd (Depends-on): Remove fd-safer-flag, unistd-safer.
Bruno Haible [Wed, 6 Nov 2024 12:02:09 +0000 (13:02 +0100)]
memset_explicit: Guarantee N3322 functionality.
* m4/memset_explicit.m4 (gl_PREREQ_MEMSET_EXPLICIT): Require
AC_CANONICAL_HOST. Test whether memset_s supports zero-length
operations.
* lib/memset_explicit.c (memset_explicit): Don't invoke memset_s with
argument 0 if memset_s does not support this.
Paul Eggert [Wed, 6 Nov 2024 07:07:09 +0000 (23:07 -0800)]
eealloc: deprecate
Now that malloc-gnu and realloc-posix arrange for the
various memory allocators to return non-null on success,
should be no need for the eealloc module.
* NEWS, modules/eealloc: Mention this.
Paul Eggert [Wed, 6 Nov 2024 06:48:53 +0000 (22:48 -0800)]
relocatable-prog-wrapper: remove eealloc.m4
* modules/relocatable-prog-wrapper (Files): Remove m4/eealloc.m4.
It wasn’t being used and evidently was listed only because
a previous version needed it.
Paul Eggert [Wed, 6 Nov 2024 06:06:54 +0000 (22:06 -0800)]
malloca: port better to AIX extensions
Also, switch from eealloc.m4 to malloc.m4 to determine
whether malloc (0) returns nonnull.
* lib/malloca.c (mmalloca): Use HAVE_MALLOC_0_NONNULL,
not MALLOC_0_IS_NONNULL.
* m4/malloca.m4 (gl_MALLOCA): Require gl_FUNC_MALLOC_GNU,
not gl_EEMALLOC.
* modules/malloca (Files): Remove m4/eemalloc.m4.
(Depends-on): Add extensions-aix.
* modules/relocatable-prog-wrapper:
AC_REQUIRE gl_FUNC_MALLOC_POSIX to suppress Autoconf 2.71
“warning: AC_REQUIRE: `gl_FUNC_MALLOC_POSIX' was expanded before
it was required”.
Bruno Haible [Tue, 5 Nov 2024 20:11:12 +0000 (21:11 +0100)]
strncmp tests: Verify N3322 functionality.
* modules/strncmp: New file.
* doc/posix-functions/strncmp.texi: Mention the new module.
* tests/test-strncmp.c: New file.
* modules/strncmp-tests: New file.
Bruno Haible [Tue, 5 Nov 2024 20:10:13 +0000 (21:10 +0100)]
strncpy tests: Verify N3322 functionality.
* modules/strncpy: New file.
* doc/posix-functions/strncpy.texi: Mention the new module.
* tests/test-strncpy.c: New file.
* modules/strncpy-tests: New file.
Bruno Haible [Tue, 5 Nov 2024 20:10:08 +0000 (21:10 +0100)]
memccpy tests: Verify N3322 functionality.
* modules/memccpy: New file.
* doc/posix-functions/memccpy.texi: Mention the new module.
* tests/test-memccpy.c: New file.
* modules/memccpy-tests: New file.
Bruno Haible [Tue, 5 Nov 2024 20:09:07 +0000 (21:09 +0100)]
bsearch tests: Verify N3322 functionality.
* modules/bsearch: New file.
* doc/posix-functions/bsearch.texi: Mention the new module.
* tests/test-bsearch.c: New file.
* modules/bsearch-tests: New file.
Bruno Haible [Tue, 5 Nov 2024 21:16:12 +0000 (22:16 +0100)]
realloc-posix: Fix link error (regression yesterday).
* lib/stdlib.in.h (realloc): Don't inline rpl_realloc if IN_GNULIB_TESTS
is defined.
* modules/realloc-posix (Depends-on, configure.ac): Compile realloc.c
also if REPLACE_REALLOC_FOR_REALLOC_POSIX is 2.
Bruno Haible [Tue, 5 Nov 2024 14:53:47 +0000 (15:53 +0100)]
calloc, malloc: Fix a comment.
* m4/malloc.m4 (gl_FUNC_MALLOC_GNU): Mention that it sets
HAVE_MALLOC_PTRDIFF.
(gl_FUNC_MALLOC_PTRDIFF): Likewise.
(gl_CHECK_MALLOC_PTRDIFF): Do not mention HAVE_MALLOC_PTRDIFF here.
Paul Eggert [Tue, 5 Nov 2024 06:24:29 +0000 (22:24 -0800)]
safe-alloc: simplify, given new reallocarray behavior
* lib/safe-alloc.h [__CHERI_PURE_CAPABILITY__]:
Remove special cases for this, as reallocarray
now does it for us.
(safe_alloc_realloc_n): Remove. All uses replaced by reallocarray.
Paul Eggert [Tue, 5 Nov 2024 03:09:08 +0000 (19:09 -0800)]
realloc-posix: update doc
* doc/posix-functions/realloc.texi: Update to match recent Gnulib
changes and OS discoveries, and to clarify and simplify by
coalescing behaviors (4) and (5).