Blame m4/wctype_h.m4

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