duplocale.m4 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # duplocale.m4 serial 7
  2. dnl Copyright (C) 2009-2014 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. if (duplocale (LC_GLOBAL_LOCALE) == (locale_t)0)
  28. return 1;
  29. return 0;
  30. }]])],
  31. [gl_cv_func_duplocale_works=yes],
  32. [gl_cv_func_duplocale_works=no],
  33. [dnl Guess it works except on glibc < 2.12, uClibc, and AIX.
  34. case "$host_os" in
  35. aix*) gl_cv_func_duplocale_works="guessing no";;
  36. *-gnu*)
  37. AC_EGREP_CPP([Unlucky], [
  38. #include <features.h>
  39. #ifdef __GNU_LIBRARY__
  40. #if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 12)
  41. Unlucky GNU user
  42. #endif
  43. #endif
  44. #ifdef __UCLIBC__
  45. Unlucky user
  46. #endif
  47. ],
  48. [gl_cv_func_duplocale_works="guessing no"],
  49. [gl_cv_func_duplocale_works="guessing yes"])
  50. ;;
  51. *) gl_cv_func_duplocale_works="guessing yes";;
  52. esac
  53. ])
  54. ])
  55. case "$gl_cv_func_duplocale_works" in
  56. *no) REPLACE_DUPLOCALE=1 ;;
  57. esac
  58. else
  59. HAVE_DUPLOCALE=0
  60. fi
  61. ])
  62. # Prerequisites of lib/duplocale.c.
  63. AC_DEFUN([gl_PREREQ_DUPLOCALE],
  64. [
  65. :
  66. ])