wctype_h.m4 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. # wctype_h.m4 serial 18
  2. dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
  3. dnl Copyright (C) 2006-2013 Free Software Foundation, Inc.
  4. dnl This file is free software; the Free Software Foundation
  5. dnl gives unlimited permission to copy and/or distribute it,
  6. dnl with or without modifications, as long as this notice is preserved.
  7. dnl Written by Paul Eggert.
  8. AC_DEFUN([gl_WCTYPE_H],
  9. [
  10. AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
  11. AC_REQUIRE([AC_PROG_CC])
  12. AC_REQUIRE([AC_CANONICAL_HOST])
  13. AC_CHECK_FUNCS_ONCE([iswcntrl])
  14. if test $ac_cv_func_iswcntrl = yes; then
  15. HAVE_ISWCNTRL=1
  16. else
  17. HAVE_ISWCNTRL=0
  18. fi
  19. AC_SUBST([HAVE_ISWCNTRL])
  20. AC_REQUIRE([gt_TYPE_WINT_T])
  21. if test $gt_cv_c_wint_t = yes; then
  22. HAVE_WINT_T=1
  23. else
  24. HAVE_WINT_T=0
  25. fi
  26. AC_SUBST([HAVE_WINT_T])
  27. gl_CHECK_NEXT_HEADERS([wctype.h])
  28. if test $ac_cv_header_wctype_h = yes; then
  29. if test $ac_cv_func_iswcntrl = yes; then
  30. dnl Linux libc5 has an iswprint function that returns 0 for all arguments.
  31. dnl The other functions are likely broken in the same way.
  32. AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works],
  33. [
  34. AC_RUN_IFELSE(
  35. [AC_LANG_SOURCE([[
  36. /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
  37. included before <wchar.h>.
  38. BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
  39. must be included before <wchar.h>. */
  40. #include <stddef.h>
  41. #include <stdio.h>
  42. #include <time.h>
  43. #include <wchar.h>
  44. #include <wctype.h>
  45. int main () { return iswprint ('x') == 0; }
  46. ]])],
  47. [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
  48. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
  49. #if __GNU_LIBRARY__ == 1
  50. Linux libc5 i18n is broken.
  51. #endif]], [])],
  52. [gl_cv_func_iswcntrl_works="guessing yes"],
  53. [gl_cv_func_iswcntrl_works="guessing no"])
  54. ])
  55. ])
  56. fi
  57. HAVE_WCTYPE_H=1
  58. else
  59. HAVE_WCTYPE_H=0
  60. fi
  61. AC_SUBST([HAVE_WCTYPE_H])
  62. case "$gl_cv_func_iswcntrl_works" in
  63. *yes) REPLACE_ISWCNTRL=0 ;;
  64. *) REPLACE_ISWCNTRL=1 ;;
  65. esac
  66. AC_SUBST([REPLACE_ISWCNTRL])
  67. if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
  68. dnl Redefine all of iswcntrl, ..., iswxdigit in <wctype.h>.
  69. :
  70. fi
  71. if test $REPLACE_ISWCNTRL = 1; then
  72. REPLACE_TOWLOWER=1
  73. else
  74. AC_CHECK_FUNCS([towlower])
  75. if test $ac_cv_func_towlower = yes; then
  76. REPLACE_TOWLOWER=0
  77. else
  78. AC_CHECK_DECLS([towlower],,,
  79. [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
  80. included before <wchar.h>.
  81. BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
  82. must be included before <wchar.h>. */
  83. #include <stddef.h>
  84. #include <stdio.h>
  85. #include <time.h>
  86. #include <wchar.h>
  87. #if HAVE_WCTYPE_H
  88. # include <wctype.h>
  89. #endif
  90. ]])
  91. if test $ac_cv_have_decl_towlower = yes; then
  92. dnl On Minix 3.1.8, the system's <wctype.h> declares towlower() and
  93. dnl towupper() although it does not have the functions. Avoid a
  94. dnl collision with gnulib's replacement.
  95. REPLACE_TOWLOWER=1
  96. else
  97. REPLACE_TOWLOWER=0
  98. fi
  99. fi
  100. fi
  101. AC_SUBST([REPLACE_TOWLOWER])
  102. if test $HAVE_ISWCNTRL = 0 || test $REPLACE_TOWLOWER = 1; then
  103. dnl Redefine towlower, towupper in <wctype.h>.
  104. :
  105. fi
  106. dnl We assume that the wctype() and iswctype() functions exist if and only
  107. dnl if the type wctype_t is defined in <wchar.h> or in <wctype.h> if that
  108. dnl exists.
  109. dnl HP-UX 11.00 declares all these in <wchar.h> and lacks <wctype.h>.
  110. AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t],
  111. [AC_COMPILE_IFELSE(
  112. [AC_LANG_PROGRAM(
  113. [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
  114. included before <wchar.h>.
  115. BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
  116. must be included before <wchar.h>. */
  117. #include <stddef.h>
  118. #include <stdio.h>
  119. #include <time.h>
  120. #include <wchar.h>
  121. #if HAVE_WCTYPE_H
  122. # include <wctype.h>
  123. #endif
  124. wctype_t a;
  125. ]],
  126. [[]])],
  127. [gl_cv_type_wctype_t=yes],
  128. [gl_cv_type_wctype_t=no])
  129. ])
  130. if test $gl_cv_type_wctype_t = no; then
  131. HAVE_WCTYPE_T=0
  132. fi
  133. dnl We assume that the wctrans() and towctrans() functions exist if and only
  134. dnl if the type wctrans_t is defined in <wctype.h>.
  135. AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t],
  136. [AC_COMPILE_IFELSE(
  137. [AC_LANG_PROGRAM(
  138. [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
  139. included before <wchar.h>.
  140. BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
  141. must be included before <wchar.h>. */
  142. #include <stddef.h>
  143. #include <stdio.h>
  144. #include <time.h>
  145. #include <wchar.h>
  146. #include <wctype.h>
  147. wctrans_t a;
  148. ]],
  149. [[]])],
  150. [gl_cv_type_wctrans_t=yes],
  151. [gl_cv_type_wctrans_t=no])
  152. ])
  153. if test $gl_cv_type_wctrans_t = no; then
  154. HAVE_WCTRANS_T=0
  155. fi
  156. dnl Check for declarations of anything we want to poison if the
  157. dnl corresponding gnulib module is not in use.
  158. gl_WARN_ON_USE_PREPARE([[
  159. /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
  160. <wchar.h>.
  161. BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
  162. included before <wchar.h>. */
  163. #if !(defined __GLIBC__ && !defined __UCLIBC__)
  164. # include <stddef.h>
  165. # include <stdio.h>
  166. # include <time.h>
  167. # include <wchar.h>
  168. #endif
  169. #include <wctype.h>
  170. ]],
  171. [wctype iswctype wctrans towctrans
  172. ])
  173. ])
  174. AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR],
  175. [
  176. dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
  177. AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
  178. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  179. dnl Define it also as a C macro, for the benefit of the unit tests.
  180. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  181. ])
  182. AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
  183. [
  184. GNULIB_ISWBLANK=0; AC_SUBST([GNULIB_ISWBLANK])
  185. GNULIB_WCTYPE=0; AC_SUBST([GNULIB_WCTYPE])
  186. GNULIB_ISWCTYPE=0; AC_SUBST([GNULIB_ISWCTYPE])
  187. GNULIB_WCTRANS=0; AC_SUBST([GNULIB_WCTRANS])
  188. GNULIB_TOWCTRANS=0; AC_SUBST([GNULIB_TOWCTRANS])
  189. dnl Assume proper GNU behavior unless another module says otherwise.
  190. HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK])
  191. HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T])
  192. HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T])
  193. REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK])
  194. ])