1# wcrtomb.m4 serial 11 2dnl Copyright (C) 2008-2013 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_WCRTOMB], 8[ 9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 10 11 AC_REQUIRE([AC_TYPE_MBSTATE_T]) 12 gl_MBSTATE_T_BROKEN 13 14 AC_CHECK_FUNCS_ONCE([wcrtomb]) 15 if test $ac_cv_func_wcrtomb = no; then 16 HAVE_WCRTOMB=0 17 AC_CHECK_DECLS([wcrtomb],,, [[ 18/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 19 <wchar.h>. 20 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be 21 included before <wchar.h>. */ 22#include <stddef.h> 23#include <stdio.h> 24#include <time.h> 25#include <wchar.h> 26]]) 27 if test $ac_cv_have_decl_wcrtomb = yes; then 28 dnl On Minix 3.1.8, the system's <wchar.h> declares wcrtomb() although 29 dnl it does not have the function. Avoid a collision with gnulib's 30 dnl replacement. 31 REPLACE_WCRTOMB=1 32 fi 33 else 34 if test $REPLACE_MBSTATE_T = 1; then 35 REPLACE_WCRTOMB=1 36 else 37 dnl On AIX 4.3, OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL) sometimes 38 dnl returns 0 instead of 1. 39 AC_REQUIRE([AC_PROG_CC]) 40 AC_REQUIRE([gt_LOCALE_FR]) 41 AC_REQUIRE([gt_LOCALE_FR_UTF8]) 42 AC_REQUIRE([gt_LOCALE_JA]) 43 AC_REQUIRE([gt_LOCALE_ZH_CN]) 44 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 45 AC_CACHE_CHECK([whether wcrtomb return value is correct], 46 [gl_cv_func_wcrtomb_retval], 47 [ 48 dnl Initial guess, used when cross-compiling or when no suitable locale 49 dnl is present. 50changequote(,)dnl 51 case "$host_os" in 52 # Guess no on AIX 4, OSF/1 and Solaris. 53 aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;; 54 # Guess yes otherwise. 55 *) gl_cv_func_wcrtomb_retval="guessing yes" ;; 56 esac 57changequote([,])dnl 58 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then 59 AC_RUN_IFELSE( 60 [AC_LANG_SOURCE([[ 61#include <locale.h> 62#include <string.h> 63/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 64 <wchar.h>. 65 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be 66 included before <wchar.h>. */ 67#include <stddef.h> 68#include <stdio.h> 69#include <time.h> 70#include <wchar.h> 71int main () 72{ 73 int result = 0; 74 if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) 75 { 76 if (wcrtomb (NULL, 0, NULL) != 1) 77 result |= 1; 78 } 79 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) 80 { 81 if (wcrtomb (NULL, 0, NULL) != 1) 82 result |= 2; 83 } 84 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) 85 { 86 if (wcrtomb (NULL, 0, NULL) != 1) 87 result |= 4; 88 } 89 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) 90 { 91 if (wcrtomb (NULL, 0, NULL) != 1) 92 result |= 8; 93 } 94 return result; 95}]])], 96 [gl_cv_func_wcrtomb_retval=yes], 97 [gl_cv_func_wcrtomb_retval=no], 98 [:]) 99 fi 100 ]) 101 case "$gl_cv_func_wcrtomb_retval" in 102 *yes) ;; 103 *) REPLACE_WCRTOMB=1 ;; 104 esac 105 fi 106 fi 107]) 108 109# Prerequisites of lib/wcrtomb.c. 110AC_DEFUN([gl_PREREQ_WCRTOMB], [ 111 : 112]) 113