From: Bruno Haible Date: Tue, 27 Jun 2023 19:19:28 +0000 (+0200) Subject: mbrtowc, mbrtoc32: Simplify autoconf macros. X-Git-Tag: v1.0~1178 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=cd1ae3e11e81293127b40626c7f9f12f41a1e576;p=gnulib.git mbrtowc, mbrtoc32: Simplify autoconf macros. * m4/mbrtowc.m4 (gl_MBRTOWC_EMPTY_INPUT, gl_MBRTOWC_C_LOCALE): Put cross-compilation guess at the usual place. * m4/mbrtoc32.m4 (gl_MBRTOC32_EMPTY_INPUT, gl_MBRTOC32_C_LOCALE): Likewise. --- diff --git a/ChangeLog b/ChangeLog index 820285f2d9..a200f5078a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2023-06-28 Bruno Haible + + mbrtowc, mbrtoc32: Simplify autoconf macros. + * m4/mbrtowc.m4 (gl_MBRTOWC_EMPTY_INPUT, gl_MBRTOWC_C_LOCALE): Put + cross-compilation guess at the usual place. + * m4/mbrtoc32.m4 (gl_MBRTOC32_EMPTY_INPUT, gl_MBRTOC32_C_LOCALE): + Likewise. + 2023-06-27 Bruno Haible c32*: Optionally enforce ISO C 23 semantics of char32_t. diff --git a/m4/mbrtoc32.m4 b/m4/mbrtoc32.m4 index 52dd913f8a..f5798db4a3 100644 --- a/m4/mbrtoc32.m4 +++ b/m4/mbrtoc32.m4 @@ -1,4 +1,4 @@ -# mbrtoc32.m4 serial 15 +# mbrtoc32.m4 serial 16 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, @@ -87,15 +87,6 @@ AC_DEFUN([gl_MBRTOC32_EMPTY_INPUT], AC_CACHE_CHECK([whether mbrtoc32 works on empty input], [gl_cv_func_mbrtoc32_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 glibc systems. - *-gnu* | gnu*) gl_cv_func_mbrtoc32_empty_input="guessing no" ;; - *) gl_cv_func_mbrtoc32_empty_input="guessing yes" ;; - esac -changequote([,])dnl AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #ifdef __HAIKU__ @@ -111,7 +102,12 @@ changequote([,])dnl }]])], [gl_cv_func_mbrtoc32_empty_input=yes], [gl_cv_func_mbrtoc32_empty_input=no], - [:]) + [case "$host_os" in + # Guess no on glibc systems. + *-gnu* | gnu*) gl_cv_func_mbrtoc32_empty_input="guessing no" ;; + *) gl_cv_func_mbrtoc32_empty_input="guessing yes" ;; + esac + ]) ]) ]) @@ -125,12 +121,7 @@ AC_DEFUN([gl_MBRTOC32_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_mbrtoc32_C_locale_sans_EILSEQ], - [ - dnl Initial guess, used when cross-compiling or when no suitable locale - dnl is present. - gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ="$gl_cross_guess_normal" - - AC_RUN_IFELSE( + [AC_RUN_IFELSE( [AC_LANG_PROGRAM( [[#include #include @@ -154,13 +145,14 @@ AC_DEFUN([gl_MBRTOC32_C_LOCALE], } return 0; ]])], - [gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ=yes], - [gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ=no], - [case "$host_os" in - # Guess yes on native Windows. - mingw*) gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ="guessing yes" ;; - esac - ]) + [gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ=yes], + [gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ=no], + [case "$host_os" in + # Guess yes on native Windows. + mingw*) gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ="guessing yes" ;; + *) gl_cv_func_mbrtoc32_C_locale_sans_EILSEQ="$gl_cross_guess_normal" ;; + esac + ]) ]) ]) diff --git a/m4/mbrtowc.m4 b/m4/mbrtowc.m4 index 6173ded2ff..04e282d24a 100644 --- a/m4/mbrtowc.m4 +++ b/m4/mbrtowc.m4 @@ -1,4 +1,4 @@ -# mbrtowc.m4 serial 41 -*- coding: utf-8 -*- +# mbrtowc.m4 serial 42 -*- coding: utf-8 -*- dnl Copyright (C) 2001-2002, 2004-2005, 2008-2023 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -682,31 +682,26 @@ 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 - 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 + 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 yes on native Windows. + mingw*) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; + *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;; + esac + ]) ]) ]) @@ -724,12 +719,7 @@ 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 #include @@ -750,13 +740,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*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;; + *) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal" ;; + esac + ]) ]) ])