Paul Eggert [Sun, 30 Jul 2023 00:06:42 +0000 (17:06 -0700)]
readutmp: work around glibc utmpx bug
When compiled with _TIME_BITS=64, glibc <utmpx.h> does not work,
because the files use 32-bit time_t and the code passes this to
the user unmodified, but <utmpx.h> defines a struct with 64-bit
time_t. Work around this compatibility bug. Problem reported
by Jakub Wilk via Sven Joachim <https://bugs.gnu.org/64937>.
* lib/readutmp.c (copy_utmp_entry): New function.
(read_utmp): Use it.
Bruno Haible [Fri, 28 Jul 2023 13:15:26 +0000 (15:15 +0200)]
uchar: Include the necessary snippets.
* lib/uchar.in.h: Add insertion points for _GL_ARG_NONNULL and
_GL_WARN_ON_USE.
* modules/uchar (Depends-on): Add snippet/arg-nonnull,
snippet/warn-on-use.
(Makefile.am): In uchar.h, include the ARG_NONNULL_H and WARN_ON_USE_H
snippets.
Bruno Haible [Fri, 28 Jul 2023 11:56:15 +0000 (13:56 +0200)]
mbmemcasecmp, mbmemcasecoll: Avoid test failure on MSVC.
* tests/test-mbmemcasecmp.h (test_utf_8): Disable two tests on platforms
that don't have the upper/lower mappings for 'ü'/'Ü'.
* tests/test-mbmemcasecmp.c: Include <wchar.h>, <wctype.h>.
* tests/test-mbmemcasecoll.c: Likewise.
* modules/mbmemcasecmp-tests (Depends-on): Add mbrtowc, wctype-h.
* modules/mbmemcasecoll-tests (Depends-on): Likewise.
Bruno Haible [Thu, 27 Jul 2023 20:19:08 +0000 (22:19 +0200)]
fnmatch-h, glob-h tests: Fix link errors (regression 2023-07-24).
* modules/fnmatch-h-c++-tests (Makefile.am): Link test-fnmatch-h-c++
with $(LIBUNISTRING).
* modules/glob-h-c++-tests (Makefile.am): Link test-glob-h-c++ with
$(LIBUNISTRING).
Bruno Haible [Thu, 27 Jul 2023 18:52:36 +0000 (20:52 +0200)]
fnmatch, glob tests: Fix link errors (regression 2023-07-24).
* modules/fnmatch-tests (Makefile.am): Link test-fnmatch-w32 with the
same libraries as test-fnmatch.
* modules/glob (Link): Add $(LIBUNISTRING).
* modules/glob-tests (Makefile.am): Link test-glob with $(LIBUNISTRING).
Bruno Haible [Wed, 26 Jul 2023 13:12:47 +0000 (15:12 +0200)]
wctype: Work around wctype+iswctype bug on MSVC.
* m4/wctype.m4 (gl_FUNC_WCTYPE): In the test program, test also for the
MSVC bug. Update cross-compilation guess.
* doc/posix-functions/wctype.texi: Mention the MSVC bug.
Bruno Haible [Wed, 26 Jul 2023 12:50:00 +0000 (14:50 +0200)]
wctype: Work around wctype bug on mingw.
* lib/wctype.in.h (rpl_wctype_t, wctype_t, GNULIB_defined_wctype_t):
Define if REPLACE_WCTYPE is 1.
(wctype): Consider REPLACE_WCTYPE.
(iswctype): Override also if REPLACE_WCTYPE is 1.
* lib/iswctype.c: If GNULIB_defined_wctype_t is defined, use the
function-pointer based implementation.
* m4/wctype_h.m4 (gl_WCTYPE_H_DEFAULTS): Initialize REPLACE_WCTYPE.
* m4/wctype.m4 (gl_FUNC_WCTYPE): Define through AC_DEFUN_ONCE. Test
whether wctype supports the "blank" character class. Set REPLACE_WCTYPE
if not.
* m4/iswctype.m4 (gl_FUNC_ISWCTYPE): Require gl_FUNC_WCTYPE.
* modules/wctype (Status, Notice): Remove.
(Depends-on): Add iswctype. Consider REPLACE_WCTYPE.
(configure.ac): Consider REPLACE_WCTYPE.
* modules/iswctype (Status, Notice): Remove.
(Files): Add m4/wctype.m4.
(configure.ac): Override also if REPLACE_WCTYPE is 1.
* modules/wctype-h (Makefile.am): Substitute REPLACE_WCTYPE.
* doc/posix-functions/wctype.texi: Mention the mingw bug.
Bruno Haible [Wed, 26 Jul 2023 12:13:48 +0000 (14:13 +0200)]
wctype-h: Work around iswprint bug on mingw.
* lib/wctype.in.h (rpl_iswprint): On mingw, don't use the system's
iswprint function.
* tests/test-wctype-h.c (main): Verify that this character class
contains the ASCII space but not tab and newline.
* tests/test-c32isprint.c (main): For tab, \v, \f, expect the same value
on native Windows as on other platforms.
* doc/posix-functions/iswprint.texi: Mention the mingw bug.
Bruno Haible [Wed, 26 Jul 2023 11:40:06 +0000 (13:40 +0200)]
wctype, wctrans: Require a non-NULL argument.
* lib/wctype.in.h: Add placeholder for definition of _GL_ARG_NONNULL.
(wctype, wctrans): Mark with _GL_ARG_NONNULL ((1)).
* modules/wctype-h (Depends-on): Add snippet/arg-nonnull.
(Makefile.am): Substitute $(ARG_NONNULL_H) into wctype.h.
Bruno Haible [Tue, 25 Jul 2023 21:39:15 +0000 (23:39 +0200)]
iswctype: Add tests.
* tests/test-iswctype.c: New file, based on
tests/test-c32_apply_type_test.c.
* tests/test-c32_apply_type_test.c (main): Update accordingly.
* modules/iswctype-tests: New file.
Bruno Haible [Tue, 25 Jul 2023 20:20:51 +0000 (22:20 +0200)]
unistr/u8-*: Make Unicode decoder more Unicode Standard compliant.
Based on a remark by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-07/msg00120.html>.
* tests/unistr/test-u8-mbtouc.c (test_safe_function): Change expected
results for "non-shortest form" or out-of-range byte sequences. Add new
test cases of incomplete well-formed byte sequences.
* tests/unistr/test-u8-mbsnlen.c (main): Likewise.
* lib/unistr/u8-mbtouc-aux.c (u8_mbtouc_aux): Reject a first byte in the
range 0xF5..0xF7 as invalid. Distinguish incomplete from invalid byte
sequences correctly. For the former, return only the number of bytes in
the maximal well-formed subpart.
* lib/unistr/u8-mbtouc.c (u8_mbtouc): Likewise.
* lib/unistr/u8-check.c (u8_check): Reject a first byte in the range
0xF5..0xF7 as invalid.
* lib/unistr/u8-mblen.c (u8_mblen): Likewise.
* lib/unistr/u8-mbtoucr.c (u8_mbtoucr): Likewise.
* lib/unistr/u8-strmbtouc.c (u8_strmbtouc): Likewise.
* lib/unistr/u8-strmblen.c (u8_strmblen): Likewise.
* lib/unistr/u8-prev.c (u8_prev): Likewise.
Bruno Haible [Mon, 24 Jul 2023 10:08:23 +0000 (12:08 +0200)]
fnmatch: Overcome wchar_t limitations.
* m4/fnmatch.m4 (gl_FUNC_FNMATCH_POSIX): Set REPLACE_FNMATCH to 1 on
AIX in 32-bit mode.
* lib/fnmatch.c: Include <uchar.h>. Conditionally include unistr.h.
(UCHAR_TO_WCHAR): Renamed from BTOWC.
(WCHAR_T, WINT_T, BTOWC, MBSRTOWCS, WCSLEN, WCSCAT, WMEMPCPY, WMEMCHR,
TOWLOWER, WCTYPE_T, WCTYPE, ISWCTYPE): New macros.
(IS_CHAR_CLASS): Use WCTYPE instead of wctype.
(UCHAR_TO_WCHAR): Use BTOWC instead of btowc.
(FOLD): Use TOWLOWER instead of towlower.
(CHAR): Use WCHAR_T instead of wchar_t.
(UCHAR, INT): Use WINT_T instead of wint_t.
(STRLEN): Use WCSLEN instead of wcslen.
(STRCAT): Use WCSCAT instead of wcscat.
(MEMPCPY): Use WMEMPCPY instead of wmempcpy.
(MEMCHR): Use WMEMCHR instead of wmemchr.
(is_char_class): Use WCTYPE_T instead of wctype_t, WCHAR_T instead of
wchar_t, WCTYPE instead of wctype.
(fnmatch): Use WCHAR_T instead of wchar_t, MBSRTOWCS instead of
mbsrtowcs.
* lib/fnmatch_loop.c (FCT): Use WCTYPE_T instead of wctype_t, ISWCTYPE
instead of iswctype. Update for renamed BTOWC.
* modules/fnmatch (Depends-on): Add btoc32, c32tolower,
c32_get_type_test, c32_apply_type_test, mbsrtoc32s, unistr/u32-chr,
unistr/u32-pcpy, unistr/u32-strcat, unistr/u32-strlen.
(Link): Add $(LIBUNISTRING).
* modules/fnmatch-tests (Makefile.am): Link test-fnmatch with
$(LIBUNISTRING).
* doc/posix-functions/fnmatch.texi: Move the Cygwin, mingw, MSVC, AIX
bug descriptions to the "fixed by Gnulib" section.
Bruno Haible [Sun, 23 Jul 2023 13:26:28 +0000 (15:26 +0200)]
fnmatch: Work around bugs on FreeBSD, NetBSD, Solaris, Cygwin, Android.
* m4/fnmatch.m4 (gl_FUNC_FNMATCH_POSIX): Add three more test cases to
the test program. Reorganize its return values.
* tests/test-fnmatch.c (main): Reflect the changes done in fnmatch.m4.
* doc/posix-functions/fnmatch.texi: Move the corresponding bug
descriptions to the "fixed by Gnulib" section.
Bruno Haible [Sun, 23 Jul 2023 12:04:59 +0000 (14:04 +0200)]
fnmatch, fnmatch-gnu: Document known bugs.
* doc/posix-headers/fnmatch.texi: Mention the macros FNM_LEADING_DIR,
FNM_CASEFOLD, FNM_EXTMATCH, FNM_FILE_NAME.
* doc/posix-functions/fnmatch.texi: Reference the glibc documentation
and the Linux man page. Document the effects of the two modules and all
the known bugs in detail.
Bruno Haible [Sat, 22 Jul 2023 23:43:43 +0000 (01:43 +0200)]
fnmatch tests: Add many more test cases.
* lib/fnmatch.in.h (GNULIB_defined_fnmatch_function): New macro.
* tests/test-fnmatch.c: Add many more test cases.
* tests/test-fnmatch-1.sh: New file, based on tests/test-mbrtoc32-5.sh.
* tests/test-fnmatch-2.sh: New file, based on tests/test-mbrtoc32-1.sh.
* tests/test-fnmatch-3.sh: New file, based on tests/test-mbrtoc32-2.sh.
* tests/test-fnmatch-4.sh: New file, based on tests/test-mbrtoc32-3.sh.
* tests/test-fnmatch-5.sh: New file, based on tests/test-mbrtoc32-4.sh.
* tests/test-fnmatch-w32.c: New file, based on tests/test-mbrtoc32-w32.c
and tests/test-fnmatch.c.
* tests/test-fnmatch-w32-1.sh: New file, based on
tests/test-mbrtoc32-w32-1.sh.
* tests/test-fnmatch-w32-2.sh: New file, based on
tests/test-mbrtoc32-w32-2.sh.
* tests/test-fnmatch-w32-3.sh: New file, based on
tests/test-mbrtoc32-w32-3.sh.
* tests/test-fnmatch-w32-4.sh: New file, based on
tests/test-mbrtoc32-w32-4.sh.
* tests/test-fnmatch-w32-5.sh: New file, based on
tests/test-mbrtoc32-w32-5.sh.
* tests/test-fnmatch-w32-6.sh: New file, based on
tests/test-mbrtoc32-w32-6.sh.
* tests/test-fnmatch-w32-7.sh: New file, based on
tests/test-mbrtoc32-w32-7.sh.
* modules/fnmatch-tests: Add the new program and shell scripts.
* tests/unistr/test-pcpy.h: New file, based on tests/unistr/test-cpy.h.
* tests/unistr/test-u8-pcpy.c: New file, based on
tests/unistr/test-u8-cpy.c.
* tests/unistr/test-u16-pcpy.c: New file, based on
tests/unistr/test-u16-cpy.c.
* tests/unistr/test-u32-pcpy.c: New file, based on
tests/unistr/test-u32-cpy.c.
* modules/unistr/u8-pcpy-tests: New file, based on
modules/unistr/u8-cpy-tests.
* modules/unistr/u16-pcpy-tests: New file, based on
modules/unistr/u16-cpy-tests.
* modules/unistr/u32-pcpy-tests: New file, based on
modules/unistr/u32-cpy-tests.
Bruno Haible [Fri, 21 Jul 2023 09:16:04 +0000 (11:16 +0200)]
unistr/u8-pcpy, unistr/u16-pcpy, unistr/u32-pcpy: New modules.
* lib/unistr.in.h (u8_pcpy, u16_pcpy, u32_pcpy): New declarations.
* lib/unistr/u-pcpy.h: New file, based on lib/wmempcpy.c.
* lib/unistr/u8-pcpy.c: New file, based on lib/unistr/u8-cpy.c.
* lib/unistr/u16-pcpy.c: New file, based on lib/unistr/u16-cpy.c.
* lib/unistr/u32-pcpy.c: New file, based on lib/unistr/u32-cpy.c.
* modules/unistr/u8-pcpy: New file, based on modules/unistr/u8-cpy.
* modules/unistr/u16-pcpy: New file, based on modules/unistr/u16-cpy.
* modules/unistr/u32-pcpy: New file, based on modules/unistr/u32-cpy.
Bruno Haible [Wed, 19 Jul 2023 23:35:10 +0000 (01:35 +0200)]
Document migration path for obsolescent functions.
* doc/glibc-functions/timespec_get.texi: Add reference to ISO C.
* doc/posix-functions/_tolower.texi: Recommend use of tolower.
* doc/posix-functions/_toupper.texi: Recommend use of toupper.
* doc/posix-functions/asctime.texi: Recommend use of strftime.
* doc/posix-functions/asctime_r.texi: Likewise.
* doc/posix-functions/ctime.texi: Recommend use of localtime_r and
strftime.
* doc/posix-functions/ctime_r.texi: Likewise.
* doc/posix-functions/ftw.texi: Recommend use of fts.
* doc/posix-functions/getitimer.texi: Recommend use of timer_gettime.
* doc/posix-functions/gets.texi: Recommend use of fgets.
* doc/posix-functions/gettimeofday.texi: Recommend use of gettime or
timespec_get.
* doc/posix-functions/inet_addr.texi: Recommend use of inet_pton.
* doc/posix-functions/inet_ntoa.texi: Recommend use of inet_ntop.
* doc/posix-functions/pthread_getconcurrency.texi: Recommend no-op.
* doc/posix-functions/pthread_setconcurrency.texi: Recommend no-op.
* doc/posix-functions/rand_r.texi: Recommend use of random_r.
* doc/posix-functions/setitimer.texi: Recommend use of timer_create and
timer_settime.
* doc/posix-functions/setpgrp.texi: Recommend use of setpgid or setsid.
* doc/posix-functions/sighold.texi: Recommend use of sigprocmask.
* doc/posix-functions/sigignore.texi: Recommend use of sigaction.
* doc/posix-functions/siginterrupt.texi: Recommend use of sigaction.
* doc/posix-functions/sigpause.texi: Recommend use of sigsuspend.
* doc/posix-functions/sigrelse.texi: Recommend use of sigprocmask.
* doc/posix-functions/sigset.texi: Recommend use of sigaction.
* doc/posix-functions/tempnam.texi: Recommend use of mkstemp.
* doc/posix-functions/ulimit.texi: Recommend use of getrlimit and
setrlimit.
* doc/posix-functions/utime.texi: Recommend use of utimens.
Paul Eggert [Wed, 19 Jul 2023 20:51:55 +0000 (13:51 -0700)]
Don’t worry about Version 7 tolower
Some code ported back to pre-C89 libraries where tolower (C) had
undefined behavior if C is not an upper case character.
Nowadays that function is _tolower which is itself obsolete,
and much Gnulib code already assumes this part of C89 anyway.
Assume C89 or better tolower, which simplifies the code
and should improve performance slightly.
* lib/mbmemcasecmp.c, lib/mbmemcasecoll.c, lib/mbscasecmp.c:
* lib/mbscasestr.c, lib/mbsncasecmp.c, lib/mbspcasecmp.c:
* lib/strcasecmp.c, lib/strcasestr.c, lib/strncasecmp.c:
(TOLOWER): Remove. All uses replaced by tolower.
Paul Eggert [Wed, 19 Jul 2023 03:33:41 +0000 (20:33 -0700)]
mbiterf, mbuiterf: port to strict C17
I ran into this problem on NetBSD 9.3.
* lib/mbiterf.h (mbiterf_next) [!GNULIB_MBRTOC32_REGULAR]:
* lib/mbuiterf.h (mbuiterf_next) [!GNULIB_MBRTOC32_REGULAR]:
Don’t label a declaration.
Bruno Haible [Tue, 18 Jul 2023 11:24:35 +0000 (13:24 +0200)]
mbuiterf: New module.
* lib/mbuiterf.h: New file, based on lib/mbuiter.h.
* lib/mbuiterf.c: New file, based on lib/mbuiter.c.
* modules/mbuiterf: New file, based on modules/mbuiter.
Bruno Haible [Tue, 18 Jul 2023 10:13:57 +0000 (12:13 +0200)]
mbiterf: New module.
* lib/mbiterf.h: New file, based on lib/mbiter.h.
* lib/mbiterf.c: New file, based on lib/mbiter.c.
* modules/mbiterf: New file, based on modules/mbiter.
Bruno Haible [Mon, 17 Jul 2023 18:50:30 +0000 (20:50 +0200)]
mbuiter: Optimize.
* lib/mbuiter.h (struct mbuiter_multi): Add cur_max field.
(mbui_init): Initialize it.
(mbuiter_multi_next): Use it instead of MB_CUR_MAX.
(mbuiter_multi_copy): Update.
Bruno Haible [Mon, 17 Jul 2023 17:11:38 +0000 (19:11 +0200)]
mbchar: Reduce size of 'struct mbchar'.
* modules/mbfile (configure.ac): Define GNULIB_MBFILE as an indicator.
* lib/mbchar.h (MBCHAR_BUF_SIZE): Set to 4.
(struct mbchar): Disable member 'buf' if the module 'mbfile' is not in
use.
Bruno Haible [Mon, 17 Jul 2023 16:00:24 +0000 (18:00 +0200)]
mbszero: Source code tweaks.
Suggested by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-07/msg00084.html>.
* lib/wchar.in.h: Comment changes.
(_GL_MBSTATE_INIT_SIZE): Don't define on NetBSD, Solaris, native
Windows. Use a safe default at the end.
(_GL_MBSTATE_ZERO_SIZE): Don't define on AIX, IRIX, Solaris, native
Windows. Use a safe default at the end.
* lib/mbrtoc16.c: Update comments accordingly.