| 1 |
# locale-fr.m4 serial 23 |
| 2 |
dnl Copyright (C) 2003, 2005-2024 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* | windows*) |
| 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 |
case $LOCALE_FR in #( |
| 137 |
'' | *[[[:space:]\"\$\'*@<:@]]*) |
| 138 |
dnl This locale name might cause trouble with sh or make. |
| 139 |
AC_MSG_WARN([invalid locale "$LOCALE_FR"; assuming "none"]) |
| 140 |
LOCALE_FR=none;; |
| 141 |
esac |
| 142 |
AC_SUBST([LOCALE_FR]) |
| 143 |
]) |
| 144 |
|
| 145 |
dnl Determine the name of a french locale with UTF-8 encoding. |
| 146 |
AC_DEFUN_ONCE([gt_LOCALE_FR_UTF8], |
| 147 |
[ |
| 148 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 149 |
AC_REQUIRE([AM_LANGINFO_CODESET]) |
| 150 |
AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [ |
| 151 |
case "$host_os" in |
| 152 |
*-musl* | midipix*) |
| 153 |
dnl On musl libc, all kinds of ll_CC.UTF-8 locales exist, even without |
| 154 |
dnl any locale file on disk. But they are effectively equivalent to the |
| 155 |
dnl C.UTF-8 locale, except for locale categories (such as LC_MESSSAGES) |
| 156 |
dnl for which localizations (.mo files) have been installed. |
| 157 |
gt_cv_locale_fr_utf8=fr_FR.UTF-8 |
| 158 |
;; |
| 159 |
*) |
| 160 |
AC_LANG_CONFTEST([AC_LANG_SOURCE([[ |
| 161 |
#include <locale.h> |
| 162 |
#include <time.h> |
| 163 |
#if HAVE_LANGINFO_CODESET |
| 164 |
# include <langinfo.h> |
| 165 |
#endif |
| 166 |
#include <stdlib.h> |
| 167 |
#include <string.h> |
| 168 |
struct tm t; |
| 169 |
char buf[16]; |
| 170 |
int main () { |
| 171 |
/* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl |
| 172 |
imitates locale dependent behaviour by looking at the environment |
| 173 |
variables, and all locales use the UTF-8 encoding. */ |
| 174 |
#if !(defined __BEOS__ || defined __HAIKU__) |
| 175 |
/* Check whether the given locale name is recognized by the system. */ |
| 176 |
# if defined _WIN32 && !defined __CYGWIN__ |
| 177 |
/* On native Windows, setlocale(category, "") looks at the system settings, |
| 178 |
not at the environment variables. Also, when an encoding suffix such |
| 179 |
as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE |
| 180 |
category of the locale to "C". */ |
| 181 |
if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL |
| 182 |
|| strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) |
| 183 |
return 1; |
| 184 |
# else |
| 185 |
if (setlocale (LC_ALL, "") == NULL) return 1; |
| 186 |
# endif |
| 187 |
/* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". |
| 188 |
On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) |
| 189 |
is empty, and the behaviour of Tcl 8.4 in this locale is not useful. |
| 190 |
On OpenBSD 4.0, when an unsupported locale is specified, setlocale() |
| 191 |
succeeds but then nl_langinfo(CODESET) is "646". In this situation, |
| 192 |
some unit tests fail. */ |
| 193 |
# if HAVE_LANGINFO_CODESET |
| 194 |
{ |
| 195 |
const char *cs = nl_langinfo (CODESET); |
| 196 |
if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0) |
| 197 |
return 1; |
| 198 |
} |
| 199 |
# endif |
| 200 |
# ifdef __CYGWIN__ |
| 201 |
/* On Cygwin, avoid locale names without encoding suffix, because the |
| 202 |
locale_charset() function relies on the encoding suffix. Note that |
| 203 |
LC_ALL is set on the command line. */ |
| 204 |
if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; |
| 205 |
# endif |
| 206 |
/* Check whether in the abbreviation of the second month, the second |
| 207 |
character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is |
| 208 |
two bytes long, with UTF-8 encoding. */ |
| 209 |
t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; |
| 210 |
if (strftime (buf, sizeof (buf), "%b", &t) < 4 |
| 211 |
|| buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v') |
| 212 |
return 1; |
| 213 |
#endif |
| 214 |
#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ |
| 215 |
/* Check whether the decimal separator is a comma. |
| 216 |
On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point |
| 217 |
are nl_langinfo(RADIXCHAR) are both ".". */ |
| 218 |
if (localeconv () ->decimal_point[0] != ',') return 1; |
| 219 |
#endif |
| 220 |
return 0; |
| 221 |
} |
| 222 |
]])]) |
| 223 |
if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then |
| 224 |
case "$host_os" in |
| 225 |
# Handle native Windows specially, because there setlocale() interprets |
| 226 |
# "ar" as "Arabic" or "Arabic_Saudi Arabia.1256", |
| 227 |
# "fr" or "fra" as "French" or "French_France.1252", |
| 228 |
# "ge"(!) or "deu"(!) as "German" or "German_Germany.1252", |
| 229 |
# "ja" as "Japanese" or "Japanese_Japan.932", |
| 230 |
# and similar. |
| 231 |
mingw* | windows*) |
| 232 |
# Test for the hypothetical native Windows locale name. |
| 233 |
if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then |
| 234 |
gt_cv_locale_fr_utf8=French_France.65001 |
| 235 |
else |
| 236 |
# None found. |
| 237 |
gt_cv_locale_fr_utf8=none |
| 238 |
fi |
| 239 |
;; |
| 240 |
*) |
| 241 |
# Setting LC_ALL is not enough. Need to set LC_TIME to empty, because |
| 242 |
# otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the |
| 243 |
# configure script would override the LC_ALL setting. Likewise for |
| 244 |
# LC_CTYPE, which is also set at the beginning of the configure script. |
| 245 |
# Test for the usual locale name. |
| 246 |
if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then |
| 247 |
gt_cv_locale_fr_utf8=fr_FR |
| 248 |
else |
| 249 |
# Test for the locale name with explicit encoding suffix. |
| 250 |
if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then |
| 251 |
gt_cv_locale_fr_utf8=fr_FR.UTF-8 |
| 252 |
else |
| 253 |
# Test for the Solaris 7 locale name. |
| 254 |
if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then |
| 255 |
gt_cv_locale_fr_utf8=fr.UTF-8 |
| 256 |
else |
| 257 |
# None found. |
| 258 |
gt_cv_locale_fr_utf8=none |
| 259 |
fi |
| 260 |
fi |
| 261 |
fi |
| 262 |
;; |
| 263 |
esac |
| 264 |
fi |
| 265 |
rm -fr conftest* |
| 266 |
;; |
| 267 |
esac |
| 268 |
]) |
| 269 |
LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8 |
| 270 |
case $LOCALE_FR_UTF8 in #( |
| 271 |
'' | *[[[:space:]\"\$\'*@<:@]]*) |
| 272 |
dnl This locale name might cause trouble with sh or make. |
| 273 |
AC_MSG_WARN([invalid locale "$LOCALE_FR_UTF8"; assuming "none"]) |
| 274 |
LOCALE_FR_UTF8=none;; |
| 275 |
esac |
| 276 |
AC_SUBST([LOCALE_FR_UTF8]) |
| 277 |
|
| 278 |
dnl Users of $LOCALE_FR_UTF8 need to know which of the locale categories they |
| 279 |
dnl can rely on. |
| 280 |
case "$host_os" in |
| 281 |
*-musl* | midipix*) |
| 282 |
dnl On musl libc, locale categories other than LC_CTYPE and LC_MESSAGES |
| 283 |
dnl are effectively unimplemented. |
| 284 |
LC_COLLATE_IMPLEMENTED=false |
| 285 |
LC_NUMERIC_IMPLEMENTED=false |
| 286 |
LC_TIME_IMPLEMENTED=false |
| 287 |
LC_MONETARY_IMPLEMENTED=false |
| 288 |
;; |
| 289 |
*) |
| 290 |
LC_COLLATE_IMPLEMENTED=true |
| 291 |
LC_NUMERIC_IMPLEMENTED=true |
| 292 |
LC_TIME_IMPLEMENTED=true |
| 293 |
LC_MONETARY_IMPLEMENTED=true |
| 294 |
;; |
| 295 |
esac |
| 296 |
AC_SUBST([LC_COLLATE_IMPLEMENTED]) |
| 297 |
AC_SUBST([LC_NUMERIC_IMPLEMENTED]) |
| 298 |
AC_SUBST([LC_TIME_IMPLEMENTED]) |
| 299 |
AC_SUBST([LC_MONETARY_IMPLEMENTED]) |
| 300 |
]) |