From: Bruno Haible Date: Mon, 3 Apr 2023 12:24:37 +0000 (+0200) Subject: mbrtoc32 tests: Add comment. X-Git-Tag: v1.0~1527 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=09a9ccc95ddd3e4ffbf386cca440b944c91d3412;p=gnulib.git mbrtoc32 tests: Add comment. * m4/mbrtowc.m4 (gl_MBRTOWC_C_LOCALE): Add comment. * m4/mbrtoc32.m4 (gl_MBRTOC32_C_LOCALE): Add comment. * tests/test-mbrtoc32.c: Add comment. * tests/test-mbrtoc32-5.sh: Use symmetric coding style. * doc/posix-functions/mbrtoc32.texi: Update. --- diff --git a/ChangeLog b/ChangeLog index 2993b1561f..7bc1a008f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2023-04-03 Bruno Haible + + mbrtoc32 tests: Add comment. + * m4/mbrtowc.m4 (gl_MBRTOWC_C_LOCALE): Add comment. + * m4/mbrtoc32.m4 (gl_MBRTOC32_C_LOCALE): Add comment. + * tests/test-mbrtoc32.c: Add comment. + * tests/test-mbrtoc32-5.sh: Use symmetric coding style. + * doc/posix-functions/mbrtoc32.texi: Update. + 2023-04-02 Bruno Haible trim: Fix trim_trailing result in multibyte locales. diff --git a/doc/posix-functions/mbrtoc32.texi b/doc/posix-functions/mbrtoc32.texi index d95c670200..7c3d6c294a 100644 --- a/doc/posix-functions/mbrtoc32.texi +++ b/doc/posix-functions/mbrtoc32.texi @@ -12,7 +12,7 @@ glibc 2.15, macOS 11.1, FreeBSD 6.4, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 7 @item In the C or POSIX locales, this function can return @code{(size_t) -1} and set @code{errno} to @code{EILSEQ}: -glibc 2.23. +glibc 2.35. @item This function returns 0 instead of @code{(size_t) -2} when the input is empty: diff --git a/m4/mbrtoc32.m4 b/m4/mbrtoc32.m4 index f2de33aff6..d6401fe2e4 100644 --- a/m4/mbrtoc32.m4 +++ b/m4/mbrtoc32.m4 @@ -1,4 +1,4 @@ -# mbrtoc32.m4 serial 10 +# mbrtoc32.m4 serial 11 dnl Copyright (C) 2014-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -101,6 +101,11 @@ changequote([,])dnl ]) ]) +dnl +dnl POSIX:2018 says regarding mbrtowc: "In the POSIX locale an [EILSEQ] error +dnl cannot occur since all byte values are valid characters." It is reasonable +dnl to expect mbrtoc32 to behave in the same way. + AC_DEFUN([gl_MBRTOC32_C_LOCALE], [ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles diff --git a/m4/mbrtowc.m4 b/m4/mbrtowc.m4 index 4bf91bec3b..0c7a8bae69 100644 --- a/m4/mbrtowc.m4 +++ b/m4/mbrtowc.m4 @@ -712,6 +712,10 @@ dnl Test whether mbrtowc reports encoding errors in the C locale. dnl Although POSIX was never intended to allow this, the GNU C Library dnl and other implementations do it. See: dnl https://sourceware.org/bugzilla/show_bug.cgi?id=19932 +dnl POSIX has now clarified it: +dnl +dnl says: "In the POSIX locale an [EILSEQ] error cannot occur since all byte +dnl values are valid characters." AC_DEFUN([gl_MBRTOWC_C_LOCALE], [ diff --git a/tests/test-mbrtoc32-5.sh b/tests/test-mbrtoc32-5.sh index cd000fb3c7..4213772272 100755 --- a/tests/test-mbrtoc32-5.sh +++ b/tests/test-mbrtoc32-5.sh @@ -1,6 +1,9 @@ #!/bin/sh + # Test whether the POSIX locale has encoding errors. LC_ALL=C \ -${CHECKER} ./test-mbrtoc32${EXEEXT} 5 || exit +${CHECKER} ./test-mbrtoc32${EXEEXT} 5 || exit 1 LC_ALL=POSIX \ -${CHECKER} ./test-mbrtoc32${EXEEXT} 5 +${CHECKER} ./test-mbrtoc32${EXEEXT} 5 || exit 1 + +exit 0 diff --git a/tests/test-mbrtoc32.c b/tests/test-mbrtoc32.c index 0d75c3db14..a40309004e 100644 --- a/tests/test-mbrtoc32.c +++ b/tests/test-mbrtoc32.c @@ -386,6 +386,10 @@ main (int argc, char *argv[]) wc = (char32_t) 0xBADFACE; ret = mbrtoc32 (&wc, buf, 1, &state); + /* POSIX:2018 says regarding mbrtowc: "In the POSIX locale an + [EILSEQ] error cannot occur since all byte values are valid + characters." It is reasonable to expect mbrtoc32 to behave + in the same way. */ ASSERT (ret == 1); if (c < 0x80) /* c is an ASCII character. */