btowc.m4 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # btowc.m4 serial 4
  2. dnl Copyright (C) 2008-2009 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. AC_CHECK_FUNCS_ONCE([btowc])
  10. if test $ac_cv_func_btowc = no; then
  11. HAVE_BTOWC=0
  12. else
  13. dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF.
  14. AC_REQUIRE([AC_PROG_CC])
  15. AC_REQUIRE([gt_LOCALE_FR])
  16. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  17. AC_CACHE_CHECK([whether btowc(EOF) is correct],
  18. [gl_cv_func_btowc_eof],
  19. [
  20. dnl Initial guess, used when cross-compiling or when no suitable locale
  21. dnl is present.
  22. changequote(,)dnl
  23. case "$host_os" in
  24. # Guess no on IRIX.
  25. irix*) gl_cv_func_btowc_eof="guessing no" ;;
  26. # Guess yes otherwise.
  27. *) gl_cv_func_btowc_eof="guessing yes" ;;
  28. esac
  29. changequote([,])dnl
  30. if test $LOCALE_FR != none; then
  31. AC_TRY_RUN([
  32. #include <locale.h>
  33. #include <stdio.h>
  34. #include <string.h>
  35. #include <wchar.h>
  36. int main ()
  37. {
  38. if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
  39. {
  40. if (btowc (EOF) != WEOF)
  41. return 1;
  42. }
  43. return 0;
  44. }],
  45. [gl_cv_func_btowc_eof=yes],
  46. [gl_cv_func_btowc_eof=no],
  47. [:])
  48. fi
  49. ])
  50. case "$gl_cv_func_btowc_eof" in
  51. *yes) ;;
  52. *) REPLACE_BTOWC=1 ;;
  53. esac
  54. fi
  55. if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then
  56. gl_REPLACE_WCHAR_H
  57. AC_LIBOBJ([btowc])
  58. gl_PREREQ_BTOWC
  59. fi
  60. ])
  61. # Prerequisites of lib/btowc.c.
  62. AC_DEFUN([gl_PREREQ_BTOWC], [
  63. :
  64. ])