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