locale-fr.m4 8.0 KB

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