wcrtomb.m4 2.7 KB

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