Bruno Haible [Wed, 25 Sep 2024 23:33:45 +0000 (01:33 +0200)]
build-to-host.m4: Add some convenience macros.
Reported by Michele Locati <michele@locati.it> in
<https://lists.gnu.org/archive/html/bug-gettext/2024-09/msg00033.html>.
* m4/build-to-host.m4 (gl_BUILD_TO_HOST_BINDIR, gl_BUILD_TO_HOST_LIBDIR,
gl_BUILD_TO_HOST_LIBEXECDIR, gl_BUILD_TO_HOST_LOCALEDIR,
gl_BUILD_TO_HOST_PKGDATADIR, gl_BUILD_TO_HOST_PKGLIBDIR): New macros.
* m4/gettext.m4 (AM_GNU_GETTEXT): Invoke gl_BUILD_TO_HOST_LOCALEDIR.
* doc/relocatable-maint.texi (Supporting Relocation): Suggest to use the
*dir_c_make variables and explain how to get them.
Bruno Haible [Wed, 25 Sep 2024 15:19:41 +0000 (17:19 +0200)]
string-buffer: Add more API.
* lib/string-buffer.h: Include string-desc.h.
(sb_append1, sb_append_desc): New declarations.
(sb_append_c): Renamed from sb_append.
(sb_contents, sb_contents_c, sb_dupfree): New declarations.
(sb_dupfree_c): Renamed from sb_dupfree.
* lib/string-buffer.c (sb_append1, sb_append_desc): New functions.
(sb_append_c): Renamed from sb_append.
(sb_contents, sb_contents_c, sb_dupfree): New functions.
(sb_dupfree_c): Renamed from sb_dupfree. Optimize.
* modules/string-buffer (Depends-on): Add string-desc.
* tests/test-string-buffer.c (main): Use sb_append_c instead of
sb_append. Use sb_dupfree_c instead of sb_dupfree. Test also sb_append1,
sb_append_desc, sb_contents.
* NEWS: Mention the changes.
Bruno Haible [Wed, 25 Sep 2024 14:21:12 +0000 (16:21 +0200)]
string-buffer: Enable resource leak warnings from clang.
* m4/gnulib-common.m4 (gl_COMMON_BODY): Define the macros
_GL_ATTRIBUTE_CAPABILITY_TYPE, _GL_ATTRIBUTE_ACQUIRE_CAPABILITY,
_GL_ATTRIBUTE_RELEASE_CAPABILITY.
* lib/string-buffer.h (sb_heap_allocated_pointer_t): New type.
(struct string_buffer): Use it.
(sb_init): Mark with _GL_ATTRIBUTE_ACQUIRE_CAPABILITY.
(sb_free, sb_dupfree): Mark with _GL_ATTRIBUTE_RELEASE_CAPABILITY.
* lib/string-buffer.c: Silence the -Wthread-safety warnings in this
compilation unit.
Bruno Haible [Tue, 24 Sep 2024 16:31:49 +0000 (18:31 +0200)]
string-buffer: Remove INT_MAX limitation.
* lib/string-buffer.h (sb_appendvf, sb_appendf): Document that errno is
set upon failure.
* lib/string-buffer-printf.c: Include <errno.h>.
(sb_appendvf): Call vsnzprintf instead of vsnprintf. Ensure errno is
set upon failure.
(sb_appendf): Likewise.
* modules/string-buffer (Depends-on): Add vsnzprintf-posix. Remove
vsnprintf-posix.
* tests/test-string-buffer.c (main): Test error code from sb_appendf.
Bruno Haible [Tue, 24 Sep 2024 15:28:07 +0000 (17:28 +0200)]
string-buffer: Link to vasnprintf implementation only when needed.
* lib/string-buffer-printf.c: New file, extracted from
lib/string-buffer.c.
* lib/string-buffer.c: Don't include <stdarg.h>.
(sb_ensure_more_bytes): Declare. Make non-static.
(sb_appendvf, sb_appendf): Moved to lib/string-buffer-printf.c.
* modules/string-buffer (Files): Add lib/string-buffer-printf.c.
(Makefile.am): Arrange to compile string-buffer-printf.c.
Bruno Haible [Tue, 24 Sep 2024 10:30:54 +0000 (12:30 +0200)]
sf-istream: New module.
* lib/sf-istream.h: New file.
* lib/sf-istream.c: New file.
* modules/sf-istream: New file.
* doc/posix-functions/fmemopen.texi: Mention the new module.
Bruno Haible [Mon, 23 Sep 2024 14:03:07 +0000 (16:03 +0200)]
utimens: Fix test failure on NetBSD 10 (regression 2024-09-16).
* lib/utimens.h (utimens): Declare as an override if utimens exists in
libc.
(lutimens): Declare as an override if lutimens exists in libc.
* lib/utimens.c (is_valid_timespec, is_valid_timespecs): New functions,
extracted from validate_timespec.
(validate_timespec): Call is_valid_timespecs.
(utimens, lutimens): On NetBSD, validate the argument before calling
NetBSD's libc function.
* tests/test-utimens-common.h (check_ctime): Set to -1 on NetBSD.
Paul Eggert [Sat, 21 Sep 2024 02:24:39 +0000 (19:24 -0700)]
sigsegv-tests: port to GCC 14
GCC 14 on x86-64 with -O2 apparently outsmarts our test for null
pointer dereference, and this is something the C standard allows.
Fix the test by putting ‘volatile’ at the right place.
* tests/test-sigsegv-catch-stackoverflow2.c (null_pointer):
Make it a volatile pointer, not a pointer to volatile.
Also, rename from null_pointer_to_volatile_int; use changed.
Paul Eggert [Tue, 17 Sep 2024 06:55:37 +0000 (23:55 -0700)]
utimens: port to NetBSD-10.99.12/amd64
On this platform, <sys/time.h> declares utimens and lutimens and the
C library defines them, so we needn’t (and shouldn’t).
Problem reported privately by Thomas Klausner.
* lib/utimens.c (utimens) [HAVE_UTIMENS]: Don’t define.
(lutimens) [HAVE_LUTIMENS]: Don’t define.
* lib/utimens.h [HAVE_UTIMENS || HAVE_LUTIMENS]:
Include <sys/time.h>, for NetBSD’s declaration of utimens and lutimens.
(utimens) [HAVE_UTIMENS]: Don’t declare.
(lutimens) [HAVE_LUTIMENS]: Don’t declare.
* m4/utimens.m4 (gl_UTIMENS): Check for utimens, lutimens.
Paul Eggert [Mon, 16 Sep 2024 18:12:24 +0000 (11:12 -0700)]
parse-datetime no longer depends on nstrftime
I discovered this unnecessary dependency when debugging
GNU Patch.
* lib/parse-datetime.y:
(populate_local_time_zone_table) [!HAVE_STRUCT_TM_TM_ZONE]:
(debug_strfdatetime): Use strftime not nstrftime,
as we don’t need nstrftime’s extensions or bug fixes.
* modules/parse-datetime (Depends-on): Remove nstrftime.
Also remove setenv, unsetenv, timegm, as this module
no longer depends on them directly.
Paul Eggert [Mon, 16 Sep 2024 16:45:36 +0000 (09:45 -0700)]
Don’t port July [[...]] changes to C89
Yesterday’s changes to port to C17 and earlier were intrusive,
since they twice replaced one macro with two. Revert the macro
definitions to what they were before yesterday, and instead change
callers so that they always have four arguments even if the last
one is empty. Although this change requires C99 or later, that’s
safe nowadays. Suggested by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2024-09/msg00079.html
* lib/c++defs.h (_GL_FUNCDECL_RPL, _GL_FUNCDECL_SYS):
Revert yesterday’s changes. All callers changed.
Add comments explaining the required comma before missing attrs.
Paul Eggert [Mon, 16 Sep 2024 04:20:15 +0000 (21:20 -0700)]
Port July changes for [[...]] to C17
The July 30 changes to _GL_FUNCDECL_RPL etc. to support use of
attributes in bracket syntax used a C23 preprocessor feature that is
a common extension to C17 and earlier, but which doesn’t work when
compiled with stricter C17-and-earlier compilers. The feature is
using ‘#define f(a, ...) b’ and calling ‘f’ with only one arg.
Port back to C17 and earlier. Problem discovered with
IBM XL C/C++ for AIX, V12.1 (5765-J02, 5725-C72) on cfarm111.
* lib/c++defs.h (_GL_FUNCDECL_RPL): Turn this into two macros
_GL_FUNCDECL_RPL and _GL_FUNCATTR_RPL. The first macro is for
functions without attributes, the second one for functions with
attributes. All uses changed.
(_GL_FUNCDECL_SYS): Likewise, turn this into _GL_FUNCDECL_SYS
and _GL_FUNCATTR_SYS.
Bruno Haible [Sun, 15 Sep 2024 23:05:00 +0000 (01:05 +0200)]
unilbrk: Some more tweaks.
* lib/unilbrk/u8-possible-linebreaks.c (u8_possible_linebreaks_loop):
Assign to preceding_prop at each loop round. Assign to prev2_ea,
prev_ea, prev_nus also when a line break was seen.
* lib/unilbrk/u16-possible-linebreaks.c (u16_possible_linebreaks_loop):
Likewise.
* lib/unilbrk/u32-possible-linebreaks.c (u32_possible_linebreaks_loop):
Likewise.
Bruno Haible [Sun, 15 Sep 2024 13:27:34 +0000 (15:27 +0200)]
unilbrk: Strengthen tests.
* lib/gen-uni-tables.c: Add shell commands for creating
tests/unilbrk/LineBreakTest.txt.
* tests/unilbrk/LineBreakTest.txt: New file, from unicode.org.
* tests/unilbrk/test-uc-possible-linebreaks.c: New file, based on
tests/uniwbrk/test-uc-wordbreaks.c.
* tests/unilbrk/test-uc-possible-linebreaks.sh: New file, based on
tests/uniwbrk/test-uc-wordbreaks.sh.
* modules/unilbrk/u32-possible-linebreaks-tests (Files): Add them.
(Makefile.am): Arrange to compile test-uc-possible-linebreaks.c and test
test-uc-possible-linebreaks.sh.
Bruno Haible [Sun, 15 Sep 2024 13:20:08 +0000 (15:20 +0200)]
uniwbrk tests: Modernize code.
* tests/uniwbrk/test-uc-wordbreaks.c (main): Reduce the scope of local
variables. Remove memset() calls. Align expected and actial output
lines. Add comments.
Bruno Haible [Sun, 15 Sep 2024 13:16:52 +0000 (15:16 +0200)]
unigbrk tests: Modernize code.
* tests/unigbrk/test-uc-grapheme-breaks.c (main): Reduce the scope of
local variables. Add comments.
* tests/unigbrk/test-uc-is-grapheme-break.c (main): Likewise.
Bruno Haible [Sun, 15 Sep 2024 13:06:01 +0000 (15:06 +0200)]
unilbrk: Fix conflicts between rules.
* lib/unilbrk/u8-possible-linebreaks.c (u8_possible_linebreaks_loop):
Avoid side effect of (LB18) on (LB14) and (LB15a). Avoid side effect
of (LB19a) on (LB18).
* lib/unilbrk/u16-possible-linebreaks.c (u16_possible_linebreaks_loop):
Likewise.
* lib/unilbrk/u32-possible-linebreaks.c (u32_possible_linebreaks_loop):
Likewise.
Bruno Haible [Sun, 15 Sep 2024 13:00:30 +0000 (15:00 +0200)]
unilbrk: Enable most cases of Unicode rule (LB29).
* lib/gen-uni-tables.c (output_lbrk_rules_as_tables): Enable rule LB29.
* lib/unilbrk/lbrktables.c: Regenerated.
* lib/unilbrk/u8-possible-linebreaks.c (u8_possible_linebreaks_loop):
Allow a break between a character with property IS and '<'.
* lib/unilbrk/u16-possible-linebreaks.c (u16_possible_linebreaks_loop):
Likewise.
* lib/unilbrk/u32-possible-linebreaks.c (u32_possible_linebreaks_loop):
Likewise.
Bruno Haible [Sun, 15 Sep 2024 11:23:04 +0000 (13:23 +0200)]
unilbrk: Fully implement Unicode rule (LB9).
* lib/unilbrk/u8-possible-linebreaks.c (u8_possible_linebreaks_loop):
New variable preceding_prop. Don't copy prop to prev_prop and ea to
prev_ea if the conditions of rule (LB9) apply.
* lib/unilbrk/u16-possible-linebreaks.c (u16_possible_linebreaks_loop):
Likewise.
* lib/unilbrk/u32-possible-linebreaks.c (u32_possible_linebreaks_loop):
Likewise.
Bruno Haible [Sun, 15 Sep 2024 10:59:46 +0000 (12:59 +0200)]
unilbrk: Fix bugs in implementation of Unicode rules (LB15a), (LB15b).
* lib/gen-uni-tables.c (output_lbrk_rules_as_tables): Fix typo in
comment.
* lib/unilbrk/u8-possible-linebreaks.c (u8_possible_linebreaks_loop):
Do the LBP_QU2 to LBP_QU1 mapping for (LB15a) after the table lookup but
before the assignment to last_prop. Do the LBP_QU3 to LBP_QU1 mapping
for (LB15b) in a way that does not influence prev_prop or last_prop.
* lib/unilbrk/u16-possible-linebreaks.c (u16_possible_linebreaks_loop):
Likewise.
* lib/unilbrk/u32-possible-linebreaks.c (u32_possible_linebreaks_loop):
Likewise.
Bruno Haible [Sat, 14 Sep 2024 09:56:38 +0000 (11:56 +0200)]
unilbrk/tables: Fix table (regression yesterday).
Reported by Collin Funk <collin.funk1@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-09/msg00061.html>.
* lib/gen-uni-tables.c (output_lbrk_rules_as_tables): Use LBP_AL1 as
array index instead of LBP_AL. Update comments.
* lib/unilbrk/lbrktables.c: Regenerated.
Bruno Haible [Fri, 13 Sep 2024 13:17:49 +0000 (15:17 +0200)]
Update to Unicode 16.0.0.
* lib/gen-uni-tables.c (PROP_MODIFIER_COMBINING_MARK): New enum item.
(fill_properties): Recognize property Modifier_Combining_Mark.
(UC_JOINING_GROUP_KASHMIRI_YEH): New enum item.
(fill_arabicshaping, joining_group_as_c_identifier): Handle
UC_JOINING_GROUP_KASHMIRI_YEH.
(LBP_*): Split LBP_AL into LBP_AL1 and LBP_AL2.
(LBP_AL): New enum item.
(get_lbea): New function.
(get_lbp): Use it. Update such that unilbrk/lbrkprop.txt comes out as
expected. Map U+25CC to LBP_AL2.
(PROP_EA, PROP, EA): New macros.
(debug_output_lbp): Print either LBP_AL1, LBP_AL2 as LBP_AL.
(lbp_value_to_string): Handle LBP_AL1, LBP_AL2 instead of LBP_AL.
(struct lbpea_table): Renamed from struct lbp_table.
(output_lbpea): Renamed from output_lbp. Store both the line break
property and the line break EastAsian bit in the same table entry.
(output_lbrk_tables): Update.
(output_lbrk_rules_as_tables): Update for LBP_AL change. Implement rules
LB28a, LB25, LB19, LB15d, LB13 as specified by
https://www.unicode.org/reports/tr14/tr14-53.html.
(get_wbp): Update such that uniwbrk/wbrkprop.txt comes out as expected.
* lib/unictype.in.h (UC_JOINING_GROUP_KASHMIRI_YEH): New enum item.
* lib/unictype/joininggroup_byname.gperf: Handle it.
* lib/unictype/joininggroup_name.h: Likewise.
* lib/unilbrk/lbrktables.h: Split LBP_AL into LBP_AL1 and LBP_AL2.
(LBP_AKLS_VI): New enum item, for rule LB28a.
(PROP, EA, PROP_EA): New macros.
(unilbrk_table): Update bounds.
* lib/unilbrk/u8-possible-linebreaks.c (u8_possible_linebreaks_loop):
Use LBP_AL1 instead of LBP_AL. Use 2 characters of lookahead, for rules
LB15c, LB19a, LB25, LB28a. New variables prev_ea, prev2_ea, for rule
LB19a. New variable prev_initial_hyphen, for rule LB20a. New variable
prev_nus, for rule LB25. Implement rules LB15c, LB19a, LB20a, LB21a,
LB25, LB28a, as specified by
https://www.unicode.org/reports/tr14/tr14-53.html.
* lib/unilbrk/u16-possible-linebreaks.c (u16_possible_linebreaks_loop):
Likewise.
* lib/unilbrk/u32-possible-linebreaks.c (u32_possible_linebreaks_loop):
Likewise.
* modules/unilbrk/base (Depends-on): Add stdbool.
* tests/uninorm/test-u32-normalize-big.h
(struct normalization_test_file): Now 6 parts.
* tests/uninorm/test-u32-normalize-big.c (read_normalization_test_file):
Fill in 6 parts.
(test_specific, free_normalization_test_file): Now handle 6 parts.
* 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.
* All the affected modules: Bump required libunistring version.
Bruno Haible [Fri, 13 Sep 2024 00:45:37 +0000 (02:45 +0200)]
uninorm/composition: Make more maintainable.
* lib/gen-uni-tables.c (output_composition_tables): Add a filename2
parameter. Emit definitions of UNINORM_COMPOSE_MAX_ARG1 and
UNINORM_COMPOSE_MAX_ARG2 to this file.
(main): Invoke it with additional file name
uninorm/composition-table-bounds.h.
* uninorm/composition-table-bounds.h: New generated file.
* lib/uninorm/composition.c: Include it.
(uc_composition): Use UNINORM_COMPOSE_MAX_ARG1 and
UNINORM_COMPOSE_MAX_ARG2 instead of hardcoded bounds.
Paul Eggert [Fri, 6 Sep 2024 01:31:29 +0000 (18:31 -0700)]
Fix COPYING.EXCEPTION license notices
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2024-08/msg00227.html
* m4/std-gnu11.m4: Fix license notice to use COPYING.EXCEPTION
correctly.
* m4/std-gnu23.m4: Likewise. Also document the commit ID,
since Autoconf was updated likewise and we’re copying from there.
Bruno Haible [Wed, 4 Sep 2024 17:38:52 +0000 (19:38 +0200)]
Resolve conflicts for functions introduced in Android API level 35.
Reported by Po Lu <luangruo@yahoo.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-09/msg00024.html>.
* lib/time.in.h (timezone_t, tzalloc, tzfree): Don't require _GNU_SOURCE
to be defined. Define depending on HAVE_TZALLOC, not HAVE_TIMEZONE_T.
(localtime_rz, mktime_z): Likewise. Override if REPLACE_LOCALTIME_RZ or
REPLACE_MKTIME_Z is 1, respectively.
* lib/time_rz.c: If NEED_TIMEZONE_NULL_SUPPORT, define only localtime_rz
and mktime_z and only as wrappers around the system function.
* m4/time_h.m4 (gl_TIME_H_DEFAULTS): Initialize HAVE_TZALLOC,
REPLACE_LOCALTIME_RZ, REPLACE_MKTIME_Z.
* m4/time_rz.m4 (gl_TIME_RZ): Conditionally set HAVE_TZALLOC,
REPLACE_LOCALTIME_RZ, REPLACE_MKTIME_Z. Conditionally define
NEED_TIMEZONE_NULL_SUPPORT.
* modules/time-h (Makefile.am): Substitute HAVE_TZALLOC,
REPLACE_LOCALTIME_RZ, REPLACE_MKTIME_Z.
* modules/time_rz (Depends-on, configure.ac): Consider HAVE_TZALLOC,
REPLACE_LOCALTIME_RZ, REPLACE_MKTIME_Z. Ignore HAVE_TIMEZONE_T.
Bruno Haible [Wed, 4 Sep 2024 08:34:04 +0000 (10:34 +0200)]
Resolve conflicts for functions introduced in Android API level 35.
* m4/strerrorname_np.m4 (gl_FUNC_COPY_FILE_RANGE): Conditionally set
REPLACE_STRERRORNAME_NP.
(gl_CHECK_STRERRORNAME_NP): Test for strerrorname_np using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
Bruno Haible [Tue, 3 Sep 2024 21:00:28 +0000 (23:00 +0200)]
tests: Strenghten tests with invalid file descriptor.
* tests/test-close.c: Include <fcntl.h>.
(main): Check that AT_FDCWD is recognized as an invalid file descriptor.
* tests/test-dup.c: Include <fcntl.h>.
(main): Check that AT_FDCWD is recognized as an invalid file descriptor.
* tests/test-unlockpt.c: Include <fcntl.h>.
(main): Check that AT_FDCWD is recognized as an invalid file descriptor.
* tests/test-fchdir.c (main): Likewise.
* tests/test-fdatasync.c (main): Likewise.
* tests/test-fdopendir.c (main): Likewise.
* tests/test-fsync.c (main): Likewise.
* tests/test-isatty.c (main): Likewise.
Bruno Haible [Sun, 1 Sep 2024 11:09:59 +0000 (13:09 +0200)]
Fix mbscasestr test failure on native Windows with MSVC.
* lib/c32to-impl.h (FUNC): On native Windows, ignore the system's
towlower/towupper function entirely.
* tests/test-c32tolower.c (main): On native Windows, reenable test that
previously failed.
* tests/test-c32toupper.c (main): Likewise. Disable two other tests on
native Windows.
* doc/posix-functions/towlower.texi: Mention bug in the native Windows
UTF-8 locale.
* doc/posix-functions/towupper.texi: Likewise.
Bruno Haible [Thu, 29 Aug 2024 16:32:35 +0000 (18:32 +0200)]
gnulib-tool.py: Allow verifying license compatibility with GPLv2+.
* pygnulib/GLInfo.py (GLInfo.usage): Document the --gpl option.
* pygnulib/main.py (main): Accept a --gpl option. Pass it to the
GLConfig.
* pygnulib/GLConfig.py (GLConfig): Add 'gpl' field and constructor
argument. Add getGPL, setGPL, resetGPL methods.
* m4/gnulib-tool.m4 (gl_GPL): New macro.
* doc/gnulib-tool.texi (Modified imports): Document the gl_GPL macro.
* pygnulib/GLImport.py (GLImport.__init__): Look for gl_GPL invocations
in gnulib-cache.m4.
(GLImport.actioncmd): Output --gpl option when option --gpl was given.
(GLImport.gnulib_cache): Emit a gl_GPL invocation when option --gpl was
given.
(GLImport.prepare): Do license compatibility checking when option --gpl
was given.
* pygnulib/GLModuleSystem.py: Update a comment.