diff options
Diffstat (limited to 'gl/m4/btowc.m4')
| -rw-r--r-- | gl/m4/btowc.m4 | 56 |
1 files changed, 12 insertions, 44 deletions
diff --git a/gl/m4/btowc.m4 b/gl/m4/btowc.m4 index d9dd7036..93c9d769 100644 --- a/gl/m4/btowc.m4 +++ b/gl/m4/btowc.m4 | |||
| @@ -1,17 +1,19 @@ | |||
| 1 | # btowc.m4 | 1 | # btowc.m4 |
| 2 | # serial 14 | 2 | # serial 16 |
| 3 | dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. | 3 | dnl Copyright (C) 2008-2026 Free Software Foundation, Inc. |
| 4 | dnl This file is free software; the Free Software Foundation | 4 | dnl This file is free software; the Free Software Foundation |
| 5 | dnl gives unlimited permission to copy and/or distribute it, | 5 | dnl gives unlimited permission to copy and/or distribute it, |
| 6 | 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. |
| 7 | dnl This file is offered as-is, without any warranty. | ||
| 7 | 8 | ||
| 8 | AC_DEFUN([gl_FUNC_BTOWC], | 9 | AC_DEFUN([gl_FUNC_BTOWC], |
| 9 | [ | 10 | [ |
| 10 | AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) | 11 | AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) |
| 12 | AC_REQUIRE([gt_TYPE_WINT_T]) | ||
| 11 | 13 | ||
| 12 | dnl Check whether <wchar.h> is usable at all, first. Otherwise the test | 14 | dnl Check whether <wchar.h> is usable at all, first. Otherwise the test |
| 13 | dnl program below may lead to an endless loop. See | 15 | dnl program below may lead to an endless loop. See |
| 14 | dnl <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. | 16 | dnl <https://gcc.gnu.org/PR42440>. |
| 15 | AC_REQUIRE([gl_WCHAR_H_INLINE_OK]) | 17 | AC_REQUIRE([gl_WCHAR_H_INLINE_OK]) |
| 16 | 18 | ||
| 17 | AC_CHECK_FUNCS_ONCE([btowc]) | 19 | AC_CHECK_FUNCS_ONCE([btowc]) |
| @@ -52,43 +54,6 @@ changequote([,])dnl | |||
| 52 | ]) | 54 | ]) |
| 53 | ]) | 55 | ]) |
| 54 | 56 | ||
| 55 | dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF. | ||
| 56 | AC_CACHE_CHECK([whether btowc(EOF) is correct], | ||
| 57 | [gl_cv_func_btowc_eof], | ||
| 58 | [ | ||
| 59 | dnl Initial guess, used when cross-compiling or when no suitable locale | ||
| 60 | dnl is present. | ||
| 61 | changequote(,)dnl | ||
| 62 | case "$host_os" in | ||
| 63 | # Guess no on IRIX. | ||
| 64 | irix*) gl_cv_func_btowc_eof="guessing no" ;; | ||
| 65 | # Guess yes on native Windows. | ||
| 66 | mingw* | windows*) gl_cv_func_btowc_eof="guessing yes" ;; | ||
| 67 | # Guess yes otherwise. | ||
| 68 | *) gl_cv_func_btowc_eof="guessing yes" ;; | ||
| 69 | esac | ||
| 70 | changequote([,])dnl | ||
| 71 | if test $LOCALE_FR != none; then | ||
| 72 | AC_RUN_IFELSE( | ||
| 73 | [AC_LANG_SOURCE([[ | ||
| 74 | #include <locale.h> | ||
| 75 | #include <stdio.h> | ||
| 76 | #include <wchar.h> | ||
| 77 | int main () | ||
| 78 | { | ||
| 79 | if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) | ||
| 80 | { | ||
| 81 | if (btowc (EOF) != WEOF) | ||
| 82 | return 1; | ||
| 83 | } | ||
| 84 | return 0; | ||
| 85 | }]])], | ||
| 86 | [gl_cv_func_btowc_eof=yes], | ||
| 87 | [gl_cv_func_btowc_eof=no], | ||
| 88 | [:]) | ||
| 89 | fi | ||
| 90 | ]) | ||
| 91 | |||
| 92 | dnl On mingw, in the C locale, btowc is inconsistent with mbrtowc: | 57 | 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 | 58 | 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. | 59 | dnl ___lc_codepage_func() is 0, but btowc is lacking this special case. |
| @@ -133,14 +98,17 @@ int main () | |||
| 133 | ]) | 98 | ]) |
| 134 | ]) | 99 | ]) |
| 135 | 100 | ||
| 101 | if test $GNULIBHEADERS_OVERRIDE_WINT_T = 1; then | ||
| 102 | dnl On mingw/ucrt, we override the return type of btowc(). | ||
| 103 | dnl While the original wint_t (= unsigned short) and the overridden wint_t | ||
| 104 | dnl (= unsigned int) are equivalent in function parameters, this is not | ||
| 105 | dnl the case for function return types. | ||
| 106 | REPLACE_BTOWC=1 | ||
| 107 | fi | ||
| 136 | case "$gl_cv_func_btowc_nul" in | 108 | case "$gl_cv_func_btowc_nul" in |
| 137 | *yes) ;; | 109 | *yes) ;; |
| 138 | *) REPLACE_BTOWC=1 ;; | 110 | *) REPLACE_BTOWC=1 ;; |
| 139 | esac | 111 | esac |
| 140 | case "$gl_cv_func_btowc_eof" in | ||
| 141 | *yes) ;; | ||
| 142 | *) REPLACE_BTOWC=1 ;; | ||
| 143 | esac | ||
| 144 | case "$gl_cv_func_btowc_consistent" in | 112 | case "$gl_cv_func_btowc_consistent" in |
| 145 | *yes) ;; | 113 | *yes) ;; |
| 146 | *) REPLACE_BTOWC=1 ;; | 114 | *) REPLACE_BTOWC=1 ;; |
