wcrtomb.m4 2.7 KB

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