Blame m4/wctype_h.m4

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