"Fossies" - the Fresh Open Source Software Archive

Member "nano-4.5/m4/wcrtomb.m4" (11 Mar 2019, 4939 Bytes) of package /linux/misc/nano-4.5.tar.xz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # wcrtomb.m4 serial 14
    2 dnl Copyright (C) 2008-2019 Free Software Foundation, Inc.
    3 dnl This file is free software; the Free Software Foundation
    4 dnl gives unlimited permission to copy and/or distribute it,
    5 dnl with or without modifications, as long as this notice is preserved.
    6 
    7 AC_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     fi
   37     if test $REPLACE_WCRTOMB = 0; then
   38       dnl On Android 4.3, wcrtomb produces wrong characters in the C locale.
   39       dnl On AIX 4.3, OSF/1 5.1 and Solaris <= 11.3, wcrtomb (NULL, 0, NULL)
   40       dnl sometimes returns 0 instead of 1.
   41       AC_REQUIRE([AC_PROG_CC])
   42       AC_REQUIRE([gt_LOCALE_FR])
   43       AC_REQUIRE([gt_LOCALE_FR_UTF8])
   44       AC_REQUIRE([gt_LOCALE_JA])
   45       AC_REQUIRE([gt_LOCALE_ZH_CN])
   46       AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   47       AC_CACHE_CHECK([whether wcrtomb works in the C locale],
   48         [gl_cv_func_wcrtomb_works],
   49         [AC_RUN_IFELSE(
   50            [AC_LANG_SOURCE([[
   51 #include <string.h>
   52 #include <stdlib.h>
   53 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
   54    <wchar.h>.
   55    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
   56    included before <wchar.h>.  */
   57 #include <stddef.h>
   58 #include <stdio.h>
   59 #include <wchar.h>
   60 int main ()
   61 {
   62   mbstate_t state;
   63   char out[64];
   64   int count;
   65   memset (&state, 0, sizeof (state));
   66   out[0] = 'x';
   67   count = wcrtomb (out, L'a', &state);
   68   return !(count == 1 && out[0] == 'a');
   69 }]])],
   70            [gl_cv_func_wcrtomb_works=yes],
   71            [gl_cv_func_wcrtomb_works=no],
   72            [case "$host_os" in
   73                                # Guess no on Android.
   74               linux*-android*) gl_cv_func_wcrtomb_works="guessing no";;
   75                                # Guess yes otherwise.
   76               *)               gl_cv_func_wcrtomb_works="guessing yes";;
   77             esac
   78            ])
   79         ])
   80       case "$gl_cv_func_wcrtomb_works" in
   81         *yes) ;;
   82         *) REPLACE_WCRTOMB=1 ;;
   83       esac
   84     fi
   85     if test $REPLACE_WCRTOMB = 0; then
   86       AC_CACHE_CHECK([whether wcrtomb return value is correct],
   87         [gl_cv_func_wcrtomb_retval],
   88         [
   89           dnl Initial guess, used when cross-compiling or when no suitable locale
   90           dnl is present.
   91 changequote(,)dnl
   92           case "$host_os" in
   93                                      # Guess no on AIX 4, OSF/1 and Solaris.
   94             aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;;
   95                                      # Guess yes on native Windows.
   96             mingw*)                  gl_cv_func_wcrtomb_retval="guessing yes" ;;
   97                                      # Guess yes otherwise.
   98             *)                       gl_cv_func_wcrtomb_retval="guessing yes" ;;
   99           esac
  100 changequote([,])dnl
  101           if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
  102             AC_RUN_IFELSE(
  103               [AC_LANG_SOURCE([[
  104 #include <locale.h>
  105 #include <string.h>
  106 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
  107    <wchar.h>.
  108    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
  109    included before <wchar.h>.  */
  110 #include <stddef.h>
  111 #include <stdio.h>
  112 #include <time.h>
  113 #include <wchar.h>
  114 int main ()
  115 {
  116   int result = 0;
  117   if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
  118     {
  119       if (wcrtomb (NULL, 0, NULL) != 1)
  120         result |= 1;
  121     }
  122   if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
  123     {
  124       if (wcrtomb (NULL, 0, NULL) != 1)
  125         result |= 2;
  126     }
  127   if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
  128     {
  129       if (wcrtomb (NULL, 0, NULL) != 1)
  130         result |= 4;
  131     }
  132   if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
  133     {
  134       if (wcrtomb (NULL, 0, NULL) != 1)
  135         result |= 8;
  136     }
  137   return result;
  138 }]])],
  139               [gl_cv_func_wcrtomb_retval=yes],
  140               [gl_cv_func_wcrtomb_retval=no],
  141               [:])
  142           fi
  143         ])
  144       case "$gl_cv_func_wcrtomb_retval" in
  145         *yes) ;;
  146         *) REPLACE_WCRTOMB=1 ;;
  147       esac
  148     fi
  149   fi
  150 ])
  151 
  152 # Prerequisites of lib/wcrtomb.c.
  153 AC_DEFUN([gl_PREREQ_WCRTOMB], [
  154   :
  155 ])