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