Blame m4/wctob.m4

Packit Service fdd496
# wctob.m4 serial 10
Packit Service fdd496
dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
Packit Service fdd496
dnl This file is free software; the Free Software Foundation
Packit Service fdd496
dnl gives unlimited permission to copy and/or distribute it,
Packit Service fdd496
dnl with or without modifications, as long as this notice is preserved.
Packit Service fdd496
Packit Service fdd496
AC_DEFUN([gl_FUNC_WCTOB],
Packit Service fdd496
[
Packit Service fdd496
  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
Packit Service fdd496
Packit Service fdd496
  AC_CHECK_FUNCS_ONCE([wctob])
Packit Service fdd496
  if test $ac_cv_func_wctob = no; then
Packit Service fdd496
    HAVE_WCTOB=0
Packit Service fdd496
    HAVE_DECL_WCTOB=0
Packit Service fdd496
  else
Packit Service fdd496
    HAVE_WCTOB=1
Packit Service fdd496
Packit Service fdd496
    dnl Solaris 9 has the wctob() function but it does not work.
Packit Service fdd496
    dnl Cygwin 1.7.2 has the wctob() function but it clobbers caller-owned
Packit Service fdd496
    dnl registers, see <http://cygwin.com/ml/cygwin/2010-05/msg00015.html>.
Packit Service fdd496
    AC_REQUIRE([AC_PROG_CC])
Packit Service fdd496
    AC_REQUIRE([gt_LOCALE_FR])
Packit Service fdd496
    AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit Service fdd496
    AC_CACHE_CHECK([whether wctob works],
Packit Service fdd496
      [gl_cv_func_wctob_works],
Packit Service fdd496
      [
Packit Service fdd496
        dnl Initial guess, used when cross-compiling or when no suitable locale
Packit Service fdd496
        dnl is present.
Packit Service fdd496
changequote(,)dnl
Packit Service fdd496
        case "$host_os" in
Packit Service fdd496
            # Guess no on Solaris <= 9 and Cygwin.
Packit Service fdd496
          solaris2.[1-9] | solaris2.[1-9].* | cygwin*)
Packit Service fdd496
            gl_cv_func_wctob_works="guessing no" ;;
Packit Service fdd496
            # Guess yes otherwise.
Packit Service fdd496
          *) gl_cv_func_wctob_works="guessing yes" ;;
Packit Service fdd496
        esac
Packit Service fdd496
changequote([,])dnl
Packit Service fdd496
        case "$host_os" in
Packit Service fdd496
          cygwin*)
Packit Service fdd496
            AC_RUN_IFELSE(
Packit Service fdd496
              [AC_LANG_SOURCE([[
Packit Service fdd496
#include <locale.h>
Packit Service fdd496
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
Packit Service fdd496
   <wchar.h>.
Packit Service fdd496
   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
Packit Service fdd496
   included before <wchar.h>.  */
Packit Service fdd496
#include <stddef.h>
Packit Service fdd496
#include <stdio.h>
Packit Service fdd496
#include <time.h>
Packit Service fdd496
#include <wchar.h>
Packit Service fdd496
Packit Service fdd496
register long global __asm__ ("%ebx");
Packit Service fdd496
Packit Service fdd496
int main ()
Packit Service fdd496
{
Packit Service fdd496
  setlocale (LC_ALL, "en_US.UTF-8");
Packit Service fdd496
Packit Service fdd496
  global = 0x12345678;
Packit Service fdd496
  if (wctob (0x00FC) != -1)
Packit Service fdd496
    return 1;
Packit Service fdd496
  if (global != 0x12345678)
Packit Service fdd496
    return 2;
Packit Service fdd496
  return 0;
Packit Service fdd496
}]])],
Packit Service fdd496
              [:],
Packit Service fdd496
              [gl_cv_func_wctob_works=no],
Packit Service fdd496
              [:])
Packit Service fdd496
            ;;
Packit Service fdd496
        esac
Packit Service fdd496
        if test "$gl_cv_func_wctob_works" != no && test $LOCALE_FR != none; then
Packit Service fdd496
          AC_RUN_IFELSE(
Packit Service fdd496
            [AC_LANG_SOURCE([[
Packit Service fdd496
#include <locale.h>
Packit Service fdd496
#include <string.h>
Packit Service fdd496
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
Packit Service fdd496
   <wchar.h>.
Packit Service fdd496
   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
Packit Service fdd496
   included before <wchar.h>.  */
Packit Service fdd496
#include <stddef.h>
Packit Service fdd496
#include <stdio.h>
Packit Service fdd496
#include <time.h>
Packit Service fdd496
#include <wchar.h>
Packit Service fdd496
int main ()
Packit Service fdd496
{
Packit Service fdd496
  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
Packit Service fdd496
    {
Packit Service fdd496
      wchar_t wc;
Packit Service fdd496
Packit Service fdd496
      if (mbtowc (&wc, "\374", 1) == 1)
Packit Service fdd496
        if (wctob (wc) != (unsigned char) '\374')
Packit Service fdd496
          return 1;
Packit Service fdd496
    }
Packit Service fdd496
  return 0;
Packit Service fdd496
}]])],
Packit Service fdd496
            [gl_cv_func_wctob_works=yes],
Packit Service fdd496
            [gl_cv_func_wctob_works=no],
Packit Service fdd496
            [:])
Packit Service fdd496
        fi
Packit Service fdd496
      ])
Packit Service fdd496
    case "$gl_cv_func_wctob_works" in
Packit Service fdd496
      *yes) ;;
Packit Service fdd496
      *) REPLACE_WCTOB=1 ;;
Packit Service fdd496
    esac
Packit Service fdd496
    if test $REPLACE_WCTOB = 0; then
Packit Service fdd496
Packit Service fdd496
      dnl IRIX 6.5 has the wctob() function but does not declare it.
Packit Service fdd496
      AC_CHECK_DECLS([wctob], [], [], [[
Packit Service fdd496
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
Packit Service fdd496
   <wchar.h>.
Packit Service fdd496
   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
Packit Service fdd496
   before <wchar.h>.  */
Packit Service fdd496
#include <stddef.h>
Packit Service fdd496
#include <stdio.h>
Packit Service fdd496
#include <time.h>
Packit Service fdd496
#include <wchar.h>
Packit Service fdd496
]])
Packit Service fdd496
      if test $ac_cv_have_decl_wctob != yes; then
Packit Service fdd496
        HAVE_DECL_WCTOB=0
Packit Service fdd496
      fi
Packit Service fdd496
    fi
Packit Service fdd496
  fi
Packit Service fdd496
])
Packit Service fdd496
Packit Service fdd496
# Prerequisites of lib/wctob.c.
Packit Service fdd496
AC_DEFUN([gl_PREREQ_WCTOB], [
Packit Service fdd496
  :
Packit Service fdd496
])