Blame m4/wint_t.m4

Packit 8f70b4
# wint_t.m4 serial 7
Packit 8f70b4
dnl Copyright (C) 2003, 2007-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
dnl From Bruno Haible.
Packit 8f70b4
dnl Test whether <wchar.h> has the 'wint_t' type and whether gnulib's
Packit 8f70b4
dnl <wchar.h> or <wctype.h> would, if present, override 'wint_t'.
Packit 8f70b4
dnl Prerequisite: AC_PROG_CC
Packit 8f70b4
Packit 8f70b4
AC_DEFUN([gt_TYPE_WINT_T],
Packit 8f70b4
[
Packit 8f70b4
  AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t],
Packit 8f70b4
    [AC_COMPILE_IFELSE(
Packit 8f70b4
       [AC_LANG_PROGRAM(
Packit 8f70b4
          [[
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 included
Packit 8f70b4
   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
            wint_t foo = (wchar_t)'\0';]],
Packit 8f70b4
          [[]])],
Packit 8f70b4
       [gt_cv_c_wint_t=yes],
Packit 8f70b4
       [gt_cv_c_wint_t=no])])
Packit 8f70b4
  if test $gt_cv_c_wint_t = yes; then
Packit 8f70b4
    AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.])
Packit 8f70b4
Packit 8f70b4
    dnl Determine whether gnulib's <wchar.h> or <wctype.h> would, if present,
Packit 8f70b4
    dnl override 'wint_t'.
Packit 8f70b4
    AC_CACHE_CHECK([whether wint_t is too small],
Packit 8f70b4
      [gl_cv_type_wint_t_too_small],
Packit 8f70b4
      [AC_COMPILE_IFELSE(
Packit 8f70b4
           [AC_LANG_PROGRAM([[
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
#if !(defined __GLIBC__ && !defined __UCLIBC__)
Packit 8f70b4
# include <stddef.h>
Packit 8f70b4
# include <stdio.h>
Packit 8f70b4
# include <time.h>
Packit 8f70b4
#endif
Packit 8f70b4
#include <wchar.h>
Packit 8f70b4
              int verify[sizeof (wint_t) < sizeof (int) ? -1 : 1];
Packit 8f70b4
              ]])],
Packit 8f70b4
           [gl_cv_type_wint_t_too_small=no],
Packit 8f70b4
           [gl_cv_type_wint_t_too_small=yes])])
Packit 8f70b4
    if test $gl_cv_type_wint_t_too_small = yes; then
Packit 8f70b4
      GNULIB_OVERRIDES_WINT_T=1
Packit 8f70b4
    else
Packit 8f70b4
      GNULIB_OVERRIDES_WINT_T=0
Packit 8f70b4
    fi
Packit 8f70b4
  else
Packit 8f70b4
    GNULIB_OVERRIDES_WINT_T=0
Packit 8f70b4
  fi
Packit 8f70b4
  AC_SUBST([GNULIB_OVERRIDES_WINT_T])
Packit 8f70b4
])
Packit 8f70b4
Packit 8f70b4
dnl Prerequisites of the 'wint_t' override.
Packit 8f70b4
AC_DEFUN([gl_TYPE_WINT_T_PREREQ],
Packit 8f70b4
[
Packit 8f70b4
  AC_CHECK_HEADERS_ONCE([crtdefs.h])
Packit 8f70b4
  if test $ac_cv_header_crtdefs_h = yes; then
Packit 8f70b4
    HAVE_CRTDEFS_H=1
Packit 8f70b4
  else
Packit 8f70b4
    HAVE_CRTDEFS_H=0
Packit 8f70b4
  fi
Packit 8f70b4
  AC_SUBST([HAVE_CRTDEFS_H])
Packit 8f70b4
])