locale-fr.m4 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. # locale-fr.m4 serial 11
  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 french locale with traditional encoding.
  8. AC_DEFUN([gt_LOCALE_FR],
  9. [
  10. AC_REQUIRE([AC_CANONICAL_HOST])
  11. AC_REQUIRE([AM_LANGINFO_CODESET])
  12. AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [
  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. /* Check whether the given locale name is recognized by the system. */
  26. if (setlocale (LC_ALL, "") == NULL) return 1;
  27. /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
  28. On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
  29. is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
  30. On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
  31. succeeds but then nl_langinfo(CODESET) is "646". In this situation,
  32. some unit tests fail. */
  33. #if HAVE_LANGINFO_CODESET
  34. {
  35. const char *cs = nl_langinfo (CODESET);
  36. if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
  37. return 1;
  38. }
  39. #endif
  40. #ifdef __CYGWIN__
  41. /* On Cygwin, avoid locale names without encoding suffix, because the
  42. locale_charset() function relies on the encoding suffix. Note that
  43. LC_ALL is set on the command line. */
  44. if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
  45. #endif
  46. /* Check whether in the abbreviation of the second month, the second
  47. character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
  48. one byte long. This excludes the UTF-8 encoding. */
  49. t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
  50. if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
  51. /* Check whether the decimal separator is a comma.
  52. On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
  53. are nl_langinfo(RADIXCHAR) are both ".". */
  54. if (localeconv () ->decimal_point[0] != ',') return 1;
  55. return 0;
  56. }
  57. changequote([,])dnl
  58. ])])
  59. if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
  60. # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
  61. # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
  62. # configure script would override the LC_ALL setting. Likewise for
  63. # LC_CTYPE, which is also set at the beginning of the configure script.
  64. # Test for the usual locale name.
  65. if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  66. gt_cv_locale_fr=fr_FR
  67. else
  68. # Test for the locale name with explicit encoding suffix.
  69. if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  70. gt_cv_locale_fr=fr_FR.ISO-8859-1
  71. else
  72. # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
  73. if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  74. gt_cv_locale_fr=fr_FR.ISO8859-1
  75. else
  76. # Test for the HP-UX locale name.
  77. if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  78. gt_cv_locale_fr=fr_FR.iso88591
  79. else
  80. # Test for the Solaris 7 locale name.
  81. if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  82. gt_cv_locale_fr=fr
  83. else
  84. # None found.
  85. gt_cv_locale_fr=none
  86. fi
  87. fi
  88. fi
  89. fi
  90. fi
  91. fi
  92. rm -fr conftest*
  93. ])
  94. LOCALE_FR=$gt_cv_locale_fr
  95. AC_SUBST([LOCALE_FR])
  96. ])
  97. dnl Determine the name of a french locale with UTF-8 encoding.
  98. AC_DEFUN([gt_LOCALE_FR_UTF8],
  99. [
  100. AC_REQUIRE([AM_LANGINFO_CODESET])
  101. AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [
  102. AC_LANG_CONFTEST([AC_LANG_SOURCE([
  103. changequote(,)dnl
  104. #include <locale.h>
  105. #include <time.h>
  106. #if HAVE_LANGINFO_CODESET
  107. # include <langinfo.h>
  108. #endif
  109. #include <stdlib.h>
  110. #include <string.h>
  111. struct tm t;
  112. char buf[16];
  113. int main () {
  114. /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
  115. imitates locale dependent behaviour by looking at the environment
  116. variables, and all locales use the UTF-8 encoding. */
  117. #if !(defined __BEOS__ || defined __HAIKU__)
  118. /* Check whether the given locale name is recognized by the system. */
  119. if (setlocale (LC_ALL, "") == NULL) return 1;
  120. /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
  121. On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
  122. is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
  123. On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
  124. succeeds but then nl_langinfo(CODESET) is "646". In this situation,
  125. some unit tests fail. */
  126. # if HAVE_LANGINFO_CODESET
  127. {
  128. const char *cs = nl_langinfo (CODESET);
  129. if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
  130. return 1;
  131. }
  132. # endif
  133. # ifdef __CYGWIN__
  134. /* On Cygwin, avoid locale names without encoding suffix, because the
  135. locale_charset() function relies on the encoding suffix. Note that
  136. LC_ALL is set on the command line. */
  137. if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
  138. # endif
  139. /* Check whether in the abbreviation of the second month, the second
  140. character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
  141. two bytes long, with UTF-8 encoding. */
  142. t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
  143. if (strftime (buf, sizeof (buf), "%b", &t) < 4
  144. || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
  145. return 1;
  146. #endif
  147. /* Check whether the decimal separator is a comma.
  148. On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
  149. are nl_langinfo(RADIXCHAR) are both ".". */
  150. if (localeconv () ->decimal_point[0] != ',') return 1;
  151. return 0;
  152. }
  153. changequote([,])dnl
  154. ])])
  155. if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
  156. # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
  157. # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
  158. # configure script would override the LC_ALL setting. Likewise for
  159. # LC_CTYPE, which is also set at the beginning of the configure script.
  160. # Test for the usual locale name.
  161. if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  162. gt_cv_locale_fr_utf8=fr_FR
  163. else
  164. # Test for the locale name with explicit encoding suffix.
  165. if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  166. gt_cv_locale_fr_utf8=fr_FR.UTF-8
  167. else
  168. # Test for the Solaris 7 locale name.
  169. if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  170. gt_cv_locale_fr_utf8=fr.UTF-8
  171. else
  172. # None found.
  173. gt_cv_locale_fr_utf8=none
  174. fi
  175. fi
  176. fi
  177. fi
  178. rm -fr conftest*
  179. ])
  180. LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
  181. AC_SUBST([LOCALE_FR_UTF8])
  182. ])