Blame m4/btowc.m4

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