Blame gettext-runtime/gnulib-m4/wctype_h.m4

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