Debian Codegraph @

m4/locale-fr.m4

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