* 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-03 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
trim: Fix trim_trailing result in multibyte locales.
@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:
-# 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,
])
])
+dnl <https://pubs.opengroup.org/onlinepubs/9699919799/functions/mbrtowc.html>
+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
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 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/mbrtowc.html>
+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],
[
#!/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
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. */