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