locale-ja.m4 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. # locale-ja.m4 serial 6
  2. dnl Copyright (C) 2003, 2005-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. dnl From Bruno Haible.
  7. dnl Determine the name of a japanese locale with EUC-JP encoding.
  8. AC_DEFUN([gt_LOCALE_JA],
  9. [
  10. AC_REQUIRE([AC_CANONICAL_HOST])
  11. AC_REQUIRE([AM_LANGINFO_CODESET])
  12. AC_CACHE_CHECK([for a traditional japanese locale], [gt_cv_locale_ja], [
  13. macosx=
  14. changequote(,)dnl
  15. case "$host_os" in
  16. darwin[56]*) ;;
  17. darwin*) macosx=yes;;
  18. esac
  19. changequote([,])dnl
  20. if test -n "$macosx"; then
  21. # On Darwin 7 (MacOS X), the libc supports some locales in non-UTF-8
  22. # encodings, but the kernel does not support them. The documentation
  23. # says:
  24. # "... all code that calls BSD system routines should ensure
  25. # that the const *char parameters of these routines are in UTF-8
  26. # encoding. All BSD system functions expect their string
  27. # parameters to be in UTF-8 encoding and nothing else."
  28. # See the comments in config.charset. Therefore we bypass the test.
  29. gt_cv_locale_ja=none
  30. else
  31. AC_LANG_CONFTEST([AC_LANG_SOURCE([
  32. changequote(,)dnl
  33. #include <locale.h>
  34. #include <time.h>
  35. #if HAVE_LANGINFO_CODESET
  36. # include <langinfo.h>
  37. #endif
  38. #include <stdlib.h>
  39. #include <string.h>
  40. struct tm t;
  41. char buf[16];
  42. int main ()
  43. {
  44. const char *p;
  45. /* Check whether the given locale name is recognized by the system. */
  46. if (setlocale (LC_ALL, "") == NULL) return 1;
  47. /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
  48. On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
  49. is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
  50. On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
  51. succeeds but then nl_langinfo(CODESET) is "646". In this situation,
  52. some unit tests fail. */
  53. #if HAVE_LANGINFO_CODESET
  54. {
  55. const char *cs = nl_langinfo (CODESET);
  56. if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
  57. return 1;
  58. }
  59. #endif
  60. #ifdef __CYGWIN__
  61. /* On Cygwin, avoid locale names without encoding suffix, because the
  62. locale_charset() function relies on the encoding suffix. Note that
  63. LC_ALL is set on the command line. */
  64. if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
  65. #endif
  66. /* Check whether MB_CUR_MAX is > 1. This excludes the dysfunctional locales
  67. on Cygwin 1.5.x. */
  68. if (MB_CUR_MAX == 1)
  69. return 1;
  70. /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
  71. This excludes the UTF-8 encoding. */
  72. t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
  73. if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
  74. for (p = buf; *p != '\0'; p++)
  75. if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
  76. return 1;
  77. return 0;
  78. }
  79. changequote([,])dnl
  80. ])])
  81. if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
  82. # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
  83. # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
  84. # configure script would override the LC_ALL setting. Likewise for
  85. # LC_CTYPE, which is also set at the beginning of the configure script.
  86. # Test for the AIX locale name.
  87. if (LC_ALL=ja_JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  88. gt_cv_locale_ja=ja_JP
  89. else
  90. # Test for the locale name with explicit encoding suffix.
  91. if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  92. gt_cv_locale_ja=ja_JP.EUC-JP
  93. else
  94. # Test for the HP-UX, OSF/1, NetBSD locale name.
  95. if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  96. gt_cv_locale_ja=ja_JP.eucJP
  97. else
  98. # Test for the IRIX, FreeBSD locale name.
  99. if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  100. gt_cv_locale_ja=ja_JP.EUC
  101. else
  102. # Test for the Solaris 7 locale name.
  103. if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  104. gt_cv_locale_ja=ja
  105. else
  106. # Special test for NetBSD 1.6.
  107. if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then
  108. gt_cv_locale_ja=ja_JP.eucJP
  109. else
  110. # None found.
  111. gt_cv_locale_ja=none
  112. fi
  113. fi
  114. fi
  115. fi
  116. fi
  117. fi
  118. fi
  119. rm -fr conftest*
  120. fi
  121. ])
  122. LOCALE_JA=$gt_cv_locale_ja
  123. AC_SUBST([LOCALE_JA])
  124. ])