wctype_h.m4 6.8 KB

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