locale-fr.m4 10 KB

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