wcrtomb.m4 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # wcrtomb.m4 serial 11
  2. dnl Copyright (C) 2008-2017 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. AC_CHECK_DECLS([wcrtomb],,, [[
  15. /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
  16. <wchar.h>.
  17. BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
  18. included before <wchar.h>. */
  19. #include <stddef.h>
  20. #include <stdio.h>
  21. #include <time.h>
  22. #include <wchar.h>
  23. ]])
  24. if test $ac_cv_have_decl_wcrtomb = yes; then
  25. dnl On Minix 3.1.8, the system's <wchar.h> declares wcrtomb() although
  26. dnl it does not have the function. Avoid a collision with gnulib's
  27. dnl replacement.
  28. REPLACE_WCRTOMB=1
  29. fi
  30. else
  31. if test $REPLACE_MBSTATE_T = 1; then
  32. REPLACE_WCRTOMB=1
  33. else
  34. dnl On AIX 4.3, OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL) sometimes
  35. dnl returns 0 instead of 1.
  36. AC_REQUIRE([AC_PROG_CC])
  37. AC_REQUIRE([gt_LOCALE_FR])
  38. AC_REQUIRE([gt_LOCALE_FR_UTF8])
  39. AC_REQUIRE([gt_LOCALE_JA])
  40. AC_REQUIRE([gt_LOCALE_ZH_CN])
  41. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  42. AC_CACHE_CHECK([whether wcrtomb return value is correct],
  43. [gl_cv_func_wcrtomb_retval],
  44. [
  45. dnl Initial guess, used when cross-compiling or when no suitable locale
  46. dnl is present.
  47. changequote(,)dnl
  48. case "$host_os" in
  49. # Guess no on AIX 4, OSF/1 and Solaris.
  50. aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;;
  51. # Guess yes otherwise.
  52. *) gl_cv_func_wcrtomb_retval="guessing yes" ;;
  53. esac
  54. changequote([,])dnl
  55. if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
  56. AC_RUN_IFELSE(
  57. [AC_LANG_SOURCE([[
  58. #include <locale.h>
  59. #include <string.h>
  60. /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
  61. <wchar.h>.
  62. BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
  63. included before <wchar.h>. */
  64. #include <stddef.h>
  65. #include <stdio.h>
  66. #include <time.h>
  67. #include <wchar.h>
  68. int main ()
  69. {
  70. int result = 0;
  71. if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
  72. {
  73. if (wcrtomb (NULL, 0, NULL) != 1)
  74. result |= 1;
  75. }
  76. if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
  77. {
  78. if (wcrtomb (NULL, 0, NULL) != 1)
  79. result |= 2;
  80. }
  81. if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
  82. {
  83. if (wcrtomb (NULL, 0, NULL) != 1)
  84. result |= 4;
  85. }
  86. if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
  87. {
  88. if (wcrtomb (NULL, 0, NULL) != 1)
  89. result |= 8;
  90. }
  91. return result;
  92. }]])],
  93. [gl_cv_func_wcrtomb_retval=yes],
  94. [gl_cv_func_wcrtomb_retval=no],
  95. [:])
  96. fi
  97. ])
  98. case "$gl_cv_func_wcrtomb_retval" in
  99. *yes) ;;
  100. *) REPLACE_WCRTOMB=1 ;;
  101. esac
  102. fi
  103. fi
  104. ])
  105. # Prerequisites of lib/wcrtomb.c.
  106. AC_DEFUN([gl_PREREQ_WCRTOMB], [
  107. :
  108. ])