duplocale.m4 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # duplocale.m4 serial 8
  2. dnl Copyright (C) 2009-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_DUPLOCALE],
  7. [
  8. AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
  9. AC_REQUIRE([AC_CANONICAL_HOST])
  10. AC_CHECK_FUNCS_ONCE([duplocale])
  11. if test $ac_cv_func_duplocale = yes; then
  12. dnl Check against glibc bug where duplocale crashes.
  13. dnl See <http://sourceware.org/bugzilla/show_bug.cgi?id=10969>.
  14. dnl Also, on AIX 7.1, duplocale(LC_GLOBAL_LOCALE) returns (locale_t)0 with
  15. dnl errno set to EINVAL.
  16. AC_REQUIRE([gl_LOCALE_H])
  17. AC_CACHE_CHECK([whether duplocale(LC_GLOBAL_LOCALE) works],
  18. [gl_cv_func_duplocale_works],
  19. [AC_RUN_IFELSE(
  20. [AC_LANG_SOURCE([[
  21. #include <locale.h>
  22. #if HAVE_XLOCALE_H
  23. # include <xlocale.h>
  24. #endif
  25. int main ()
  26. {
  27. locale_t loc = duplocale (LC_GLOBAL_LOCALE);
  28. if (!loc)
  29. return 1;
  30. freelocale (loc);
  31. return 0;
  32. }]])],
  33. [gl_cv_func_duplocale_works=yes],
  34. [gl_cv_func_duplocale_works=no],
  35. [dnl Guess it works except on glibc < 2.12, uClibc, and AIX.
  36. case "$host_os" in
  37. aix*) gl_cv_func_duplocale_works="guessing no";;
  38. *-gnu*)
  39. AC_EGREP_CPP([Unlucky], [
  40. #include <features.h>
  41. #ifdef __GNU_LIBRARY__
  42. #if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 12)
  43. Unlucky GNU user
  44. #endif
  45. #endif
  46. #ifdef __UCLIBC__
  47. Unlucky user
  48. #endif
  49. ],
  50. [gl_cv_func_duplocale_works="guessing no"],
  51. [gl_cv_func_duplocale_works="guessing yes"])
  52. ;;
  53. *) gl_cv_func_duplocale_works="guessing yes";;
  54. esac
  55. ])
  56. ])
  57. case "$gl_cv_func_duplocale_works" in
  58. *no) REPLACE_DUPLOCALE=1 ;;
  59. esac
  60. else
  61. HAVE_DUPLOCALE=0
  62. fi
  63. ])
  64. # Prerequisites of lib/duplocale.c.
  65. AC_DEFUN([gl_PREREQ_DUPLOCALE],
  66. [
  67. :
  68. ])