locale-fr.m4 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. # locale-fr.m4 serial 14
  2. dnl Copyright (C) 2003, 2005-2012 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 (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
  27. /* On native Windows, setlocale(category, "") looks at the system settings,
  28. not at the environment variables. Also, when an encoding suffix such
  29. as ".65001" or ".54936" is speficied, it succeeds but sets the LC_CTYPE
  30. category of the locale to "C". */
  31. if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
  32. || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
  33. return 1;
  34. #else
  35. if (setlocale (LC_ALL, "") == NULL) return 1;
  36. #endif
  37. /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
  38. On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
  39. is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
  40. On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
  41. succeeds but then nl_langinfo(CODESET) is "646". In this situation,
  42. some unit tests fail.
  43. On MirBSD 10, when an unsupported locale is specified, setlocale()
  44. succeeds but then nl_langinfo(CODESET) is "UTF-8". */
  45. #if HAVE_LANGINFO_CODESET
  46. {
  47. const char *cs = nl_langinfo (CODESET);
  48. if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
  49. || strcmp (cs, "UTF-8") == 0)
  50. return 1;
  51. }
  52. #endif
  53. #ifdef __CYGWIN__
  54. /* On Cygwin, avoid locale names without encoding suffix, because the
  55. locale_charset() function relies on the encoding suffix. Note that
  56. LC_ALL is set on the command line. */
  57. if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
  58. #endif
  59. /* Check whether in the abbreviation of the second month, the second
  60. character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
  61. one byte long. This excludes the UTF-8 encoding. */
  62. t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
  63. if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
  64. /* Check whether the decimal separator is a comma.
  65. On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
  66. are nl_langinfo(RADIXCHAR) are both ".". */
  67. if (localeconv () ->decimal_point[0] != ',') return 1;
  68. return 0;
  69. }
  70. changequote([,])dnl
  71. ])])
  72. if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
  73. case "$host_os" in
  74. # Handle native Windows specially, because there setlocale() interprets
  75. # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
  76. # "fr" or "fra" as "French" or "French_France.1252",
  77. # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
  78. # "ja" as "Japanese" or "Japanese_Japan.932",
  79. # and similar.
  80. mingw*)
  81. # Test for the native Windows locale name.
  82. if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  83. gt_cv_locale_fr=French_France.1252
  84. else
  85. # None found.
  86. gt_cv_locale_fr=none
  87. fi
  88. ;;
  89. *)
  90. # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
  91. # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
  92. # configure script would override the LC_ALL setting. Likewise for
  93. # LC_CTYPE, which is also set at the beginning of the configure script.
  94. # Test for the usual locale name.
  95. if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  96. gt_cv_locale_fr=fr_FR
  97. else
  98. # Test for the locale name with explicit encoding suffix.
  99. if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  100. gt_cv_locale_fr=fr_FR.ISO-8859-1
  101. else
  102. # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
  103. if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  104. gt_cv_locale_fr=fr_FR.ISO8859-1
  105. else
  106. # Test for the HP-UX locale name.
  107. if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  108. gt_cv_locale_fr=fr_FR.iso88591
  109. else
  110. # Test for the Solaris 7 locale name.
  111. if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  112. gt_cv_locale_fr=fr
  113. else
  114. # None found.
  115. gt_cv_locale_fr=none
  116. fi
  117. fi
  118. fi
  119. fi
  120. fi
  121. ;;
  122. esac
  123. fi
  124. rm -fr conftest*
  125. ])
  126. LOCALE_FR=$gt_cv_locale_fr
  127. AC_SUBST([LOCALE_FR])
  128. ])
  129. dnl Determine the name of a french locale with UTF-8 encoding.
  130. AC_DEFUN([gt_LOCALE_FR_UTF8],
  131. [
  132. AC_REQUIRE([AM_LANGINFO_CODESET])
  133. AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [
  134. AC_LANG_CONFTEST([AC_LANG_SOURCE([
  135. changequote(,)dnl
  136. #include <locale.h>
  137. #include <time.h>
  138. #if HAVE_LANGINFO_CODESET
  139. # include <langinfo.h>
  140. #endif
  141. #include <stdlib.h>
  142. #include <string.h>
  143. struct tm t;
  144. char buf[16];
  145. int main () {
  146. /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
  147. imitates locale dependent behaviour by looking at the environment
  148. variables, and all locales use the UTF-8 encoding. */
  149. #if !(defined __BEOS__ || defined __HAIKU__)
  150. /* Check whether the given locale name is recognized by the system. */
  151. # if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
  152. /* On native Windows, setlocale(category, "") looks at the system settings,
  153. not at the environment variables. Also, when an encoding suffix such
  154. as ".65001" or ".54936" is speficied, it succeeds but sets the LC_CTYPE
  155. category of the locale to "C". */
  156. if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
  157. || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
  158. return 1;
  159. # else
  160. if (setlocale (LC_ALL, "") == NULL) return 1;
  161. # endif
  162. /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
  163. On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
  164. is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
  165. On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
  166. succeeds but then nl_langinfo(CODESET) is "646". In this situation,
  167. some unit tests fail. */
  168. # if HAVE_LANGINFO_CODESET
  169. {
  170. const char *cs = nl_langinfo (CODESET);
  171. if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
  172. return 1;
  173. }
  174. # endif
  175. # ifdef __CYGWIN__
  176. /* On Cygwin, avoid locale names without encoding suffix, because the
  177. locale_charset() function relies on the encoding suffix. Note that
  178. LC_ALL is set on the command line. */
  179. if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
  180. # endif
  181. /* Check whether in the abbreviation of the second month, the second
  182. character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
  183. two bytes long, with UTF-8 encoding. */
  184. t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
  185. if (strftime (buf, sizeof (buf), "%b", &t) < 4
  186. || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
  187. return 1;
  188. #endif
  189. /* Check whether the decimal separator is a comma.
  190. On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
  191. are nl_langinfo(RADIXCHAR) are both ".". */
  192. if (localeconv () ->decimal_point[0] != ',') return 1;
  193. return 0;
  194. }
  195. changequote([,])dnl
  196. ])])
  197. if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
  198. case "$host_os" in
  199. # Handle native Windows specially, because there setlocale() interprets
  200. # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
  201. # "fr" or "fra" as "French" or "French_France.1252",
  202. # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
  203. # "ja" as "Japanese" or "Japanese_Japan.932",
  204. # and similar.
  205. mingw*)
  206. # Test for the hypothetical native Windows locale name.
  207. if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  208. gt_cv_locale_fr_utf8=French_France.65001
  209. else
  210. # None found.
  211. gt_cv_locale_fr_utf8=none
  212. fi
  213. ;;
  214. *)
  215. # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
  216. # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
  217. # configure script would override the LC_ALL setting. Likewise for
  218. # LC_CTYPE, which is also set at the beginning of the configure script.
  219. # Test for the usual locale name.
  220. if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  221. gt_cv_locale_fr_utf8=fr_FR
  222. else
  223. # Test for the locale name with explicit encoding suffix.
  224. if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  225. gt_cv_locale_fr_utf8=fr_FR.UTF-8
  226. else
  227. # Test for the Solaris 7 locale name.
  228. if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
  229. gt_cv_locale_fr_utf8=fr.UTF-8
  230. else
  231. # None found.
  232. gt_cv_locale_fr_utf8=none
  233. fi
  234. fi
  235. fi
  236. ;;
  237. esac
  238. fi
  239. rm -fr conftest*
  240. ])
  241. LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
  242. AC_SUBST([LOCALE_FR_UTF8])
  243. ])