locale-fr.m4 10 KB

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