+2024-05-23 Bruno Haible <bruno@clisp.org>
+
+ mbrtoc32: Work around bug in Cygwin 3.5.3.
+ * m4/mbrtoc32.m4 (gl_MBRTOC32_UTF8_LOCALE): New macro.
+ (gl_FUNC_MBRTOC32): Invoke it. If mbrtoc32 has this bug, define
+ MBRTOC32_MULTIBYTE_LOCALE_BUG and reset LOCALE_ZH_CN to 'none'.
+ * lib/mbrtoc32.c (mbrtoc32): Test MBRTOC32_MULTIBYTE_LOCALE_BUG.
+ * doc/posix-functions/mbrtoc32.texi: Mention the Cygwin bug.
+
2024-05-23 Bruno Haible <bruno@clisp.org>
access, euidaccess tests: Avoid test failures on Cygwin.
Solaris 11.4, mingw, MSVC 14.
@c For MSVC this is because it assumes that the input is always UTF-8 encoded.
@c See https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/mbrtoc16-mbrtoc323
+@item
+This function does not work when it's fed the input bytes one-by-one
+on some platforms:
+@c https://cygwin.com/pipermail/cygwin/2024-May/255989.html
+@c https://cygwin.com/pipermail/cygwin/2024-May/255990.html
+Cygwin 3.5.3.
@end itemize
Portability problems fixed by Gnulib module @code{mbrtoc32-regular}:
-# mbrtoc32.m4 serial 18
+# mbrtoc32.m4 serial 19
dnl Copyright (C) 2014-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
else
gl_MBRTOC32_EMPTY_INPUT
gl_MBRTOC32_C_LOCALE
+ gl_MBRTOC32_UTF8_LOCALE
case "$gl_cv_func_mbrtoc32_empty_input" in
*yes) ;;
*) AC_DEFINE([MBRTOC32_EMPTY_INPUT_BUG], [1],
REPLACE_MBRTOC32=1
;;
esac
+ case "$gl_cv_func_mbrtoc32_utf8_locale_works" in
+ *yes) ;;
+ *) AC_DEFINE([MBRTOC32_MULTIBYTE_LOCALE_BUG], [1],
+ [Define if the mbrtoc32 function does not accept the input bytes one-by-one.])
+ REPLACE_MBRTOC32=1
+ dnl Our replacement mbrtoc32 can handle UTF-8, but not GB18030.
+ LOCALE_ZH_CN=none
+ ;;
+ esac
fi
if test $HAVE_WORKING_MBRTOC32 = 0; then
REPLACE_MBRTOC32=1
])
])
+dnl Test whether mbrtoc32 works when it's fed the bytes one-by-one in an UTF-8
+dnl locale.
+
+AC_DEFUN([gl_MBRTOC32_UTF8_LOCALE],
+[
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether mbrtoc32 works in an UTF-8 locale],
+ [gl_cv_func_mbrtoc32_utf8_locale_works],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <locale.h>
+ #ifdef __HAIKU__
+ #include <stdint.h>
+ #endif
+ #include <uchar.h>
+ ]], [[
+ char *locale = setlocale (LC_ALL, "en_US.UTF-8");
+ if (locale)
+ {
+ /* This test fails on Cygwin 3.5.3. */
+ mbstate_t state = { 0, };
+ char32_t uc = 0xDEADBEEF;
+ /* \360\237\220\203 = U+0001F403 */
+ if (mbrtoc32 (&uc, "\360", 1, &state) != (size_t)-2)
+ return 1;
+ if (mbrtoc32 (&uc, "\237", 1, &state) != (size_t)-2)
+ return 2;
+ if (mbrtoc32 (&uc, "\220", 1, &state) != (size_t)-2)
+ return 3;
+ if (mbrtoc32 (&uc, "\203", 1, &state) != 1)
+ return 4;
+ if (uc != 0x0001F403)
+ return 5;
+ }
+ return 0;
+ ]])],
+ [gl_cv_func_mbrtoc32_utf8_locale_works=yes],
+ [gl_cv_func_mbrtoc32_utf8_locale_works=no],
+ [case "$host_os" in
+ # Guess no on Cygwin.
+ cygwin*) gl_cv_func_mbrtoc32_utf8_locale_works="guessing yes" ;;
+ *) gl_cv_func_mbrtoc32_utf8_locale_works="$gl_cross_guess_normal" ;;
+ esac
+ ])
+ ])
+])
+
dnl Test whether mbrtoc32 works not worse than mbrtowc.
dnl Result is HAVE_WORKING_MBRTOC32.