Bruno Haible [Sun, 16 Feb 2025 17:24:16 +0000 (18:24 +0100)]
strncasecmp: Add tests.
* tests/test-strncasecmp-1.sh: New file.
* tests/test-strncasecmp-2.sh: New file.
* tests/test-strncasecmp.c: New file.
* modules/strncasecmp-tests: New file.
Bruno Haible [Sun, 16 Feb 2025 17:02:00 +0000 (18:02 +0100)]
strcasecmp: Add tests.
* tests/test-strcasecmp-1.sh: New file.
* tests/test-strcasecmp-2.sh: New file.
* tests/test-strcasecmp.c: New file.
* modules/strcasecmp-tests: New file.
Bruno Haible [Sun, 16 Feb 2025 12:43:40 +0000 (13:43 +0100)]
bootstrap: Fix recognition of --depth option with recent git releases.
Reported by Benno Schulenberg <bensberg@telfort.nl> in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-02/msg00106.html>.
* top/bootstrap-funclib.sh (prepare_GNULIB_SRCDIR): Assume that
'git clone' and 'git fetch' support the --depth option.
* build-aux/bootstrap: Regenerated.
Paul Eggert [Sat, 15 Feb 2025 02:04:54 +0000 (18:04 -0800)]
isascii: stop using it
* doc/pastposix-functions/isascii.texi: There is no isascii module.
* m4/mbswidth.m4 (gl_MBSWIDTH): Do not check for isascii,
as it no longer seems to be used here.
* tests/test-c-ctype.c (test_agree_with_C_locale):
Do not assume isascii exists, as POSIX no longer requires it.
Bruno Haible [Fri, 14 Feb 2025 05:17:24 +0000 (06:17 +0100)]
isalnum_l: New module.
* lib/ctype.in.h: Include <locale.h>.
(isalnum_l): New declaration.
* lib/isalnum_l.c: New file.
* lib/is_l-impl.h: New file.
* m4/isalnum_l.m4: New file.
* m4/ctype_h.m4 (gl_CTYPE_H): Test for isalnum_l.
(gl_CTYPE_H_REQUIRE_DEFAULTS): Initialize GNULIB_ISALNUM_L.
(gl_CTYPE_H_DEFAULTS): Initialize HAVE_ISALNUM_L.
* modules/ctype-h (Makefile.am): Substitute GNULIB_ISALNUM_L,
HAVE_ISALNUM_L.
* modules/isalnum_l: New file.
* tests/test-ctype-h-c++.cc: Check declaration of isalnum_l.
* doc/posix-functions/isalnum_l.texi: Mention the new module.
Bruno Haible [Fri, 14 Feb 2025 14:42:22 +0000 (15:42 +0100)]
newlocale: Work around NetBSD bug.
* lib/newlocale.c (newlocale) [NetBSD]: Test whether the locale name is
valid; fail with error ENOENT if not.
* doc/posix-functions/newlocale.texi: Mention the NetBSD bug.
Bruno Haible [Fri, 14 Feb 2025 14:24:54 +0000 (15:24 +0100)]
newlocale: Work around macOS, NetBSD, Solaris 11 OpenIndiana bug.
* m4/newlocale.m4 (gl_FUNC_NEWLOCALE): Test for the "null base" bug.
Set REPLACE_NEWLOCALE to 1 if it has the bug.
* lib/newlocale.c (newlocale): Add alternative implementation that uses
the system's newlocale().
* modules/newlocale (configure.ac): Consider REPLACE_NEWLOCALE.
* tests/test-newlocale.c: Include <langinfo.h>.
(main): Verify fix for the "null base" bug.
* modules/newlocale-tests (configure.ac): Test for nl_langinfo_l.
* doc/posix-functions/newlocale.texi: Mention the "null base" bug.
Bruno Haible [Fri, 14 Feb 2025 04:56:55 +0000 (05:56 +0100)]
duplocale: Support all platforms.
* lib/locale.in.h (duplocale): Declare also on platforms that don't
already have a duplocale function. Don't define HAVE_WORKING_DUPLOCALE.
* lib/duplocale.c: Include <stdlib.h>.
(duplocale): Renamed from rpl_duplocale. Add implementation for
platforms without native locale_t.
* modules/duplocale (Depends-on): Add newlocale, freelocale.
(configure.ac): Compile also on platforms without native locale_t.
* tests/test-duplocale.c: Ignore HAVE_WORKING_DUPLOCALE.
* tests/test-locale-h-c++.cc: Likewise.
* doc/posix-functions/duplocale.texi: Mention the change.
Bruno Haible [Thu, 13 Feb 2025 01:18:05 +0000 (02:18 +0100)]
setlocale: Update info about Galician and Tamil.
* lib/setlocale.c (locales_with_principal_territory): Galician is
mostly spoken in Spain, not Portugal. Tamil is mostly spoken in India,
not Sri Lanka.
Bruno Haible [Wed, 12 Feb 2025 19:03:29 +0000 (20:03 +0100)]
getaddrinfo: Support the AI_NUMERICHOST flag.
* lib/getaddrinfo.c (is_numeric_host): New function.
(getaddrinfo): Accept and implement the AI_NUMERICHOST flag.
* modules/getaddrinfo (Depends-on): Add inet_pton.
* tests/test-getaddrinfo.c: Include <ctype.h>.
(simple): In pass 3, pass the AI_NUMERICHOST flag.
(main): Add a pass 3.
Bruno Haible [Wed, 12 Feb 2025 17:43:59 +0000 (18:43 +0100)]
netdb-h: Ensure AI_NUMERICHOST and AI_NUMERICSERV are defined.
* lib/netdb.in.h (AI_NUMERICHOST): New macro.
* tests/test-netdb-h.c: Verify that AI_NUMERICHOST and AI_NUMERICSERV
are defined.
* doc/posix-headers/netdb.texi: Mention the platform support for
AI_NUMERICHOST and AI_NUMERICSERV.
Bruno Haible [Sun, 9 Feb 2025 21:02:27 +0000 (22:02 +0100)]
string-buffer, string-buffer-reversed: Allow for better static analysis.
* lib/string-buffer.h (sb_appendvf, sb_appendf, sb_xappendvf,
sb_xappendf): Don't declare if SB_NO_APPENDF is defined.
(sb_xdupfree_c): Declare a non-NULL return value if SB_NO_APPENDF is
defined.
* lib/string-buffer-reversed.h (sbr_prependvf, sbr_prependf,
sbr_xprependvf, sbr_xprependf): Don't declare if SBR_NO_PREPENDF is
defined.
(sbr_xdupfree_c): Declare a non-NULL return value if SBR_NO_PREPENDF is
defined.
* lib/string.in.h (mbsstr, mbspcasecmp, mbscasestr): On ISO C compliant
compilers, use the _Generic based macro instead of the 'typeof' based
macro.
* lib/unistr.in.h (u*_check, u*_next, u*_prev, u*_chr, u*_strchr,
u*_strrchr, u*_strpbrk, u*_strstr): Likewise.
* lib/unigbrk.in.h (u*_grapheme_next, u*_grapheme_prev): Likewise.
Bruno Haible [Sun, 9 Feb 2025 15:56:39 +0000 (16:56 +0100)]
string-buffer, string-buffer-reversed: Make OOM handling consistent.
* lib/string-buffer.h (struct string_buffer): New field 'oom'.
* lib/string-buffer.c (sb_init): Initialize the 'oom' field.
(sb_append1, sb_append_desc, sb_append_c): Upon out-of-memory, set
buffer->oom, not buffer->error.
(sb_dupfree, sb_dupfree_c): If there was an OOM, return NULL.
* lib/string-buffer-printf.c (sb_appendvf, sb_appendf): Upon
out-of-memory, set buffer->oom, not buffer->error.
* lib/string-buffer-reversed.h (struct string_buffer_reversed): New
field 'oom'.
* lib/string-buffer-reversed.c (sbr_init): Initialize the 'oom' field.
(sbr_prepend1, sbr_prepend_desc, sbr_prepend_c): Upon out-of-memory, set
buffer->oom, not buffer->error.
(sbr_dupfree, sbr_dupfree_c): If there was an OOM, return NULL.
* lib/string-buffer-reversed-printf.c (sbr_prependvf, sbr_prependf):
Upon out-of-memory, set buffer->oom, not buffer->error.
Bruno Haible [Sun, 9 Feb 2025 07:18:18 +0000 (08:18 +0100)]
mbsstr, mbscasestr, mbspcasecmp: Use const-improved function macros.
* lib/string.in.h (mbsstr, mbspcasecmp, mbscasestr): Define as macros
that cast the result to 'const char *' when the first argument is a
'const char *'.
* lib/mbsstr.c: Define _GL_NO_CONST_GENERICS.
* lib/mbscasestr.c: Likewise.
* lib/mbspcasecmp.c: Likewise.
Bruno Haible [Sun, 9 Feb 2025 05:07:13 +0000 (06:07 +0100)]
intprops tests: Strengthen INT_PROMOTE tests.
* lib/intprops.h (INT_PROMOTE): Refine comment.
* tests/test-intprops.c: Check the size and sign of INT_PROMOTE (x) on
all compilers.
(main): Check that INT_PROMOTE is a no-op on floats.
Collin Funk [Sun, 9 Feb 2025 01:40:48 +0000 (17:40 -0800)]
doc: Document free_aligned_sized and free_sized added in C23.
* doc/posix-functions/free_aligned_sized.texi: New file.
* doc/posix-functions/free_sized.texi: New file.
* doc/gnulib.texi (Functions in <stdlib.h>): Include them.
Paul Eggert [Sat, 8 Feb 2025 22:58:51 +0000 (14:58 -0800)]
memalignment: document
* doc/gnulib-readme.texi (Other portability assumptions):
Mention the C23 function memalignment.
* doc/posix-functions/memalignment.texi: New file.
* doc/gnulib.texi (Functions in <stdlib.h>): Include it.
Paul Eggert [Fri, 7 Feb 2025 22:36:55 +0000 (14:36 -0800)]
intprops: new macro INT_PROMOTE
Something like this was requested for Emacs.
* doc/intprops.texi (Arithmetic Type Conversion): New section.
* lib/intprops.h (INT_PROMOTE): New macro.
* tests/test-intprops.c: Test it.
Bruno Haible [Wed, 5 Feb 2025 20:04:34 +0000 (21:04 +0100)]
xstring-buffer-reversed: New module.
* lib/xstring-buffer-reversed.c: New file, based on
lib/xstring-buffer.c.
* lib/xstring-buffer-reversed-printf.c: New file, based on
lib/xstring-buffer-printf.c.
* modules/xstring-buffer-reversed: New file.
Bruno Haible [Wed, 5 Feb 2025 19:57:16 +0000 (20:57 +0100)]
string-buffer-reversed: New module.
* lib/string-buffer-reversed.h: New file, based on lib/string-buffer.h.
* lib/string-buffer-reversed.c: New file, based on lib/string-buffer.c.
* lib/string-buffer-reversed-printf.c: New file, based on
lib/string-buffer-printf.c.
* modules/string-buffer-reversed: New file.
Bruno Haible [Tue, 4 Feb 2025 11:00:50 +0000 (12:00 +0100)]
gnulib-tool: Fix the result of --create-testdir (regression yesterday).
* gnulib-tool.sh (func_emit_lib_Makefile_am): If $for_test, revert to
the previous code.
* pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): If for_test, revert
to the previous code.
Bruno Haible [Mon, 3 Feb 2025 22:55:39 +0000 (23:55 +0100)]
gnulib-tool: Apply libgnu.{,l}a specific CFLAGS to all its object files.
* gnulib-tool.sh (func_emit_initmacro_end): Define
${macro_prefix}_${libname}_{LIBOBJS,LTLIBOBJS,LIBOBJDEPS} macros, that
include libname in the base name of the object files.
(func_emit_lib_Makefile_am): Use ${macro_prefix}_${libname}_*LIBOBJS
values instead of ${macro_prefix}_*LIBOBJS values.
* pygnulib/GLEmiter.py (GLEmiter.initmacro_end): Define
{macro_prefix_arg}_{libname}_{LIBOBJS,LTLIBOBJS,LIBOBJDEPS} macros, that
include libname in the base name of the object files.
(GLEmiter.lib_Makefile_am):Use {macro_prefix}_{libname}_*LIBOBJS
values instead of {macro_prefix}_*LIBOBJS values.