locale-ja.m4 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. # locale-ja.m4 serial 7
  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. AC_LANG_CONFTEST([AC_LANG_SOURCE([
  14. changequote(,)dnl
  15. #include <locale.h>
  16. #include <time.h>
  17. #if HAVE_LANGINFO_CODESET
  18. # include <langinfo.h>
  19. #endif
  20. #include <stdlib.h>
  21. #include <string.h>
  22. struct tm t;
  23. char buf[16];
  24. int main ()
  25. {
  26. const char *p;
  27. /* Check whether the given locale name is recognized by the system. */
  28. if (setlocale (LC_ALL, "") == NULL) return 1;
  29. /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
  30. On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
  31. is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
  32. On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
  33. succeeds but then nl_langinfo(CODESET) is "646". In this situation,
  34. some unit tests fail. */
  35. #if HAVE_LANGINFO_CODESET
  36. {
  37. const char *cs = nl_langinfo (CODESET);
  38. if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
  39. return 1;
  40. }
  41. #endif
  42. #ifdef __CYGWIN__
  43. /* On Cygwin, avoid locale names without encoding suffix, because the
  44. locale_charset() function relies on the encoding suffix. Note that
  45. LC_ALL is set on the command line. */
  46. if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
  47. #endif
  48. /* Check whether MB_CUR_MAX is > 1. This excludes the dysfunctional locales
  49. on Cygwin 1.5.x. */
  50. if (MB_CUR_MAX == 1)
  51. return 1;
  52. /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
  53. This excludes the UTF-8 encoding. */
  54. t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
  55. if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
  56. for (p = buf; *p != '\0'; p++)
  57. if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
  58. return 1;
  59. return 0;
  60. }
  61. changequote([,])dnl
  62. ])])
  63. if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
  64. # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
  65. # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
  66. # configure script would override the LC_ALL setting. Likewise for
  67. # LC_CTYPE, which is also set at the beginning of the configure script.
  68. # Test for the AIX locale name.
  69. if (LC_ALL=ja_JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  70. gt_cv_locale_ja=ja_JP
  71. else
  72. # Test for the locale name with explicit encoding suffix.
  73. if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  74. gt_cv_locale_ja=ja_JP.EUC-JP
  75. else
  76. # Test for the HP-UX, OSF/1, NetBSD locale name.
  77. if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  78. gt_cv_locale_ja=ja_JP.eucJP
  79. else
  80. # Test for the IRIX, FreeBSD locale name.
  81. if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  82. gt_cv_locale_ja=ja_JP.EUC
  83. else
  84. # Test for the Solaris 7 locale name.
  85. if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  86. gt_cv_locale_ja=ja
  87. else
  88. # Special test for NetBSD 1.6.
  89. if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then
  90. gt_cv_locale_ja=ja_JP.eucJP
  91. else
  92. # None found.
  93. gt_cv_locale_ja=none
  94. fi
  95. fi
  96. fi
  97. fi
  98. fi
  99. fi
  100. fi
  101. rm -fr conftest*
  102. ])
  103. LOCALE_JA=$gt_cv_locale_ja
  104. AC_SUBST([LOCALE_JA])
  105. ])