Paul Eggert [Mon, 28 Nov 2022 04:52:04 +0000 (20:52 -0800)]
read-file: use memset_explicit
* lib/read-file.c (fread_file, read_file):
Use memset_explicit instead of explicit_bzero.
* modules/read-file (Depends-on): Depend on memset_explicit
instead of on explicit_bzero.
* doc/parse-datetime.texi: Use @samp and @code in menus
for consistenty with how the Coreutils manual will do
this sort of thing. Update examples to this year.
Bruno Haible [Thu, 3 Nov 2022 12:32:42 +0000 (13:32 +0100)]
dynarray: Rename to glibc-internal/dynarray.
* modules/glibc-internal/dynarray: Renamed from modules/dynarray.
* modules/glibc-internal/dynarray-tests: Renamed from
modules/dynarray-tests.
* modules/regex (Depends-on): Update.
* NEWS: Mention this change and the previous one.
Paul Eggert [Thu, 3 Nov 2022 01:14:15 +0000 (18:14 -0700)]
scratch_buffer: adjust to glibc changes
Problem reported by Karl Berry in:
https://lists.gnu.org/r/bug-gnulib/2022-11/msg00004.html
* build-aux/depcomp, doc/make-stds.texi, lib/malloc/scratch_buffer.h:
Autoupdate.
* build-aux/install-reloc (func_create_wrapper):
Omit removed file scratch_buffer_dupfree.c.
* config/srclist.txt: Remove lib/malloc/scratch_buffer_dupfree.c
* lib/canonicalize-lgpl.c: Merge changes from glibc through its
commit ef0700004bf0dccf493a5e8e21f71d9e7972ea9f dated 2022-07-05
11:04:45 +0200.
(__strdup) [!_LIBC]: New macro.
(struct realpath_bufs): New type.
(realpath_stk): Use it as the extra argument. All uses changed.
No longer any need for noinline or GCC_BOGUS_WRETURN_LOCAL_ADDR.
* lib/canonicalize.c (struct realpath_bufs)
(canonicalize_filename_mode_stk): Likewise.
* lib/malloc/scratch_buffer_dupfree.c:
Remove, since it was removed in glibc.
* lib/scratch_buffer.h (scratch_buffer_dupfree) [0]:
(__libc_scratch_buffer_dupfree): Remove decls.
* modules/relocatable-prog-wrapper (Files):
* modules/scratch_buffer (Files, lib_SOURCES):
Remove lib/malloc/scratch_buffer_dupfree.c.
Bruno Haible [Mon, 17 Oct 2022 00:44:54 +0000 (02:44 +0200)]
getdelim: Work around buggy implementation on macOS 10.13.
* doc/posix-functions/getdelim.texi: Mention the macOS bug.
* m4/getdelim.m4 (gl_FUNC_GETDELIM): Let the "checking for working
getdelim function" test answer 'no' on macOS.
Bruno Haible [Sat, 15 Oct 2022 22:46:24 +0000 (00:46 +0200)]
Update to Unicode 15.0.0.
* lib/gen-uni-tables.c (is_property_default_ignorable_code_point):
Exclude 0x13439..0x1343F.
(get_lbp): Update such that unilbrk/lbrkprop.txt comes out as expected.
* 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/uniwidth/test-uc_width2.sh: Expect width 0 for the characters
0x0ECE, 0x10EFD..0x10EFF, 0x11241, 0x11F00..0x11F01, 0x11F36..0x11F3A,
0x11F40, 0x11F42, 0x13439..0x13440, 0x13447..0x13455, 0x1E08F,
0x1E4EC..0x1E4EF.
* All the affected modules: Bump required libunistring version.
Paul Eggert [Thu, 13 Oct 2022 00:18:20 +0000 (17:18 -0700)]
doc: improve intprops doc
* doc/intprops.texi: Tighten up wording, by saying that macros
"yield 1 if X, 0 otherwise" rather than the weaker "yield 1 if X".
Say "yield" rather than "return" since the macros are not
functions. Say "1" and "0" rather than "true" and "false" since
the macros yield int. Say that stdckdint.h is the standard
alternative to the _WRAPV macros. Mention another source of
problems with the _OVERFLOW macros.
Paul Eggert [Tue, 11 Oct 2022 01:26:05 +0000 (18:26 -0700)]
stat-time: prefer stdckdint to intprops
* lib/stat-time.h: Include stdckdint.h instead of intprops.h.
(stat_time_normalize): Use ckd_add instead of INT_ADD_WRAPV.
* modules/stat-time (Depends-on): Depend on stdckdint, not intprops.
Paul Eggert [Tue, 11 Oct 2022 01:17:02 +0000 (18:17 -0700)]
xalloc: remove stray includes + dependencies
These used to be needed, but are not needed now.
* lib/xalloc.h: Do not include stdlib.h.
[GNULIB_XALLOC]: Do not include "intprops.h".
* lib/xmalloc.c: Include stdint.h here instead, for SIZE_MAX.
* modules/xalloc-die, modules/xvasprintf (Depends-on): Remove stdint.
Paul Eggert [Sat, 1 Oct 2022 00:35:18 +0000 (17:35 -0700)]
assert-h: suppress Apple clang 13 false alarms
* m4/assert_h.m4 (gl_ASSERT_H): Suppress bogus warnings from Apple
clang 13 (clang-1300.0.29.30). Problem privately reported by
Mattias Engdegård for GNU Emacs.
Paul Eggert [Mon, 26 Sep 2022 01:33:49 +0000 (18:33 -0700)]
fts: fix errno handling if dirfd fails
* lib/fts.c (fts_build): Use proper errno if dirfd failed.
Although I don’t know of any platform where dirfd can fail here,
we might as well get it right.
Bruno Haible [Sat, 24 Sep 2022 21:42:44 +0000 (23:42 +0200)]
stdbool: Don't #include a gnulib-generated stdbool.h from config.h.
* m4/c-bool.m4 (gl_C_BOOL): Check for stdbool.h and for _Bool. If
stdbool.h does not exist, don't #include <stdbool.h> but instead put the
substitute code into config.h.
Bruno Haible [Sat, 24 Sep 2022 17:56:31 +0000 (19:56 +0200)]
stdalign: Don't #include a gnulib-generated stdalign.h from config.h.
* m4/stdalign.m4 (gl_STDALIGN_H): Check for stdalign.h. If it does not
exist, don't #include <stdalign.h> but instead put the substitute code
into config.h.
Simon Josefsson [Fri, 23 Sep 2022 07:06:22 +0000 (09:06 +0200)]
warnings, manywarnings: Doc fixes.
* doc/manywarnings.texi (manywarnings): Improve usage instruction.
Start list of comments on particular warning flags, based on
comment from Paul Eggert <eggert@cs.ucla.edu>.
* doc/warnings.texi (warnings): Mention that it is often used with manywarnings.
Paul Eggert [Wed, 21 Sep 2022 23:37:37 +0000 (16:37 -0700)]
assert-h: suppress clang false alarms
Suppress scads of annoying warnings from clang version 14.0.5
(Fedora 14.0.5-1.fc36) of the form "warning: '_Static_assert' with
no message is a C2x extension [-Wc2x-extensions]",
by refusing to use single-arg static_assert with older clang.
* m4/assert_h.m4 (gl_ASSERT_H): Turn -Wc2x-extensions from a
warning into an error when testing static_assert, so that the
annoying diagnostic causes the test to fail, which causes assert.h
to be replaced in a way that suppresses the diagnostic during
the real build.
Paul Eggert [Sun, 18 Sep 2022 18:26:36 +0000 (11:26 -0700)]
stdbool: omit ‘#undef true’
This is mostly just simplification.
* m4/c-bool.m4 (gl_C_BOOL): Test all preprocessors when
!HAVE_C_BOOL, not merely __SUNPRO_CC. Use the slightly
more-elegant ‘!true’ instead of ‘true == 1’; this shouldn’t matter
in practice and if it does matter we want to know about it anyway.
Remove an unnecessary ‘#undef true’ that is simply commented out
by ‘configure’; again, if true is already #defined to be 0 the
system is so messed up we want to know about it anyway.
Paul Eggert [Sun, 18 Sep 2022 02:59:26 +0000 (19:59 -0700)]
explicit_bzero-tests: robustify a bit
This is mostly to suppress GCC warnings, though I suppose it
might also improve the test.
* tests/test-explicit_bzero.c: Do not ignore -Wmaybe-uninitialized,
as this warning should no longer be generated given the other changes.
(test_heap): ASSERT that malloc succeeds, to suppress any GCC
warning about relying on malloc succeeding. Declare addr to be
volatile, so that GCC does not deduce that it is heapbuf in
disguise and diagnose using it after freeing it.
(do_secret_stuff): Declare more things to be volatile, to avoid
optimizations that might disturb the stack and/or mess up the test
in other ways. Pass last_stackbuf address as a parameter rather
than having last_stackbuf be static, to avoid GCC warning about
assigning address of a local to a static; all callers changed.
Bruno Haible [Sun, 18 Sep 2022 01:05:21 +0000 (03:05 +0200)]
wchar: Fix compilation errors in C++ mode on Solaris 11.3.
* lib/wchar.in.h (wcsnlen, wcpcpy, wcpncpy, wcscasecmp, wcsncasecmp,
wcsdup): Force declaration in C++ mode on Solaris (which does not
declare these functions in the global namespace).
Bruno Haible [Wed, 14 Sep 2022 22:50:41 +0000 (00:50 +0200)]
time: Fix compilation errors with clang/MSVC.
* m4/time_h.m4 (gl_TIME_H): Test whether asctime_r and ctime_r are
declared.
* lib/time.in.h (asctime_r, ctime_r): Skip _GL_WARN_ON_USE invocations
when these functions are not declared.
Bruno Haible [Wed, 14 Sep 2022 20:21:47 +0000 (22:21 +0200)]
verify: Avoid syntax error due to static_assert with clang in C++ mode.
* lib/verify.h (static_assert): Don't define in clang C++ 6 or newer.
* m4/assert_h.m4 (gl_ASSERT_H): If we don't need to define static_assert
with clang in C++ mode, don't include <assert.h>.
Paul Eggert [Wed, 14 Sep 2022 18:44:19 +0000 (13:44 -0500)]
assert-h: work around include confusion
* m4/assert_h.m4 (gl_ASSERT_H): Arrange for <config.h> to not
include <assert.h> if assert is already defined. This works
around bugs in packages that mistakenly include <config.h> after
including <assert.h> (typically due to double-inclusion of
<config.h>). Found in coreutils, which I plan to fix.
Paul Eggert [Wed, 14 Sep 2022 18:40:37 +0000 (13:40 -0500)]
stdbool: depend on C99
Record that stdbool depends on C99 these days.
This matters only for ancient compilers that need special
flags to support C99 features.
* modules/stdbool (Depends-on): Add c99.
Paul Eggert [Wed, 14 Sep 2022 04:01:53 +0000 (23:01 -0500)]
verify: treat GNU C++ 6 like recent C++
* lib/verify.h (_GL_VERIFY):
* m4/assert_h.m4 (gl_ASSERT_H):
If we check __cpp_static_assert < 200410, also check __GNUG__ < 6,
for consistency with the previous change.
Paul Eggert [Tue, 13 Sep 2022 22:29:36 +0000 (17:29 -0500)]
stdalign: prefer to not include <stdalign.h>
* lib/alignalloc.c, lib/argp-parse.c, lib/fts.c, lib/md4.c, lib/md5.c:
* lib/rawmemchr.c, lib/sha1.c, lib/sha256.c, lib/sha512.c, lib/sm3.c:
* lib/sys_socket.in.h:
In C23, <stdalign.h> is a no-op, so don’t include it.
Paul Eggert [Tue, 13 Sep 2022 22:29:36 +0000 (17:29 -0500)]
stdalign: alignas and alignof are C23 keywords
* m4/stdalign.m4 (gl_STDALIGN_H): Check also whether
alignas and alignof are keywords and so don’t need stdalign.h,
and define HAVE_C_ALIGNASOF if so.
If not, arrange for config.h to #define alignas and alignof
by including <stdalign.h>.
* modules/stdalign: No need to include <stdalign.h>.
* tests/test-stdalign.c: Do not include stdalign.h.
Paul Eggert [Tue, 13 Sep 2022 22:29:35 +0000 (17:29 -0500)]
assert-h: static_assert is a keyword in C23
* m4/assert_h.m4 (gl_ASSERT_H): Also test for static_assert
keyword a la C23, and define HAVE_C_STATIC_ASSERT if so.
If not, arrange for config.h to #define static_assert
by including <assert.h>, and then do "#undef assert"
so that the assert macro still needs an explicit include.
This should be safe even on very old hosts, as assert.h
has been re-includable for decades.
* tests/tests-assert.c: New test.
* modules/assert-h-tests (Files, Makefile.am): Add it.
Paul Eggert [Tue, 13 Sep 2022 17:56:56 +0000 (12:56 -0500)]
stdalign-tests: port to C23
* tests/test-stdalign.c: Do not test __alignas_is_defined,
_Alignof, or _Alignas as they are obsolescent.
Do not use __alignas_is_defined in C23 or later (or C++11 or later),
as it’s removed in C23.
Bruno Haible [Sat, 10 Sep 2022 18:01:24 +0000 (20:01 +0200)]
Reorganize C++ tests for stdbool and stdbool-c99.
* tests/test-stdbool-c++.cc: Don't include <stdbool.h> if TEST_STDBOOL_H
is not defined. Add a couple of simple tests, from test-stdbool.c.
* tests/test-stdbool-c99-c++.cc: New file.
* modules/stdbool-c99-c++-tests: New file, based on
modules/stdbool-c++-tests.
* modules/stdbool-c99-tests (Depends-on): Add stdbool-c99-c++-tests.
Remove stdbool-c++-tests.
* modules/stdbool-tests (Depends-on): Add stdbool-c++-tests.
Bruno Haible [Sat, 10 Sep 2022 16:56:14 +0000 (18:56 +0200)]
uchar: Work around error in C++ mode on AIX 7.2 with xlclang.
* lib/uchar.in.h (char16_t, char32_t): On AIX with xlclang++, define
these as macros.
* doc/posix-headers/uchar.texi: Document the AIX + xlclang++ bug.
Paul Eggert [Sat, 10 Sep 2022 16:41:31 +0000 (11:41 -0500)]
stdbool: upgrade from C99 to C23
Change the stdbool module so that it now emulates C23.
The module now assumes C99. The old module (which assumes
C89 and emulates C99) is still available as stdbool-c99,
but is deprecated.
* tests/test-stdbool.c [TEST_STDBOOL_H]: Do not include stdbool.h.
(WORKING_BOOL): Depend on HAVE_C_BOOL, not __STDC_VERSION__.
* m4/c-bool.m4, modules/c-bool, modules/c-bool-tests:
* tests/test-c-bool.c: New files.
Bruno Haible [Sat, 10 Sep 2022 16:03:02 +0000 (18:03 +0200)]
math: Fix compilation error in C++ mode on AIX 7.2 with xlclang.
* lib/math.in.h (cbrtl, copysignl, exp2l, expm1l, fmal, ilogbl, log1pl,
log2l, logbl, remainderl, rintl, roundl, truncl): Enable the C++ alias
warning only on glibc systems.
Bruno Haible [Sat, 10 Sep 2022 00:31:20 +0000 (02:31 +0200)]
posix_spawn-internal: Optimize DuplicateHandle calls on native Windows.
* lib/windows-spawn.h (DELAYED_DUP2_OLDFD, DELAYED_DUP2_NEWFD): New
macros.
(struct IHANDLE): Add a linked_fd field.
* lib/spawni.c (SPAWN_INTERNAL_OPTIMIZE_DUPLICATEHANDLE): New macro.
(do_delayed_dup2, do_remaining_delayed_dup2): New functions.
(close_inheritable_handles): Don't close handles in DELAYED_DUP2_NEWFD
entries.
(do_close): Add a third parameter. Optimize delayed dup2 calls.
(do_open): Use do_close.
(do_dup2): Likewise. Prepare for optimizing the DuplicateHandle call.
(__spawni): Do the remaining delayed dup2 invocations after the loop
over the actions.
Bruno Haible [Sat, 10 Sep 2022 00:27:05 +0000 (02:27 +0200)]
posix_spawn-internal: Optimize DuplicateHandle calls on native Windows.
* lib/windows-spawn.h (KEEP_OPEN_IN_PARENT): New macro.
* lib/windows-spawn.c (init_inheritable_handles): When a handle is
already inheritable, don't bother duplicating it; instead, just mark it
as KEEP_OPEN_IN_PARENT.
* lib/spawni.c (shrink_inheritable_handles, close_inheritable_handles,
do_open, do_dup2, do_close): Don't close handles that are marked as
KEEP_OPEN_IN_PARENT.
Bruno Haible [Fri, 9 Sep 2022 14:49:10 +0000 (16:49 +0200)]
spawn-pipe: Fix pipe-filter-* test hangs (regression 2020-12-24).
* lib/windows-spawn.h (struct inheritable_handles): Widen the per-fd
flags from 8 bits to 16 bits.
(KEEP_OPEN_IN_CHILD): New macro.
(init_inheritable_handles): Change description of what it does when
duplicate == true.
* lib/windows-spawn.c (init_inheritable_handles): If duplicate == true,
add all fds to the array, regardless whether they are scheduled to be
preserved in the child process.
(compose_handles_block): Update.
(spawnpvech): Update.
* lib/spawni.c (grow_inheritable_handles): Update.
(shrink_inheritable_handles): Also close the handles not marked with
KEEP_OPEN_IN_CHILD.
(do_open, do_dup2): Mark the new fd with KEEP_OPEN_IN_CHILD.