Debian Codegraph @

m4/locale-fr.m4

raw
1 # locale-fr.m4
2 # serial 24
3 dnl Copyright (C) 2003, 2005-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8
9 dnl From Bruno Haible.
10
11 dnl Determine the name of a french locale with traditional encoding.
12 AC_DEFUN_ONCE([gt_LOCALE_FR],
13 [
14 AC_REQUIRE([AC_CANONICAL_HOST])
15 AC_REQUIRE([AM_LANGINFO_CODESET])
16 AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [
17 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
18 #include <locale.h>
19 #include <time.h>
20 #if HAVE_LANGINFO_CODESET
21 # include <langinfo.h>
22 #endif
23 #include <stdlib.h>
24 #include <string.h>
25 struct tm t;
26 char buf[16];
27 int main () {
28 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
29 imitates locale dependent behaviour by looking at the environment
30 variables, and all locales use the UTF-8 encoding. */
31 #if defined __BEOS__ || defined __HAIKU__
32 return 1;
33 #else
34 /* Check whether the given locale name is recognized by the system. */
35 # if defined _WIN32 && !defined __CYGWIN__
36 /* On native Windows, setlocale(category, "") looks at the system settings,
37 not at the environment variables. Also, when an encoding suffix such
38 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
39 category of the locale to "C". */
40 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
41 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
42 return 1;
43 # else
44 if (setlocale (LC_ALL, "") == NULL) return 1;
45 # endif
46 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
47 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
48 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
49 On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
50 succeeds but then nl_langinfo(CODESET) is "646". In this situation,
51 some unit tests fail.
52 On MirBSD 10, when an unsupported locale is specified, setlocale()
53 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
54 # if HAVE_LANGINFO_CODESET
55 {
56 const char *cs = nl_langinfo (CODESET);
57 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
58 || strcmp (cs, "UTF-8") == 0)
59 return 1;
60 }
61 # endif
62 # ifdef __CYGWIN__
63 /* On Cygwin, avoid locale names without encoding suffix, because the
64 locale_charset() function relies on the encoding suffix. Note that
65 LC_ALL is set on the command line. */
66 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
67 # endif
68 /* Check whether in the abbreviation of the second month, the second
69 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
70 one byte long. This excludes the UTF-8 encoding. */
71 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
72 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
73 # if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */
74 /* Check whether the decimal separator is a comma.
75 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale
76 and on Haiku in the fr_FR.UTF-8 locale,
77 localeconv()->decimal_point are nl_langinfo(RADIXCHAR) are both ".". */
78 if (localeconv () ->decimal_point[0] != ',') return 1;
79 # endif
80 return 0;
81 #endif
82 }
83 ]])])
84 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
85 case "$host_os" in
86 # Handle native Windows specially, because there setlocale() interprets
87 # "ar" or "ara" as "Arabic" or "Arabic_Saudi Arabia.1256",
88 # "en" or "eng" as "English" or "English_United States.1252",
89 # "fr" or "fra" as "French" or "French_France.1252",
90 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
91 # "ja" or "jpn" as "Japanese" or "Japanese_Japan.932",
92 # and similar.
93 mingw* | windows*)
94 # Test for the native Windows locale name.
95 if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
96 gt_cv_locale_fr=French_France.1252
97 else
98 # None found.
99 gt_cv_locale_fr=none
100 fi
101 ;;
102 *)
103 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
104 # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the
105 # configure script would override the LC_ALL setting. Likewise for
106 # LC_CTYPE, which is also set at the beginning of the configure script.
107 # Test for the usual locale name.
108 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
109 gt_cv_locale_fr=fr_FR
110 else
111 # Test for the locale name with explicit encoding suffix.
112 if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
113 gt_cv_locale_fr=fr_FR.ISO-8859-1
114 else
115 # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
116 if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
117 gt_cv_locale_fr=fr_FR.ISO8859-1
118 else
119 # Test for the HP-UX locale name.
120 if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
121 gt_cv_locale_fr=fr_FR.iso88591
122 else
123 # Test for the Solaris 10 locale name.
124 if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
125 gt_cv_locale_fr=fr
126 else
127 # None found.
128 gt_cv_locale_fr=none
129 fi
130 fi
131 fi
132 fi
133 fi
134 ;;
135 esac
136 fi
137 rm -fr conftest*
138 ])
139 LOCALE_FR=$gt_cv_locale_fr
140 case $LOCALE_FR in #(
141 '' | *[[[:space:]\"\$\'*@<:@]]*)
142 dnl This locale name might cause trouble with sh or make.
143 AC_MSG_WARN([invalid locale "$LOCALE_FR"; assuming "none"])
144 LOCALE_FR=none;;
145 esac
146 AC_SUBST([LOCALE_FR])
147 ])
148
149 dnl Determine the name of a french locale with UTF-8 encoding.
150 AC_DEFUN_ONCE([gt_LOCALE_FR_UTF8],
151 [
152 AC_REQUIRE([AC_CANONICAL_HOST])
153 AC_REQUIRE([AM_LANGINFO_CODESET])
154 AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [
155 case "$host_os" in
156 *-musl* | midipix*)
157 dnl On musl libc, all kinds of ll_CC.UTF-8 locales exist, even without
158 dnl any locale file on disk. But they are effectively equivalent to the
159 dnl C.UTF-8 locale, except for locale categories (such as LC_MESSSAGES)
160 dnl for which localizations (.mo files) have been installed.
161 gt_cv_locale_fr_utf8=fr_FR.UTF-8
162 ;;
163 *)
164 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
165 #include <locale.h>
166 #include <time.h>
167 #if HAVE_LANGINFO_CODESET
168 # include <langinfo.h>
169 #endif
170 #include <stdlib.h>
171 #include <string.h>
172 struct tm t;
173 char buf[16];
174 int main () {
175 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
176 imitates locale dependent behaviour by looking at the environment
177 variables, and all locales use the UTF-8 encoding. */
178 #if !(defined __BEOS__ || defined __HAIKU__)
179 /* Check whether the given locale name is recognized by the system. */
180 # if defined _WIN32 && !defined __CYGWIN__
181 /* On native Windows, setlocale(category, "") looks at the system settings,
182 not at the environment variables. Also, when an encoding suffix such
183 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
184 category of the locale to "C". */
185 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
186 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
187 return 1;
188 # else
189 if (setlocale (LC_ALL, "") == NULL) return 1;
190 # endif
191 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
192 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
193 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
194 On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
195 succeeds but then nl_langinfo(CODESET) is "646". In this situation,
196 some unit tests fail. */
197 # if HAVE_LANGINFO_CODESET
198 {
199 const char *cs = nl_langinfo (CODESET);
200 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
201 return 1;
202 }
203 # endif
204 # ifdef __CYGWIN__
205 /* On Cygwin, avoid locale names without encoding suffix, because the
206 locale_charset() function relies on the encoding suffix. Note that
207 LC_ALL is set on the command line. */
208 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
209 # endif
210 /* Check whether in the abbreviation of the second month, the second
211 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
212 two bytes long, with UTF-8 encoding. */
213 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
214 if (strftime (buf, sizeof (buf), "%b", &t) < 4
215 || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
216 return 1;
217 #endif
218 #if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */
219 /* Check whether the decimal separator is a comma.
220 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale
221 and on Haiku in the fr_FR.UTF-8 locale,
222 localeconv()->decimal_point are nl_langinfo(RADIXCHAR) are both ".". */
223 if (localeconv () ->decimal_point[0] != ',') return 1;
224 #endif
225 return 0;
226 }
227 ]])])
228 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
229 case "$host_os" in
230 # Handle native Windows specially, because there setlocale() interprets
231 # "ar" or "ara" as "Arabic" or "Arabic_Saudi Arabia.1256",
232 # "en" or "eng" as "English" or "English_United States.1252",
233 # "fr" or "fra" as "French" or "French_France.1252",
234 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
235 # "ja" or "jpn" as "Japanese" or "Japanese_Japan.932",
236 # and similar.
237 mingw* | windows*)
238 # Test for the hypothetical native Windows locale name.
239 if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
240 gt_cv_locale_fr_utf8=French_France.65001
241 else
242 # None found.
243 gt_cv_locale_fr_utf8=none
244 fi
245 ;;
246 *)
247 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
248 # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the
249 # configure script would override the LC_ALL setting. Likewise for
250 # LC_CTYPE, which is also set at the beginning of the configure script.
251 # Test for the usual locale name.
252 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
253 gt_cv_locale_fr_utf8=fr_FR
254 else
255 # Test for the locale name with explicit encoding suffix.
256 if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
257 gt_cv_locale_fr_utf8=fr_FR.UTF-8
258 else
259 # Test for the Solaris 10 locale name.
260 if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
261 gt_cv_locale_fr_utf8=fr.UTF-8
262 else
263 # None found.
264 gt_cv_locale_fr_utf8=none
265 fi
266 fi
267 fi
268 ;;
269 esac
270 fi
271 rm -fr conftest*
272 ;;
273 esac
274 ])
275 LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
276 case $LOCALE_FR_UTF8 in #(
277 '' | *[[[:space:]\"\$\'*@<:@]]*)
278 dnl This locale name might cause trouble with sh or make.
279 AC_MSG_WARN([invalid locale "$LOCALE_FR_UTF8"; assuming "none"])
280 LOCALE_FR_UTF8=none;;
281 esac
282 AC_SUBST([LOCALE_FR_UTF8])
283
284 dnl Users of $LOCALE_FR_UTF8 need to know which of the locale categories they
285 dnl can rely on.
286 case "$host_os" in
287 *-musl* | midipix*)
288 dnl On musl libc, locale categories other than LC_CTYPE and LC_MESSAGES
289 dnl are effectively unimplemented.
290 LC_COLLATE_IMPLEMENTED=false
291 LC_NUMERIC_IMPLEMENTED=false
292 LC_TIME_IMPLEMENTED=false
293 LC_MONETARY_IMPLEMENTED=false
294 ;;
295 *)
296 LC_COLLATE_IMPLEMENTED=true
297 LC_NUMERIC_IMPLEMENTED=true
298 LC_TIME_IMPLEMENTED=true
299 LC_MONETARY_IMPLEMENTED=true
300 ;;
301 esac
302 AC_SUBST([LC_COLLATE_IMPLEMENTED])
303 AC_SUBST([LC_NUMERIC_IMPLEMENTED])
304 AC_SUBST([LC_TIME_IMPLEMENTED])
305 AC_SUBST([LC_MONETARY_IMPLEMENTED])
306 ])