Blame m4/wctype_h.m4

Packit 709fb3
# wctype_h.m4 serial 20
Packit 709fb3
Packit 709fb3
dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
Packit 709fb3
Packit 709fb3
dnl Copyright (C) 2006-2017 Free Software Foundation, Inc.
Packit 709fb3
dnl This file is free software; the Free Software Foundation
Packit 709fb3
dnl gives unlimited permission to copy and/or distribute it,
Packit 709fb3
dnl with or without modifications, as long as this notice is preserved.
Packit 709fb3
Packit 709fb3
dnl Written by Paul Eggert.
Packit 709fb3
Packit 709fb3
AC_DEFUN([gl_WCTYPE_H],
Packit 709fb3
[
Packit 709fb3
  AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
Packit 709fb3
  AC_REQUIRE([AC_PROG_CC])
Packit 709fb3
  AC_REQUIRE([AC_CANONICAL_HOST])
Packit 709fb3
  AC_CHECK_FUNCS_ONCE([iswcntrl])
Packit 709fb3
  if test $ac_cv_func_iswcntrl = yes; then
Packit 709fb3
    HAVE_ISWCNTRL=1
Packit 709fb3
  else
Packit 709fb3
    HAVE_ISWCNTRL=0
Packit 709fb3
  fi
Packit 709fb3
  AC_SUBST([HAVE_ISWCNTRL])
Packit 709fb3
Packit 709fb3
  AC_REQUIRE([gt_TYPE_WINT_T])
Packit 709fb3
  if test $gt_cv_c_wint_t = yes; then
Packit 709fb3
    HAVE_WINT_T=1
Packit 709fb3
  else
Packit 709fb3
    HAVE_WINT_T=0
Packit 709fb3
  fi
Packit 709fb3
  AC_SUBST([HAVE_WINT_T])
Packit 709fb3
Packit 709fb3
  AC_REQUIRE([gl_TYPE_WINT_T_PREREQ])
Packit 709fb3
Packit 709fb3
  gl_CHECK_NEXT_HEADERS([wctype.h])
Packit 709fb3
  if test $ac_cv_header_wctype_h = yes; then
Packit 709fb3
    if test $ac_cv_func_iswcntrl = yes; then
Packit 709fb3
      dnl Linux libc5 has an iswprint function that returns 0 for all arguments.
Packit 709fb3
      dnl The other functions are likely broken in the same way.
Packit 709fb3
      AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works],
Packit 709fb3
        [
Packit 709fb3
          AC_RUN_IFELSE(
Packit 709fb3
            [AC_LANG_SOURCE([[
Packit 709fb3
               /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
Packit 709fb3
                  included before <wchar.h>.
Packit 709fb3
                  BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
Packit 709fb3
                  must be included before <wchar.h>.  */
Packit 709fb3
               #include <stddef.h>
Packit 709fb3
               #include <stdio.h>
Packit 709fb3
               #include <time.h>
Packit 709fb3
               #include <wchar.h>
Packit 709fb3
               #include <wctype.h>
Packit 709fb3
               int main () { return iswprint ('x') == 0; }
Packit 709fb3
            ]])],
Packit 709fb3
            [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
Packit 709fb3
            [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
Packit 709fb3
                          #if __GNU_LIBRARY__ == 1
Packit 709fb3
                          Linux libc5 i18n is broken.
Packit 709fb3
                          #endif]], [])],
Packit 709fb3
              [gl_cv_func_iswcntrl_works="guessing yes"],
Packit 709fb3
              [gl_cv_func_iswcntrl_works="guessing no"])
Packit 709fb3
            ])
Packit 709fb3
        ])
Packit 709fb3
    fi
Packit 709fb3
    HAVE_WCTYPE_H=1
Packit 709fb3
  else
Packit 709fb3
    HAVE_WCTYPE_H=0
Packit 709fb3
  fi
Packit 709fb3
  AC_SUBST([HAVE_WCTYPE_H])
Packit 709fb3
Packit 709fb3
  case "$gl_cv_func_iswcntrl_works" in
Packit 709fb3
    *yes) REPLACE_ISWCNTRL=0 ;;
Packit 709fb3
    *)    REPLACE_ISWCNTRL=1 ;;
Packit 709fb3
  esac
Packit 709fb3
  AC_SUBST([REPLACE_ISWCNTRL])
Packit 709fb3
Packit 709fb3
  if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
Packit 709fb3
    dnl Redefine all of iswcntrl, ..., iswxdigit in <wctype.h>.
Packit 709fb3
    :
Packit 709fb3
  fi
Packit 709fb3
Packit 709fb3
  if test $REPLACE_ISWCNTRL = 1; then
Packit 709fb3
    REPLACE_TOWLOWER=1
Packit 709fb3
  else
Packit 709fb3
    AC_CHECK_FUNCS([towlower])
Packit 709fb3
    if test $ac_cv_func_towlower = yes; then
Packit 709fb3
      REPLACE_TOWLOWER=0
Packit 709fb3
    else
Packit 709fb3
      AC_CHECK_DECLS([towlower],,,
Packit 709fb3
        [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
Packit 709fb3
             included before <wchar.h>.
Packit 709fb3
             BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
Packit 709fb3
             must be included before <wchar.h>.  */
Packit 709fb3
          #include <stddef.h>
Packit 709fb3
          #include <stdio.h>
Packit 709fb3
          #include <time.h>
Packit 709fb3
          #include <wchar.h>
Packit 709fb3
          #if HAVE_WCTYPE_H
Packit 709fb3
          # include <wctype.h>
Packit 709fb3
          #endif
Packit 709fb3
        ]])
Packit 709fb3
      if test $ac_cv_have_decl_towlower = yes; then
Packit 709fb3
        dnl On Minix 3.1.8, the system's <wctype.h> declares towlower() and
Packit 709fb3
        dnl towupper() although it does not have the functions. Avoid a
Packit 709fb3
        dnl collision with gnulib's replacement.
Packit 709fb3
        REPLACE_TOWLOWER=1
Packit 709fb3
      else
Packit 709fb3
        REPLACE_TOWLOWER=0
Packit 709fb3
      fi
Packit 709fb3
    fi
Packit 709fb3
  fi
Packit 709fb3
  AC_SUBST([REPLACE_TOWLOWER])
Packit 709fb3
Packit 709fb3
  if test $HAVE_ISWCNTRL = 0 || test $REPLACE_TOWLOWER = 1; then
Packit 709fb3
    dnl Redefine towlower, towupper in <wctype.h>.
Packit 709fb3
    :
Packit 709fb3
  fi
Packit 709fb3
Packit 709fb3
  dnl We assume that the wctype() and iswctype() functions exist if and only
Packit 709fb3
  dnl if the type wctype_t is defined in <wchar.h> or in <wctype.h> if that
Packit 709fb3
  dnl exists.
Packit 709fb3
  dnl HP-UX 11.00 declares all these in <wchar.h> and lacks <wctype.h>.
Packit 709fb3
  AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t],
Packit 709fb3
    [AC_COMPILE_IFELSE(
Packit 709fb3
       [AC_LANG_PROGRAM(
Packit 709fb3
          [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
Packit 709fb3
               included before <wchar.h>.
Packit 709fb3
               BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
Packit 709fb3
               must be included before <wchar.h>.  */
Packit 709fb3
            #include <stddef.h>
Packit 709fb3
            #include <stdio.h>
Packit 709fb3
            #include <time.h>
Packit 709fb3
            #include <wchar.h>
Packit 709fb3
            #if HAVE_WCTYPE_H
Packit 709fb3
            # include <wctype.h>
Packit 709fb3
            #endif
Packit 709fb3
            wctype_t a;
Packit 709fb3
          ]],
Packit 709fb3
          [[]])],
Packit 709fb3
       [gl_cv_type_wctype_t=yes],
Packit 709fb3
       [gl_cv_type_wctype_t=no])
Packit 709fb3
    ])
Packit 709fb3
  if test $gl_cv_type_wctype_t = no; then
Packit 709fb3
    HAVE_WCTYPE_T=0
Packit 709fb3
  fi
Packit 709fb3
Packit 709fb3
  dnl We assume that the wctrans() and towctrans() functions exist if and only
Packit 709fb3
  dnl if the type wctrans_t is defined in <wctype.h>.
Packit 709fb3
  AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t],
Packit 709fb3
    [AC_COMPILE_IFELSE(
Packit 709fb3
       [AC_LANG_PROGRAM(
Packit 709fb3
          [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
Packit 709fb3
               included before <wchar.h>.
Packit 709fb3
               BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
Packit 709fb3
               must be included before <wchar.h>.  */
Packit 709fb3
            #include <stddef.h>
Packit 709fb3
            #include <stdio.h>
Packit 709fb3
            #include <time.h>
Packit 709fb3
            #include <wchar.h>
Packit 709fb3
            #include <wctype.h>
Packit 709fb3
            wctrans_t a;
Packit 709fb3
          ]],
Packit 709fb3
          [[]])],
Packit 709fb3
       [gl_cv_type_wctrans_t=yes],
Packit 709fb3
       [gl_cv_type_wctrans_t=no])
Packit 709fb3
    ])
Packit 709fb3
  if test $gl_cv_type_wctrans_t = no; then
Packit 709fb3
    HAVE_WCTRANS_T=0
Packit 709fb3
  fi
Packit 709fb3
Packit 709fb3
  dnl Check for declarations of anything we want to poison if the
Packit 709fb3
  dnl corresponding gnulib module is not in use.
Packit 709fb3
  gl_WARN_ON_USE_PREPARE([[
Packit 709fb3
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
Packit 709fb3
   <wchar.h>.
Packit 709fb3
   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
Packit 709fb3
   included before <wchar.h>.  */
Packit 709fb3
#if !(defined __GLIBC__ && !defined __UCLIBC__)
Packit 709fb3
# include <stddef.h>
Packit 709fb3
# include <stdio.h>
Packit 709fb3
# include <time.h>
Packit 709fb3
# include <wchar.h>
Packit 709fb3
#endif
Packit 709fb3
#include <wctype.h>
Packit 709fb3
    ]],
Packit 709fb3
    [wctype iswctype wctrans towctrans
Packit 709fb3
    ])
Packit 709fb3
])
Packit 709fb3
Packit 709fb3
AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR],
Packit 709fb3
[
Packit 709fb3
  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
Packit 709fb3
  AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
Packit 709fb3
  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
Packit 709fb3
  dnl Define it also as a C macro, for the benefit of the unit tests.
Packit 709fb3
  gl_MODULE_INDICATOR_FOR_TESTS([$1])
Packit 709fb3
])
Packit 709fb3
Packit 709fb3
AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
Packit 709fb3
[
Packit 709fb3
  GNULIB_ISWBLANK=0;    AC_SUBST([GNULIB_ISWBLANK])
Packit 709fb3
  GNULIB_WCTYPE=0;      AC_SUBST([GNULIB_WCTYPE])
Packit 709fb3
  GNULIB_ISWCTYPE=0;    AC_SUBST([GNULIB_ISWCTYPE])
Packit 709fb3
  GNULIB_WCTRANS=0;     AC_SUBST([GNULIB_WCTRANS])
Packit 709fb3
  GNULIB_TOWCTRANS=0;   AC_SUBST([GNULIB_TOWCTRANS])
Packit 709fb3
  dnl Assume proper GNU behavior unless another module says otherwise.
Packit 709fb3
  HAVE_ISWBLANK=1;      AC_SUBST([HAVE_ISWBLANK])
Packit 709fb3
  HAVE_WCTYPE_T=1;      AC_SUBST([HAVE_WCTYPE_T])
Packit 709fb3
  HAVE_WCTRANS_T=1;     AC_SUBST([HAVE_WCTRANS_T])
Packit 709fb3
  REPLACE_ISWBLANK=0;   AC_SUBST([REPLACE_ISWBLANK])
Packit 709fb3
])