Blame m4/btowc.m4

Packit Service a2489d
# btowc.m4 serial 11
Packit Service a2489d
dnl Copyright (C) 2008-2018 Free Software Foundation, Inc.
Packit Service a2489d
dnl This file is free software; the Free Software Foundation
Packit Service a2489d
dnl gives unlimited permission to copy and/or distribute it,
Packit Service a2489d
dnl with or without modifications, as long as this notice is preserved.
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_FUNC_BTOWC],
Packit Service a2489d
[
Packit Service a2489d
  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
Packit Service a2489d
Packit Service a2489d
  dnl Check whether <wchar.h> is usable at all, first. Otherwise the test
Packit Service a2489d
  dnl program below may lead to an endless loop. See
Packit Service a2489d
  dnl <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>.
Packit Service a2489d
  AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
Packit Service a2489d
Packit Service a2489d
  AC_CHECK_FUNCS_ONCE([btowc])
Packit Service a2489d
  if test $ac_cv_func_btowc = no; then
Packit Service a2489d
    HAVE_BTOWC=0
Packit Service a2489d
  else
Packit Service a2489d
Packit Service a2489d
    AC_REQUIRE([AC_PROG_CC])
Packit Service a2489d
    AC_REQUIRE([gt_LOCALE_FR])
Packit Service a2489d
    AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit Service a2489d
Packit Service a2489d
    dnl Cygwin 1.7.2 btowc('\0') is WEOF, not 0.
Packit Service a2489d
    AC_CACHE_CHECK([whether btowc(0) is correct],
Packit Service a2489d
      [gl_cv_func_btowc_nul],
Packit Service a2489d
      [
Packit Service a2489d
        AC_RUN_IFELSE(
Packit Service a2489d
          [AC_LANG_SOURCE([[
Packit Service a2489d
#include <string.h>
Packit Service a2489d
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
Packit Service a2489d
   <wchar.h>.
Packit Service a2489d
   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
Packit Service a2489d
   included before <wchar.h>.  */
Packit Service a2489d
#include <stddef.h>
Packit Service a2489d
#include <stdio.h>
Packit Service a2489d
#include <time.h>
Packit Service a2489d
#include <wchar.h>
Packit Service a2489d
int main ()
Packit Service a2489d
{
Packit Service a2489d
  if (btowc ('\0') != 0)
Packit Service a2489d
    return 1;
Packit Service a2489d
  return 0;
Packit Service a2489d
}]])],
Packit Service a2489d
          [gl_cv_func_btowc_nul=yes],
Packit Service a2489d
          [gl_cv_func_btowc_nul=no],
Packit Service a2489d
          [
Packit Service a2489d
changequote(,)dnl
Packit Service a2489d
           case "$host_os" in
Packit Service a2489d
                      # Guess no on Cygwin.
Packit Service a2489d
             cygwin*) gl_cv_func_btowc_nul="guessing no" ;;
Packit Service a2489d
                      # Guess yes on native Windows.
Packit Service a2489d
             mingw*)  gl_cv_func_btowc_nul="guessing yes" ;;
Packit Service a2489d
                      # Guess yes otherwise.
Packit Service a2489d
             *)       gl_cv_func_btowc_nul="guessing yes" ;;
Packit Service a2489d
           esac
Packit Service a2489d
changequote([,])dnl
Packit Service a2489d
          ])
Packit Service a2489d
      ])
Packit Service a2489d
Packit Service a2489d
    dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF.
Packit Service a2489d
    AC_CACHE_CHECK([whether btowc(EOF) is correct],
Packit Service a2489d
      [gl_cv_func_btowc_eof],
Packit Service a2489d
      [
Packit Service a2489d
        dnl Initial guess, used when cross-compiling or when no suitable locale
Packit Service a2489d
        dnl is present.
Packit Service a2489d
changequote(,)dnl
Packit Service a2489d
        case "$host_os" in
Packit Service a2489d
                  # Guess no on IRIX.
Packit Service a2489d
          irix*)  gl_cv_func_btowc_eof="guessing no" ;;
Packit Service a2489d
                  # Guess yes on native Windows.
Packit Service a2489d
          mingw*) gl_cv_func_btowc_eof="guessing yes" ;;
Packit Service a2489d
                  # Guess yes otherwise.
Packit Service a2489d
          *)      gl_cv_func_btowc_eof="guessing yes" ;;
Packit Service a2489d
        esac
Packit Service a2489d
changequote([,])dnl
Packit Service a2489d
        if test $LOCALE_FR != none; then
Packit Service a2489d
          AC_RUN_IFELSE(
Packit Service a2489d
            [AC_LANG_SOURCE([[
Packit Service a2489d
#include <locale.h>
Packit Service a2489d
#include <string.h>
Packit Service a2489d
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
Packit Service a2489d
   <wchar.h>.
Packit Service a2489d
   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
Packit Service a2489d
   included before <wchar.h>.  */
Packit Service a2489d
#include <stddef.h>
Packit Service a2489d
#include <stdio.h>
Packit Service a2489d
#include <time.h>
Packit Service a2489d
#include <wchar.h>
Packit Service a2489d
int main ()
Packit Service a2489d
{
Packit Service a2489d
  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
Packit Service a2489d
    {
Packit Service a2489d
      if (btowc (EOF) != WEOF)
Packit Service a2489d
        return 1;
Packit Service a2489d
    }
Packit Service a2489d
  return 0;
Packit Service a2489d
}]])],
Packit Service a2489d
            [gl_cv_func_btowc_eof=yes],
Packit Service a2489d
            [gl_cv_func_btowc_eof=no],
Packit Service a2489d
            [:])
Packit Service a2489d
        fi
Packit Service a2489d
      ])
Packit Service a2489d
Packit Service a2489d
    case "$gl_cv_func_btowc_nul" in
Packit Service a2489d
      *yes) ;;
Packit Service a2489d
      *) REPLACE_BTOWC=1 ;;
Packit Service a2489d
    esac
Packit Service a2489d
    case "$gl_cv_func_btowc_eof" in
Packit Service a2489d
      *yes) ;;
Packit Service a2489d
      *) REPLACE_BTOWC=1 ;;
Packit Service a2489d
    esac
Packit Service a2489d
  fi
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
# Prerequisites of lib/btowc.c.
Packit Service a2489d
AC_DEFUN([gl_PREREQ_BTOWC], [
Packit Service a2489d
  :
Packit Service a2489d
])