summaryrefslogtreecommitdiff
path: root/gnulib-m4/mbrtowc.m4
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2024-03-03 19:11:32 +0100
committerJörg Frings-Fürst <debian@jff.email>2024-03-03 19:11:32 +0100
commit00893e79fc62966067af1a106567db96bd170338 (patch)
tree52b35cd0b42ca28e62a2ffbecade2e13dd8332cf /gnulib-m4/mbrtowc.m4
parent26112352a774737e1ce5580c93654a26c1e82b39 (diff)
New upstream version 1.2upstream/1.2
Diffstat (limited to 'gnulib-m4/mbrtowc.m4')
-rw-r--r--gnulib-m4/mbrtowc.m4122
1 files changed, 64 insertions, 58 deletions
diff --git a/gnulib-m4/mbrtowc.m4 b/gnulib-m4/mbrtowc.m4
index ec8716b5..6ff51824 100644
--- a/gnulib-m4/mbrtowc.m4
+++ b/gnulib-m4/mbrtowc.m4
@@ -1,5 +1,5 @@
-# mbrtowc.m4 serial 38 -*- coding: utf-8 -*-
-dnl Copyright (C) 2001-2002, 2004-2005, 2008-2022 Free Software Foundation,
+# mbrtowc.m4 serial 44 -*- coding: utf-8 -*-
+dnl Copyright (C) 2001-2002, 2004-2005, 2008-2024 Free Software Foundation,
dnl Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -91,20 +91,25 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
fi
if test $REPLACE_MBSTATE_T = 1; then
case "$host_os" in
- mingw*) LIB_MBRTOWC= ;;
+ mingw* | windows*)
+ MBRTOWC_LIB=
+ ;;
*)
gl_WEAK_SYMBOLS
case "$gl_cv_have_weak" in
- *yes) LIB_MBRTOWC= ;;
- *) LIB_MBRTOWC="$LIBPTHREAD" ;;
+ *yes) MBRTOWC_LIB= ;;
+ *) MBRTOWC_LIB="$LIBPTHREAD" ;;
esac
;;
esac
else
- LIB_MBRTOWC=
+ MBRTOWC_LIB=
fi
- dnl LIB_MBRTOWC is expected to be '-pthread' or '-lpthread' on AIX
+ dnl MBRTOWC_LIB is expected to be '-pthread' or '-lpthread' on AIX
dnl with gcc or xlc, and empty otherwise.
+ AC_SUBST([MBRTOWC_LIB])
+ dnl For backward compatibility.
+ LIB_MBRTOWC="$MBRTOWC_LIB"
AC_SUBST([LIB_MBRTOWC])
])
@@ -114,7 +119,7 @@ dnl Result is REPLACE_MBSTATE_T.
dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to
dnl avoid inconsistencies.
-AC_DEFUN([gl_MBSTATE_T_BROKEN],
+AC_DEFUN_ONCE([gl_MBSTATE_T_BROKEN],
[
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
AC_REQUIRE([AC_CANONICAL_HOST])
@@ -126,7 +131,7 @@ AC_DEFUN([gl_MBSTATE_T_BROKEN],
dnl to override it, even if - like on MSVC - mbsinit() is only defined as
dnl an inline function, not as a global function.
if case "$host_os" in
- mingw*) true ;;
+ mingw* | windows*) true ;;
*) test $ac_cv_func_mbsinit = yes ;;
esac \
&& test $ac_cv_func_mbrtowc = yes; then
@@ -408,14 +413,16 @@ AC_DEFUN([gl_MBRTOWC_RETVAL],
dnl is present.
changequote(,)dnl
case "$host_os" in
- # Guess no on HP-UX, Solaris, native Windows.
- hpux* | solaris* | mingw*) gl_cv_func_mbrtowc_retval="guessing no" ;;
- # Guess yes otherwise.
- *) gl_cv_func_mbrtowc_retval="guessing yes" ;;
+ # Guess no on HP-UX, Solaris, native Windows.
+ hpux* | solaris* | mingw* | windows*)
+ gl_cv_func_mbrtowc_retval="guessing no" ;;
+ # Guess yes otherwise.
+ *)
+ gl_cv_func_mbrtowc_retval="guessing yes" ;;
esac
changequote([,])dnl
if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \
- || { case "$host_os" in mingw*) true;; *) false;; esac; }; then
+ || { case "$host_os" in mingw* | windows*) true;; *) false;; esac; }; then
AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
#include <locale.h>
@@ -426,7 +433,8 @@ int main ()
int result = 0;
int found_some_locale = 0;
/* This fails on Solaris. */
- if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
+ if (strcmp ("$LOCALE_FR_UTF8", "none") != 0
+ && setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
{
char input[] = "B\303\274\303\237er"; /* "Büßer" */
mbstate_t state;
@@ -442,7 +450,8 @@ int main ()
found_some_locale = 1;
}
/* This fails on HP-UX 11.11. */
- if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+ if (strcmp ("$LOCALE_JA", "none") != 0
+ && setlocale (LC_ALL, "$LOCALE_JA") != NULL)
{
char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
mbstate_t state;
@@ -577,13 +586,13 @@ AC_DEFUN([gl_MBRTOWC_STORES_INCOMPLETE],
dnl is present.
changequote(,)dnl
case "$host_os" in
- # Guess yes on native Windows.
- mingw*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;;
- *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;;
+ # Guess yes on native Windows.
+ mingw* | windows*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;;
+ *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;;
esac
changequote([,])dnl
case "$host_os" in
- mingw*)
+ mingw* | windows*)
AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
#include <locale.h>
@@ -677,31 +686,28 @@ AC_DEFUN([gl_MBRTOWC_EMPTY_INPUT],
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_CACHE_CHECK([whether mbrtowc works on empty input],
[gl_cv_func_mbrtowc_empty_input],
- [
- dnl Initial guess, used when cross-compiling or when no suitable locale
- dnl is present.
-changequote(,)dnl
- case "$host_os" in
- # Guess no on AIX and glibc systems.
- aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;;
- # Guess yes on native Windows.
- mingw*) gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
- *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
- esac
-changequote([,])dnl
- AC_RUN_IFELSE(
- [AC_LANG_SOURCE([[
- #include <wchar.h>
- static wchar_t wc;
- static mbstate_t mbs;
- int
- main (void)
- {
- return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2;
- }]])],
- [gl_cv_func_mbrtowc_empty_input=yes],
- [gl_cv_func_mbrtowc_empty_input=no],
- [:])
+ [AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[
+ #include <wchar.h>
+ static wchar_t wc;
+ static mbstate_t mbs;
+ int
+ main (void)
+ {
+ return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2;
+ }]])],
+ [gl_cv_func_mbrtowc_empty_input=yes],
+ [gl_cv_func_mbrtowc_empty_input=no],
+ [case "$host_os" in
+ # Guess no on AIX and glibc systems.
+ aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;;
+ # Guess no on Android.
+ linux*-android*) gl_cv_func_mbrtowc_empty_input="guessing no" ;;
+ # Guess no on native Windows.
+ mingw* | windows*) gl_cv_func_mbrtowc_empty_input="guessing no" ;;
+ *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
+ esac
+ ])
])
])
@@ -709,18 +715,17 @@ 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 <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],
[
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_CACHE_CHECK([whether the C locale is free of encoding errors],
[gl_cv_func_mbrtowc_C_locale_sans_EILSEQ],
- [
- dnl Initial guess, used when cross-compiling or when no suitable locale
- dnl is present.
- gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal"
-
- AC_RUN_IFELSE(
+ [AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <limits.h>
#include <locale.h>
@@ -741,13 +746,14 @@ AC_DEFUN([gl_MBRTOWC_C_LOCALE],
}
return 0;
]])],
- [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes],
- [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no],
- [case "$host_os" in
- # Guess yes on native Windows.
- mingw*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;;
- esac
- ])
+ [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes],
+ [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no],
+ [case "$host_os" in
+ # Guess yes on native Windows.
+ mingw* | windows*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;;
+ *) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal" ;;
+ esac
+ ])
])
])