wcrtomb.m4 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # wcrtomb.m4 serial 2
  2. dnl Copyright (C) 2008 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_WCRTOMB],
  7. [
  8. AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
  9. AC_REQUIRE([AC_TYPE_MBSTATE_T])
  10. AC_CHECK_FUNCS_ONCE([wcrtomb])
  11. if test $ac_cv_func_wcrtomb = no; then
  12. HAVE_WCRTOMB=0
  13. else
  14. dnl On OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL) sometimes
  15. dnl returns 0 instead of 1.
  16. AC_REQUIRE([AC_PROG_CC])
  17. AC_REQUIRE([gt_LOCALE_FR])
  18. AC_REQUIRE([gt_LOCALE_FR_UTF8])
  19. AC_REQUIRE([gt_LOCALE_JA])
  20. AC_REQUIRE([gt_LOCALE_ZH_CN])
  21. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  22. AC_CACHE_CHECK([whether wcrtomb return value is correct],
  23. [gl_cv_func_wcrtomb_retval],
  24. [
  25. dnl Initial guess, used when cross-compiling or when no suitable locale
  26. dnl is present.
  27. changequote(,)dnl
  28. case "$host_os" in
  29. # Guess no on OSF/1 and Solaris.
  30. osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;;
  31. # Guess yes otherwise.
  32. *) gl_cv_func_wcrtomb_retval="guessing yes" ;;
  33. esac
  34. changequote([,])dnl
  35. if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
  36. AC_TRY_RUN([
  37. #include <locale.h>
  38. #include <stdio.h>
  39. #include <string.h>
  40. #include <wchar.h>
  41. int main ()
  42. {
  43. if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
  44. {
  45. if (wcrtomb (NULL, 0, NULL) != 1)
  46. return 1;
  47. }
  48. if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
  49. {
  50. if (wcrtomb (NULL, 0, NULL) != 1)
  51. return 1;
  52. }
  53. if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
  54. {
  55. if (wcrtomb (NULL, 0, NULL) != 1)
  56. return 1;
  57. }
  58. if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
  59. {
  60. if (wcrtomb (NULL, 0, NULL) != 1)
  61. return 1;
  62. }
  63. return 0;
  64. }],
  65. [gl_cv_func_wcrtomb_retval=yes],
  66. [gl_cv_func_wcrtomb_retval=no],
  67. [])
  68. fi
  69. ])
  70. case "$gl_cv_func_wcrtomb_retval" in
  71. *yes) ;;
  72. *) REPLACE_WCRTOMB=1 ;;
  73. esac
  74. fi
  75. if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then
  76. gl_REPLACE_WCHAR_H
  77. AC_LIBOBJ([wcrtomb])
  78. gl_PREREQ_WCRTOMB
  79. fi
  80. ])
  81. # Prerequisites of lib/wcrtomb.c.
  82. AC_DEFUN([gl_PREREQ_WCRTOMB], [
  83. :
  84. ])