btowc.m4 2.7 KB

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