Debian Codegraph @

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