btowc.m4 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # btowc.m4 serial 12
  2. dnl Copyright (C) 2008-2023 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 <https://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 <wchar.h>
  27. int main ()
  28. {
  29. if (btowc ('\0') != 0)
  30. return 1;
  31. return 0;
  32. }]])],
  33. [gl_cv_func_btowc_nul=yes],
  34. [gl_cv_func_btowc_nul=no],
  35. [
  36. changequote(,)dnl
  37. case "$host_os" in
  38. # Guess no on Cygwin.
  39. cygwin*) gl_cv_func_btowc_nul="guessing no" ;;
  40. # Guess yes on native Windows.
  41. mingw*) gl_cv_func_btowc_nul="guessing yes" ;;
  42. # Guess yes otherwise.
  43. *) gl_cv_func_btowc_nul="guessing yes" ;;
  44. esac
  45. changequote([,])dnl
  46. ])
  47. ])
  48. dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF.
  49. AC_CACHE_CHECK([whether btowc(EOF) is correct],
  50. [gl_cv_func_btowc_eof],
  51. [
  52. dnl Initial guess, used when cross-compiling or when no suitable locale
  53. dnl is present.
  54. changequote(,)dnl
  55. case "$host_os" in
  56. # Guess no on IRIX.
  57. irix*) gl_cv_func_btowc_eof="guessing no" ;;
  58. # Guess yes on native Windows.
  59. mingw*) gl_cv_func_btowc_eof="guessing yes" ;;
  60. # Guess yes otherwise.
  61. *) gl_cv_func_btowc_eof="guessing yes" ;;
  62. esac
  63. changequote([,])dnl
  64. if test $LOCALE_FR != none; then
  65. AC_RUN_IFELSE(
  66. [AC_LANG_SOURCE([[
  67. #include <locale.h>
  68. #include <stdio.h>
  69. #include <wchar.h>
  70. int main ()
  71. {
  72. if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
  73. {
  74. if (btowc (EOF) != WEOF)
  75. return 1;
  76. }
  77. return 0;
  78. }]])],
  79. [gl_cv_func_btowc_eof=yes],
  80. [gl_cv_func_btowc_eof=no],
  81. [:])
  82. fi
  83. ])
  84. case "$gl_cv_func_btowc_nul" in
  85. *yes) ;;
  86. *) REPLACE_BTOWC=1 ;;
  87. esac
  88. case "$gl_cv_func_btowc_eof" in
  89. *yes) ;;
  90. *) REPLACE_BTOWC=1 ;;
  91. esac
  92. fi
  93. ])
  94. # Prerequisites of lib/btowc.c.
  95. AC_DEFUN([gl_PREREQ_BTOWC], [
  96. :
  97. ])