diff options
Diffstat (limited to 'gl/m4/btowc.m4')
| -rw-r--r-- | gl/m4/btowc.m4 | 85 |
1 files changed, 71 insertions, 14 deletions
diff --git a/gl/m4/btowc.m4 b/gl/m4/btowc.m4 index 77218a7d..d9dd7036 100644 --- a/gl/m4/btowc.m4 +++ b/gl/m4/btowc.m4 | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | # btowc.m4 serial 12 | 1 | # btowc.m4 |
| 2 | dnl Copyright (C) 2008-2023 Free Software Foundation, Inc. | 2 | # serial 14 |
| 3 | dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. | ||
| 3 | dnl This file is free software; the Free Software Foundation | 4 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 5 | dnl gives unlimited permission to copy and/or distribute it, |
| 5 | dnl with or without modifications, as long as this notice is preserved. | 6 | dnl with or without modifications, as long as this notice is preserved. |
| @@ -40,12 +41,12 @@ int main () | |||
| 40 | [ | 41 | [ |
| 41 | changequote(,)dnl | 42 | changequote(,)dnl |
| 42 | case "$host_os" in | 43 | case "$host_os" in |
| 43 | # Guess no on Cygwin. | 44 | # Guess no on Cygwin. |
| 44 | cygwin*) gl_cv_func_btowc_nul="guessing no" ;; | 45 | cygwin*) gl_cv_func_btowc_nul="guessing no" ;; |
| 45 | # Guess yes on native Windows. | 46 | # Guess yes on native Windows. |
| 46 | mingw*) gl_cv_func_btowc_nul="guessing yes" ;; | 47 | mingw* | windows*) gl_cv_func_btowc_nul="guessing yes" ;; |
| 47 | # Guess yes otherwise. | 48 | # Guess yes otherwise. |
| 48 | *) gl_cv_func_btowc_nul="guessing yes" ;; | 49 | *) gl_cv_func_btowc_nul="guessing yes" ;; |
| 49 | esac | 50 | esac |
| 50 | changequote([,])dnl | 51 | changequote([,])dnl |
| 51 | ]) | 52 | ]) |
| @@ -59,12 +60,12 @@ changequote([,])dnl | |||
| 59 | dnl is present. | 60 | dnl is present. |
| 60 | changequote(,)dnl | 61 | changequote(,)dnl |
| 61 | case "$host_os" in | 62 | case "$host_os" in |
| 62 | # Guess no on IRIX. | 63 | # Guess no on IRIX. |
| 63 | irix*) gl_cv_func_btowc_eof="guessing no" ;; | 64 | irix*) gl_cv_func_btowc_eof="guessing no" ;; |
| 64 | # Guess yes on native Windows. | 65 | # Guess yes on native Windows. |
| 65 | mingw*) gl_cv_func_btowc_eof="guessing yes" ;; | 66 | mingw* | windows*) gl_cv_func_btowc_eof="guessing yes" ;; |
| 66 | # Guess yes otherwise. | 67 | # Guess yes otherwise. |
| 67 | *) gl_cv_func_btowc_eof="guessing yes" ;; | 68 | *) gl_cv_func_btowc_eof="guessing yes" ;; |
| 68 | esac | 69 | esac |
| 69 | changequote([,])dnl | 70 | changequote([,])dnl |
| 70 | if test $LOCALE_FR != none; then | 71 | if test $LOCALE_FR != none; then |
| @@ -88,6 +89,50 @@ int main () | |||
| 88 | fi | 89 | fi |
| 89 | ]) | 90 | ]) |
| 90 | 91 | ||
| 92 | dnl On mingw, in the C locale, btowc is inconsistent with mbrtowc: | ||
| 93 | dnl mbrtowc avoids calling MultiByteToWideChar when MB_CUR_MAX is 1 and | ||
| 94 | dnl ___lc_codepage_func() is 0, but btowc is lacking this special case. | ||
| 95 | AC_CHECK_FUNCS_ONCE([mbrtowc]) | ||
| 96 | AC_CACHE_CHECK([whether btowc is consistent with mbrtowc in the C locale], | ||
| 97 | [gl_cv_func_btowc_consistent], | ||
| 98 | [ | ||
| 99 | AC_RUN_IFELSE( | ||
| 100 | [AC_LANG_SOURCE([[ | ||
| 101 | #include <stdlib.h> | ||
| 102 | #include <string.h> | ||
| 103 | #include <wchar.h> | ||
| 104 | int main () | ||
| 105 | { | ||
| 106 | #if HAVE_MBRTOWC | ||
| 107 | wint_t wc1 = btowc (0x80); | ||
| 108 | wchar_t wc2 = (wchar_t) 0xbadface; | ||
| 109 | char buf[1] = { 0x80 }; | ||
| 110 | mbstate_t state; | ||
| 111 | memset (&state, 0, sizeof (mbstate_t)); | ||
| 112 | if (mbrtowc (&wc2, buf, 1, &state) != 1 || wc1 != wc2) | ||
| 113 | return 1; | ||
| 114 | #endif | ||
| 115 | return 0; | ||
| 116 | }]])], | ||
| 117 | [gl_cv_func_btowc_consistent=yes], | ||
| 118 | [gl_cv_func_btowc_consistent=no], | ||
| 119 | [case "$host_os" in | ||
| 120 | # Guess no on mingw. | ||
| 121 | mingw* | windows*) | ||
| 122 | AC_EGREP_CPP([Problem], [ | ||
| 123 | #ifdef __MINGW32__ | ||
| 124 | Problem | ||
| 125 | #endif | ||
| 126 | ], | ||
| 127 | [gl_cv_func_btowc_consistent="guessing no"], | ||
| 128 | [gl_cv_func_btowc_consistent="guessing yes"]) | ||
| 129 | ;; | ||
| 130 | # Guess yes otherwise. | ||
| 131 | *) gl_cv_func_btowc_consistent="guessing yes" ;; | ||
| 132 | esac | ||
| 133 | ]) | ||
| 134 | ]) | ||
| 135 | |||
| 91 | case "$gl_cv_func_btowc_nul" in | 136 | case "$gl_cv_func_btowc_nul" in |
| 92 | *yes) ;; | 137 | *yes) ;; |
| 93 | *) REPLACE_BTOWC=1 ;; | 138 | *) REPLACE_BTOWC=1 ;; |
| @@ -96,10 +141,22 @@ int main () | |||
| 96 | *yes) ;; | 141 | *yes) ;; |
| 97 | *) REPLACE_BTOWC=1 ;; | 142 | *) REPLACE_BTOWC=1 ;; |
| 98 | esac | 143 | esac |
| 144 | case "$gl_cv_func_btowc_consistent" in | ||
| 145 | *yes) ;; | ||
| 146 | *) REPLACE_BTOWC=1 ;; | ||
| 147 | esac | ||
| 148 | if test $REPLACE_BTOWC = 0; then | ||
| 149 | gl_MBRTOWC_C_LOCALE | ||
| 150 | case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in | ||
| 151 | *yes) ;; | ||
| 152 | *) REPLACE_BTOWC=1 ;; | ||
| 153 | esac | ||
| 154 | fi | ||
| 99 | fi | 155 | fi |
| 100 | ]) | 156 | ]) |
| 101 | 157 | ||
| 102 | # Prerequisites of lib/btowc.c. | 158 | # Prerequisites of lib/btowc.c. |
| 103 | AC_DEFUN([gl_PREREQ_BTOWC], [ | 159 | AC_DEFUN([gl_PREREQ_BTOWC], [ |
| 104 | : | 160 | : |
| 161 | AC_CHECK_FUNCS_ONCE([mbrtowc]) | ||
| 105 | ]) | 162 | ]) |
