btowc.m4 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # btowc.m4 serial 10
  2. dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. AC_DEFUN([gl_FUNC_BTOWC],
  7. [
  8. AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
  9. dnl Check whether <wchar.h> is usable at all, first. Otherwise the test
  10. dnl program below may lead to an endless loop. See
  11. dnl <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>.
  12. AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
  13. AC_CHECK_FUNCS_ONCE([btowc])
  14. if test $ac_cv_func_btowc = no; then
  15. HAVE_BTOWC=0
  16. else
  17. AC_REQUIRE([AC_PROG_CC])
  18. AC_REQUIRE([gt_LOCALE_FR])
  19. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  20. dnl Cygwin 1.7.2 btowc('\0') is WEOF, not 0.
  21. AC_CACHE_CHECK([whether btowc(0) is correct],
  22. [gl_cv_func_btowc_nul],
  23. [
  24. AC_RUN_IFELSE(
  25. [AC_LANG_SOURCE([[
  26. #include <string.h>
  27. /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
  28. <wchar.h>.
  29. BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
  30. included before <wchar.h>. */
  31. #include <stddef.h>
  32. #include <stdio.h>
  33. #include <time.h>
  34. #include <wchar.h>
  35. int main ()
  36. {
  37. if (btowc ('\0') != 0)
  38. return 1;
  39. return 0;
  40. }]])],
  41. [gl_cv_func_btowc_nul=yes],
  42. [gl_cv_func_btowc_nul=no],
  43. [
  44. changequote(,)dnl
  45. case "$host_os" in
  46. # Guess no on Cygwin.
  47. cygwin*) gl_cv_func_btowc_nul="guessing no" ;;
  48. # Guess yes otherwise.
  49. *) gl_cv_func_btowc_nul="guessing yes" ;;
  50. esac
  51. changequote([,])dnl
  52. ])
  53. ])
  54. dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF.
  55. AC_CACHE_CHECK([whether btowc(EOF) is correct],
  56. [gl_cv_func_btowc_eof],
  57. [
  58. dnl Initial guess, used when cross-compiling or when no suitable locale
  59. dnl is present.
  60. changequote(,)dnl
  61. case "$host_os" in
  62. # Guess no on IRIX.
  63. irix*) gl_cv_func_btowc_eof="guessing no" ;;
  64. # Guess yes otherwise.
  65. *) gl_cv_func_btowc_eof="guessing yes" ;;
  66. esac
  67. changequote([,])dnl
  68. if test $LOCALE_FR != none; then
  69. AC_RUN_IFELSE(
  70. [AC_LANG_SOURCE([[
  71. #include <locale.h>
  72. #include <string.h>
  73. /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
  74. <wchar.h>.
  75. BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
  76. included before <wchar.h>. */
  77. #include <stddef.h>
  78. #include <stdio.h>
  79. #include <time.h>
  80. #include <wchar.h>
  81. int main ()
  82. {
  83. if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
  84. {
  85. if (btowc (EOF) != WEOF)
  86. return 1;
  87. }
  88. return 0;
  89. }]])],
  90. [gl_cv_func_btowc_eof=yes],
  91. [gl_cv_func_btowc_eof=no],
  92. [:])
  93. fi
  94. ])
  95. case "$gl_cv_func_btowc_nul" in
  96. *yes) ;;
  97. *) REPLACE_BTOWC=1 ;;
  98. esac
  99. case "$gl_cv_func_btowc_eof" in
  100. *yes) ;;
  101. *) REPLACE_BTOWC=1 ;;
  102. esac
  103. fi
  104. ])
  105. # Prerequisites of lib/btowc.c.
  106. AC_DEFUN([gl_PREREQ_BTOWC], [
  107. :
  108. ])