| 1 |
# wctob.m4 |
| 2 |
# serial 14 |
| 3 |
dnl Copyright (C) 2008-2025 Free Software Foundation, Inc. |
| 4 |
dnl This file is free software; the Free Software Foundation |
| 5 |
dnl gives unlimited permission to copy and/or distribute it, |
| 6 |
dnl with or without modifications, as long as this notice is preserved. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
AC_DEFUN([gl_FUNC_WCTOB], |
| 10 |
[ |
| 11 |
AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) |
| 12 |
|
| 13 |
AC_CHECK_FUNCS_ONCE([wctob]) |
| 14 |
if test $ac_cv_func_wctob = no; then |
| 15 |
HAVE_WCTOB=0 |
| 16 |
HAVE_DECL_WCTOB=0 |
| 17 |
else |
| 18 |
HAVE_WCTOB=1 |
| 19 |
|
| 20 |
dnl Solaris 9 has the wctob() function but it does not work. |
| 21 |
dnl Cygwin 1.7.2 has the wctob() function but it clobbers caller-owned |
| 22 |
dnl registers, see <https://cygwin.com/ml/cygwin/2010-05/msg00015.html>. |
| 23 |
AC_REQUIRE([AC_PROG_CC]) |
| 24 |
AC_REQUIRE([gt_LOCALE_FR]) |
| 25 |
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles |
| 26 |
AC_CACHE_CHECK([whether wctob works], |
| 27 |
[gl_cv_func_wctob_works], |
| 28 |
[ |
| 29 |
dnl Initial guess, used when cross-compiling or when no suitable locale |
| 30 |
dnl is present. |
| 31 |
changequote(,)dnl |
| 32 |
case "$host_os" in |
| 33 |
# Guess no on Solaris <= 9 and Cygwin. |
| 34 |
solaris2.[1-9] | solaris2.[1-9].* | cygwin*) |
| 35 |
gl_cv_func_wctob_works="guessing no" ;; |
| 36 |
# Guess no on native Windows. |
| 37 |
mingw* | windows*) |
| 38 |
gl_cv_func_wctob_works="guessing no" ;; |
| 39 |
# Guess yes otherwise. |
| 40 |
*) gl_cv_func_wctob_works="guessing yes" ;; |
| 41 |
esac |
| 42 |
changequote([,])dnl |
| 43 |
case "$host_os" in |
| 44 |
cygwin*) |
| 45 |
AC_RUN_IFELSE( |
| 46 |
[AC_LANG_SOURCE([[ |
| 47 |
#include <locale.h> |
| 48 |
#include <wchar.h> |
| 49 |
|
| 50 |
register long global __asm__ ("%ebx"); |
| 51 |
|
| 52 |
int main () |
| 53 |
{ |
| 54 |
setlocale (LC_ALL, "en_US.UTF-8"); |
| 55 |
|
| 56 |
global = 0x12345678; |
| 57 |
if (wctob (0x00FC) != -1) |
| 58 |
return 1; |
| 59 |
if (global != 0x12345678) |
| 60 |
return 2; |
| 61 |
return 0; |
| 62 |
}]])], |
| 63 |
[:], |
| 64 |
[gl_cv_func_wctob_works=no], |
| 65 |
[:]) |
| 66 |
;; |
| 67 |
esac |
| 68 |
if test "$gl_cv_func_wctob_works" != no && test $LOCALE_FR != none; then |
| 69 |
AC_RUN_IFELSE( |
| 70 |
[AC_LANG_SOURCE([[ |
| 71 |
#include <locale.h> |
| 72 |
#include <stdlib.h> |
| 73 |
#include <wchar.h> |
| 74 |
int main () |
| 75 |
{ |
| 76 |
if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) |
| 77 |
{ |
| 78 |
wchar_t wc; |
| 79 |
|
| 80 |
if (mbtowc (&wc, "\374", 1) == 1) |
| 81 |
if (wctob (wc) != (unsigned char) '\374') |
| 82 |
return 1; |
| 83 |
} |
| 84 |
return 0; |
| 85 |
}]])], |
| 86 |
[gl_cv_func_wctob_works=yes], |
| 87 |
[gl_cv_func_wctob_works=no], |
| 88 |
[:]) |
| 89 |
fi |
| 90 |
]) |
| 91 |
case "$gl_cv_func_wctob_works" in |
| 92 |
*yes) ;; |
| 93 |
*) REPLACE_WCTOB=1 ;; |
| 94 |
esac |
| 95 |
if test $REPLACE_WCTOB = 0; then |
| 96 |
|
| 97 |
dnl IRIX 6.5 has the wctob() function but does not declare it. |
| 98 |
AC_CHECK_DECLS([wctob], [], [], [[ |
| 99 |
#include <wchar.h> |
| 100 |
]]) |
| 101 |
if test $ac_cv_have_decl_wctob != yes; then |
| 102 |
HAVE_DECL_WCTOB=0 |
| 103 |
fi |
| 104 |
fi |
| 105 |
fi |
| 106 |
]) |
| 107 |
|
| 108 |
# Prerequisites of lib/wctob.c. |
| 109 |
AC_DEFUN([gl_PREREQ_WCTOB], [ |
| 110 |
: |
| 111 |
]) |