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.
Paul Eggert [Sun, 2 Feb 2025 23:32:15 +0000 (15:32 -0800)]
quotearg: pacify -Wswitch-enum
* lib/quotearg.c (quotearg_buffer_restyled): Use switch (+E), and
omit default case, to pacify gcc -Wswitch-enum. This is a good
way to pacify -Wswitch-enum when we don’t want to enumerate
all the enum values. Omit unnecessary ‘default: break;’s.
Paul Eggert [Sun, 2 Feb 2025 23:27:39 +0000 (15:27 -0800)]
test-gettext-h: check call results
* tests/test-gettext-h.c: Include string.h.
(main): Check return values of calls.
This also pacifies GCC, which otherwise might
warn about a variable being set but not used.
Bruno Haible [Tue, 28 Jan 2025 09:33:34 +0000 (10:33 +0100)]
git-version-gen: Change suffix.
* doc/package-version.texi (Propagating the package version): Drop the
git-version-gen postprocessing line, that does not work on Solaris.
* build-aux/git-version-gen: Likewise. Produce a suffix '-modified'
instead of '-dirty'.
Collin Funk [Sat, 25 Jan 2025 05:36:11 +0000 (21:36 -0800)]
ptsname_r: Work around ptsname_r bug on Solaris 11 OmniOS.
* lib/ptsname_r.c (ptsname_r): Ensure the resulting buffer is not
clobbered if it is too small on Solaris 11 OmniOS.
* m4/ptsname_r.m4 (gl_FUNC_PTSNAME_R): On Solaris 11 OmniOS, arrange to
override ptsname_r.
* doc/posix-functions/ptsname_r.texi: Document the bug.
Collin Funk [Sat, 25 Jan 2025 04:38:54 +0000 (20:38 -0800)]
strerrorname_np: Work around a bug on Solaris 11 OmniOS.
* m4/strerrorname_np.m4 (gl_CHECK_STRERRORNAME_NP): Test if
strerrorname_np returns NULL when given ERESTART or ESTRPIPE.
* doc/glibc-functions/strerrorname_np.texi: Document the bug.
Bruno Haible [Sat, 25 Jan 2025 03:07:32 +0000 (04:07 +0100)]
package-version: Simplify further.
* doc/package-version.texi (Propagating the package version): Recommend
use of gl_INIT_PACKAGE_VERSION instead of gl_INIT_PACKAGE.
* build-aux/git-version-gen: Likewise.
* m4/init-package-version.m4: Likewise.
(gl_INIT_PACKAGE_VERSION): Renamed from gl_INIT_PACKAGE. Take only one
argument. Don't fiddle with AC_PACKAGE_NAME, AC_PACKAGE_TARNAME,
PACKAGE.
(gl_RPL_INIT_AUTOMAKE): Update.
Bruno Haible [Fri, 24 Jan 2025 21:03:29 +0000 (22:03 +0100)]
package-version: Simplify its use.
Reported by Basil L. Contovounesios <basil@contovou.net> in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-01/msg00195.html>.
* doc/package-version.texi (Propagating the package version): Recommend
to pass the usual arguments to AC_INIT.
* m4/init-package-version.m4: Likewise.
(gl_INIT_PACKAGE): Define PACKAGE_VERSION and PACKAGE_STRING as needed.
(gl_RPL_INIT_AUTOMAKE): Improve quoting.
Bruno Haible [Fri, 24 Jan 2025 17:34:04 +0000 (18:34 +0100)]
sys_socket-h tests: Avoid compilation error on Solaris 11.4.
* doc/posix-headers/sys_socket.texi: Update.
* tests/test-sys_socket-h.c (main): Don't assume that all platforms that
have SOCK_CLOFORK also have MSG_CMSG_CLOFORK.
Bruno Haible [Thu, 23 Jan 2025 20:39:35 +0000 (21:39 +0100)]
bootstrap: Make it work with module 'package-version'.
Reported by Basil L. Contovounesios <basil@contovou.net> in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-01/msg00195.html>.
* top/bootstrap-funclib.sh (normalize_package_name): New variable.
(extract_package_name): Don't normalize the package name here.
(package): Also look at the first argument of a gl_INIT_PACKAGE
invocation.
* build-aux/bootstrap: Regenerated.
Bruno Haible [Wed, 22 Jan 2025 20:31:52 +0000 (21:31 +0100)]
doc: Document the workflows of the .tarball-version and .version files.
* doc/package-version.texi: New file.
* doc/gnulib.texi (Build Infrastructure Modules): Include it.
* build-aux/git-version-gen: Fix comments: Fix description of
.tarball-version. Recommend to invoke git-version-gen at configure time,
not at autoconf time. Remove description of .version. Rename Makefile
target 'tarball-version' to 'dist-tarball-version'.
* top/GNUmakefile: Improve comments.
Bruno Haible [Sun, 19 Jan 2025 09:40:02 +0000 (10:40 +0100)]
attribute: Add note about ongoing standardization of some attributes.
* m4/gnulib-common.m4 (gl_COMMON_BODY): Add note that the meaning of
_GL_ATTRIBUTE_REPRODUCIBLE and _GL_ATTRIBUTE_UNSEQUENCED are likely to
change.
* lib/attribute.h (UNSEQUENCED, REPRODUCIBLE): Likewise.
Paul Eggert [Sun, 19 Jan 2025 07:02:09 +0000 (23:02 -0800)]
flexmember: port to IBM XL C 16.1
* lib/flexmember.h (FLEXALIGNOF): Use the conservative definition
if _Alignof is a macro, to avoid a C99 conformance issue exposed
by IBM XL C 16.1 which otherwise complains "An aggregate
containing a flexible array member cannot be used as a member of a
structure or as an array element."
Paul Eggert [Sun, 19 Jan 2025 06:06:55 +0000 (22:06 -0800)]
alignasof: port to IBM XL C 16.1
* doc/gnulib.texi (alignof):
Improve doc to match implementationa better.
* m4/stdalign.m4 (alignas): Do not define to _Alignas
if __xlC__ claims to conform to C11, because _Alignas fails with
weird diagnostics "Unexpected text %1$s encountered."
* tests/test-alignasof.c (TEST_ALIGNMENT, alignas):
Follow doc advice.
Paul Eggert [Sat, 18 Jan 2025 06:11:54 +0000 (22:11 -0800)]
alignasof: port to IBM XL C V16.1
* m4/stdalign.m4 (gl_ALIGNASOF):
Work around similar bug in IBM XL C V16.1.0 cc (non-clang).
Since this is the last version of this obsolescent compiler,
assume the bug is in earlier versions.
* modules/stdalign, modules/stdalign-h, modules/stdnoreturn:
* modules/stdnoreturn-h: Use more consistent deprecation
warnings, that do not recommend a different deprecated module.
Bruno Haible [Fri, 17 Jan 2025 21:51:55 +0000 (22:51 +0100)]
sys_stat-h: Ensure blksize_t and blkcnt_t are defined.
* tests/test-sys_stat-h.c: Check that blksize_t and blkcnt_t are
defined. Include intprops.h. Check the signedness of various types.
* modules/sys_stat-h-tests (Depends-on): Add intprops.
* doc/posix-headers/sys_stat.texi: Mention the issues with blksize_t and
blkcnt_t.
Bruno Haible [Fri, 17 Jan 2025 21:32:58 +0000 (22:32 +0100)]
sys_types-h: Ensure blksize_t and blkcnt_t are defined.
* lib/sys_types.in.h (blksize_t, blkcnt_t): New definitions.
* m4/sys_types_h.m4 (gl_SYS_TYPES_H): Set HAVE_BLKSIZE_T and
HAVE_BLKCNT_T.
* modules/sys_types-h (Makefile.am): Substitute HAVE_BLKSIZE_T and
HAVE_BLKCNT_T.
* tests/test-sys_types-h.c: Check that blksize_t and blkcnt_t are
defined. Include intprops.h. Check the signedness of various types.
* modules/sys_types-h-tests (Depends-on): Add assert-h, intprops.
* doc/posix-headers/sys_types.texi: Mention the issues with blksize_t
and blkcnt_t.
Paul Eggert [Fri, 17 Jan 2025 18:39:38 +0000 (10:39 -0800)]
crc-x86_64: port to old GCC compilers
* m4/crc-x86_64.m4 (gl_CRC_X86_64_PCLMUL):
Check that the compiler supports __m128i_u, too,
since we’re using the type now. Issue reported in
the same message from Lasse Collin.
Paul Eggert [Fri, 17 Jan 2025 18:27:55 +0000 (10:27 -0800)]
crc-x86_64: better fix for unaligned access
Avoid undefined behavior in a way that doesn’t require
the input buffer to be aligned.
From a suggestion by Lasse Collin in:
https://lists.gnu.org/r/bug-gnulib/2025-01/msg00148.html
* lib/crc-x86_64-pclmul.c (crc32_update_no_xor_pclmul):
Since the const void * pointer ‘buf’ might not be aligned,
assign it to const __m128i_u * instead of to const __m128i *.
* lib/crc.c (crc32_update_no_xor):
Remove recently-addeda check for buffer alignment.
Paul Eggert [Fri, 17 Jan 2025 06:58:55 +0000 (22:58 -0800)]
crc-x86_64: fix unaligned access
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2025-01/msg00142.html
* lib/crc.c (crc32_update_no_xor): Don’t pass unaligned buffer to
crc32_update_no_xor_pclmul. No doubt there is a higher
performance fix, perhaps involving advancing byte-by-byte along
the buffer until we get to an aligned boundary, but at least this
should fix the alignment bug.