Drop has_localenames flag
This commit is contained in:
parent
ed0ff4b940
commit
94f98f18db
|
@ -79,164 +79,78 @@ __get_lcid_from_locale (const char *name)
|
||||||
c = strchr (locale, '_');
|
c = strchr (locale, '_');
|
||||||
if (!c)
|
if (!c)
|
||||||
return last_lcid = (LCID) -1;
|
return last_lcid = (LCID) -1;
|
||||||
if (wincap.has_localenames ())
|
|
||||||
{
|
|
||||||
wchar_t wlocale[ENCODING_LEN + 1];
|
|
||||||
|
|
||||||
/* Convert to RFC 4646 syntax which is the standard for the locale names
|
wchar_t wlocale[ENCODING_LEN + 1];
|
||||||
replacing LCIDs starting with Vista. */
|
|
||||||
*c = '-';
|
|
||||||
mbstowcs (wlocale, locale, ENCODING_LEN + 1);
|
|
||||||
lcid = LocaleNameToLCID (wlocale, 0);
|
|
||||||
/* Bug on Windows 10: LocaleNameToLCID returns LOCALE_CUSTOM_UNSPECIFIED
|
|
||||||
for unknown locales. */
|
|
||||||
if (lcid == 0 || lcid == LOCALE_CUSTOM_UNSPECIFIED)
|
|
||||||
{
|
|
||||||
/* Unfortunately there are a couple of locales for which no form
|
|
||||||
without a Script part per RFC 4646 exists.
|
|
||||||
Linux also supports no_NO which is equivalent to nb_NO. */
|
|
||||||
struct {
|
|
||||||
const char *loc;
|
|
||||||
const wchar_t *wloc;
|
|
||||||
} sc_only_locale[] = {
|
|
||||||
{ "az-AZ" , L"az-Latn-AZ" },
|
|
||||||
{ "bs-BA" , L"bs-Latn-BA" },
|
|
||||||
{ "chr-US", L"chr-Cher-US"},
|
|
||||||
{ "ff-SN" , L"ff-Latn-SN" },
|
|
||||||
{ "ha-NG" , L"ha-Latn-NG" },
|
|
||||||
{ "iu-CA" , L"iu-Latn-CA" },
|
|
||||||
{ "ku-IQ" , L"ku-Arab-IQ" },
|
|
||||||
{ "mn-CN" , L"mn-Mong-CN" },
|
|
||||||
{ "no-NO" , L"nb-NO" },
|
|
||||||
{ "pa-PK" , L"pa-Arab-PK" },
|
|
||||||
{ "sd-PK" , L"sd-Arab-PK" },
|
|
||||||
{ "sr-BA" , L"sr-Cyrl-BA" },
|
|
||||||
{ "sr-CS" , L"sr-Cyrl-CS" },
|
|
||||||
{ "sr-ME" , L"sr-Cyrl-ME" },
|
|
||||||
{ "sr-RS" , L"sr-Cyrl-RS" },
|
|
||||||
{ "tg-TJ" , L"tg-Cyrl-TJ" },
|
|
||||||
{ "tzm-DZ", L"tzm-Latn-DZ" },
|
|
||||||
{ "tzm-MA", L"tzm-Tfng-MA" },
|
|
||||||
{ "uz-UZ" , L"uz-Latn-UZ" },
|
|
||||||
{ NULL , NULL }
|
|
||||||
};
|
|
||||||
for (int i = 0; sc_only_locale[i].loc
|
|
||||||
&& sc_only_locale[i].loc[0] <= locale[0]; ++i)
|
|
||||||
if (!strcmp (locale, sc_only_locale[i].loc))
|
|
||||||
{
|
|
||||||
lcid = LocaleNameToLCID (sc_only_locale[i].wloc, 0);
|
|
||||||
if (!strncmp (locale, "sr-", 3))
|
|
||||||
{
|
|
||||||
/* Vista/2K8 is missing sr-ME and sr-RS. It has only the
|
|
||||||
deprecated sr-CS. So we map ME and RS to CS here. */
|
|
||||||
if (lcid == 0 || lcid == LOCALE_CUSTOM_UNSPECIFIED)
|
|
||||||
lcid = LocaleNameToLCID (L"sr-Cyrl-CS", 0);
|
|
||||||
/* "@latin" modifier for the sr_XY locales changes
|
|
||||||
collation behaviour so lcid should accommodate that
|
|
||||||
by being set to the Latin sublang. */
|
|
||||||
if (lcid != 0 && lcid != LOCALE_CUSTOM_UNSPECIFIED
|
|
||||||
&& has_modifier ("@latin"))
|
|
||||||
lcid = MAKELANGID (lcid & 0x3ff, (lcid >> 10) - 1);
|
|
||||||
}
|
|
||||||
else if (!strncmp (locale, "uz-", 3))
|
|
||||||
{
|
|
||||||
/* Equivalent for "@cyrillic" modifier in uz_UZ locale */
|
|
||||||
if (lcid != 0 && lcid != LOCALE_CUSTOM_UNSPECIFIED
|
|
||||||
&& has_modifier ("@cyrillic"))
|
|
||||||
lcid = MAKELANGID (lcid & 0x3ff, (lcid >> 10) + 1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lcid && lcid != LOCALE_CUSTOM_UNSPECIFIED)
|
|
||||||
last_lcid = lcid;
|
|
||||||
else
|
|
||||||
last_lcid = (LCID) -1;
|
|
||||||
debug_printf ("LCID=%04y", last_lcid);
|
|
||||||
return last_lcid;
|
|
||||||
}
|
|
||||||
/* Pre-Vista we have to loop through the LCID values and see if they
|
|
||||||
match language and TERRITORY. */
|
|
||||||
*c++ = '\0';
|
|
||||||
/* locale now points to the language, c points to the TERRITORY */
|
|
||||||
const char *language = locale;
|
|
||||||
const char *territory = c;
|
|
||||||
LCID lang, sublang;
|
|
||||||
char iso[10];
|
|
||||||
|
|
||||||
/* In theory the lang part takes 10 bits (0x3ff), but up to Windows 2003 R2
|
/* Convert to RFC 4646 syntax which is the standard for the locale names
|
||||||
the highest lang value is 0x81. */
|
replacing LCIDs starting with Vista. */
|
||||||
for (lang = 1; lang <= 0x81; ++lang)
|
*c = '-';
|
||||||
if (GetLocaleInfo (lang, LOCALE_SISO639LANGNAME, iso, 10)
|
mbstowcs (wlocale, locale, ENCODING_LEN + 1);
|
||||||
&& !strcmp (language, iso))
|
lcid = LocaleNameToLCID (wlocale, 0);
|
||||||
break;
|
/* Bug on Windows 10: LocaleNameToLCID returns LOCALE_CUSTOM_UNSPECIFIED
|
||||||
if (lang > 0x81)
|
for unknown locales. */
|
||||||
lcid = 0;
|
if (lcid == 0 || lcid == LOCALE_CUSTOM_UNSPECIFIED)
|
||||||
else if (!territory)
|
|
||||||
lcid = lang;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/* In theory the sublang part takes 7 bits (0x3f), but up to
|
/* Unfortunately there are a couple of locales for which no form
|
||||||
Windows 2003 R2 the highest sublang value is 0x14. */
|
without a Script part per RFC 4646 exists.
|
||||||
for (sublang = 1; sublang <= 0x14; ++sublang)
|
|
||||||
{
|
|
||||||
lcid = (sublang << 10) | lang;
|
|
||||||
if (GetLocaleInfo (lcid, LOCALE_SISO3166CTRYNAME, iso, 10)
|
|
||||||
&& !strcmp (territory, iso))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (sublang > 0x14)
|
|
||||||
lcid = 0;
|
|
||||||
}
|
|
||||||
if (lcid == 0 && territory)
|
|
||||||
{
|
|
||||||
/* Unfortunately there are four language LCID number areas representing
|
|
||||||
multiple languages. Fortunately only two of them already existed
|
|
||||||
pre-Vista. The concealed languages have to be tested explicitly,
|
|
||||||
since they are not catched by the above loops.
|
|
||||||
This also enables the serbian ISO 3166 territory codes which have
|
|
||||||
been changed post 2003, and maps them to the old wrong (SP was never
|
|
||||||
a valid ISO 3166 code) territory code sr_SP which fortunately has the
|
|
||||||
same LCID as the newer sr_CS.
|
|
||||||
Linux also supports no_NO which is equivalent to nb_NO. */
|
Linux also supports no_NO which is equivalent to nb_NO. */
|
||||||
struct {
|
struct {
|
||||||
const char *loc;
|
const char *loc;
|
||||||
LCID lcid;
|
const wchar_t *wloc;
|
||||||
} ambiguous_locale[] = {
|
} sc_only_locale[] = {
|
||||||
{ "bs_BA", MAKELANGID (LANG_BOSNIAN, 0x05) },
|
{ "az-AZ" , L"az-Latn-AZ" },
|
||||||
{ "nn_NO", MAKELANGID (LANG_NORWEGIAN, SUBLANG_NORWEGIAN_NYNORSK) },
|
{ "bs-BA" , L"bs-Latn-BA" },
|
||||||
{ "no_NO", MAKELANGID (LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL) },
|
{ "chr-US", L"chr-Cher-US"},
|
||||||
{ "sr_BA", MAKELANGID (LANG_BOSNIAN,
|
{ "ff-SN" , L"ff-Latn-SN" },
|
||||||
SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC) },
|
{ "ha-NG" , L"ha-Latn-NG" },
|
||||||
{ "sr_CS", MAKELANGID (LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC) },
|
{ "iu-CA" , L"iu-Latn-CA" },
|
||||||
{ "sr_ME", MAKELANGID (LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC) },
|
{ "ku-IQ" , L"ku-Arab-IQ" },
|
||||||
{ "sr_RS", MAKELANGID (LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC) },
|
{ "mn-CN" , L"mn-Mong-CN" },
|
||||||
{ "sr_SP", MAKELANGID (LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC) },
|
{ "no-NO" , L"nb-NO" },
|
||||||
{ NULL, 0 },
|
{ "pa-PK" , L"pa-Arab-PK" },
|
||||||
|
{ "sd-PK" , L"sd-Arab-PK" },
|
||||||
|
{ "sr-BA" , L"sr-Cyrl-BA" },
|
||||||
|
{ "sr-CS" , L"sr-Cyrl-CS" },
|
||||||
|
{ "sr-ME" , L"sr-Cyrl-ME" },
|
||||||
|
{ "sr-RS" , L"sr-Cyrl-RS" },
|
||||||
|
{ "tg-TJ" , L"tg-Cyrl-TJ" },
|
||||||
|
{ "tzm-DZ", L"tzm-Latn-DZ" },
|
||||||
|
{ "tzm-MA", L"tzm-Tfng-MA" },
|
||||||
|
{ "uz-UZ" , L"uz-Latn-UZ" },
|
||||||
|
{ NULL , NULL }
|
||||||
};
|
};
|
||||||
*--c = '_';
|
for (int i = 0; sc_only_locale[i].loc
|
||||||
for (int i = 0; ambiguous_locale[i].loc
|
&& sc_only_locale[i].loc[0] <= locale[0]; ++i)
|
||||||
&& ambiguous_locale[i].loc[0] <= locale[0]; ++i)
|
if (!strcmp (locale, sc_only_locale[i].loc))
|
||||||
if (!strcmp (locale, ambiguous_locale[i].loc)
|
|
||||||
&& GetLocaleInfo (ambiguous_locale[i].lcid, LOCALE_SISO639LANGNAME,
|
|
||||||
iso, 10))
|
|
||||||
{
|
{
|
||||||
lcid = ambiguous_locale[i].lcid;
|
lcid = LocaleNameToLCID (sc_only_locale[i].wloc, 0);
|
||||||
/* "@latin" modifier for the sr_XY locales changes collation
|
if (!strncmp (locale, "sr-", 3))
|
||||||
behaviour so lcid should accommodate that by being set to
|
{
|
||||||
the Latin sublang. */
|
/* Vista/2K8 is missing sr-ME and sr-RS. It has only the
|
||||||
if (!strncmp (locale, "sr_", 3) && has_modifier ("@latin"))
|
deprecated sr-CS. So we map ME and RS to CS here. */
|
||||||
lcid = MAKELANGID (lcid & 0x3ff, (lcid >> 10) - 1);
|
if (lcid == 0 || lcid == LOCALE_CUSTOM_UNSPECIFIED)
|
||||||
|
lcid = LocaleNameToLCID (L"sr-Cyrl-CS", 0);
|
||||||
|
/* "@latin" modifier for the sr_XY locales changes
|
||||||
|
collation behaviour so lcid should accommodate that
|
||||||
|
by being set to the Latin sublang. */
|
||||||
|
if (lcid != 0 && lcid != LOCALE_CUSTOM_UNSPECIFIED
|
||||||
|
&& has_modifier ("@latin"))
|
||||||
|
lcid = MAKELANGID (lcid & 0x3ff, (lcid >> 10) - 1);
|
||||||
|
}
|
||||||
|
else if (!strncmp (locale, "uz-", 3))
|
||||||
|
{
|
||||||
|
/* Equivalent for "@cyrillic" modifier in uz_UZ locale */
|
||||||
|
if (lcid != 0 && lcid != LOCALE_CUSTOM_UNSPECIFIED
|
||||||
|
&& has_modifier ("@cyrillic"))
|
||||||
|
lcid = MAKELANGID (lcid & 0x3ff, (lcid >> 10) + 1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (lcid == 0x0443) /* uz_UZ (Uzbek/Uzbekistan) */
|
if (lcid && lcid != LOCALE_CUSTOM_UNSPECIFIED)
|
||||||
{
|
last_lcid = lcid;
|
||||||
/* Equivalent for "@cyrillic" modifier in uz_UZ locale */
|
else
|
||||||
if (lcid != 0 && has_modifier ("@cyrillic"))
|
last_lcid = (LCID) -1;
|
||||||
lcid = MAKELANGID (lcid & 0x3ff, (lcid >> 10) + 1);
|
|
||||||
}
|
|
||||||
last_lcid = lcid ?: (LCID) -1;
|
|
||||||
debug_printf ("LCID=%04y", last_lcid);
|
debug_printf ("LCID=%04y", last_lcid);
|
||||||
return last_lcid;
|
return last_lcid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
has_gaa_largeaddress_bug:false,
|
has_gaa_largeaddress_bug:false,
|
||||||
has_transactions:false,
|
has_transactions:false,
|
||||||
has_broken_alloc_console:false,
|
has_broken_alloc_console:false,
|
||||||
has_localenames:false,
|
|
||||||
has_fast_cwd:false,
|
has_fast_cwd:false,
|
||||||
has_restricted_raw_disk_access:false,
|
has_restricted_raw_disk_access:false,
|
||||||
use_dont_resolve_hack:true,
|
use_dont_resolve_hack:true,
|
||||||
|
@ -52,7 +51,6 @@ wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
has_gaa_largeaddress_bug:false,
|
has_gaa_largeaddress_bug:false,
|
||||||
has_transactions:false,
|
has_transactions:false,
|
||||||
has_broken_alloc_console:false,
|
has_broken_alloc_console:false,
|
||||||
has_localenames:false,
|
|
||||||
has_fast_cwd:false,
|
has_fast_cwd:false,
|
||||||
has_restricted_raw_disk_access:false,
|
has_restricted_raw_disk_access:false,
|
||||||
use_dont_resolve_hack:true,
|
use_dont_resolve_hack:true,
|
||||||
|
@ -79,7 +77,6 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
has_gaa_largeaddress_bug:true,
|
has_gaa_largeaddress_bug:true,
|
||||||
has_transactions:true,
|
has_transactions:true,
|
||||||
has_broken_alloc_console:false,
|
has_broken_alloc_console:false,
|
||||||
has_localenames:true,
|
|
||||||
has_fast_cwd:true,
|
has_fast_cwd:true,
|
||||||
has_restricted_raw_disk_access:true,
|
has_restricted_raw_disk_access:true,
|
||||||
use_dont_resolve_hack:false,
|
use_dont_resolve_hack:false,
|
||||||
|
@ -106,7 +103,6 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
has_gaa_largeaddress_bug:true,
|
has_gaa_largeaddress_bug:true,
|
||||||
has_transactions:true,
|
has_transactions:true,
|
||||||
has_broken_alloc_console:true,
|
has_broken_alloc_console:true,
|
||||||
has_localenames:true,
|
|
||||||
has_fast_cwd:true,
|
has_fast_cwd:true,
|
||||||
has_restricted_raw_disk_access:true,
|
has_restricted_raw_disk_access:true,
|
||||||
use_dont_resolve_hack:false,
|
use_dont_resolve_hack:false,
|
||||||
|
@ -133,7 +129,6 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
has_gaa_largeaddress_bug:false,
|
has_gaa_largeaddress_bug:false,
|
||||||
has_transactions:true,
|
has_transactions:true,
|
||||||
has_broken_alloc_console:true,
|
has_broken_alloc_console:true,
|
||||||
has_localenames:true,
|
|
||||||
has_fast_cwd:true,
|
has_fast_cwd:true,
|
||||||
has_restricted_raw_disk_access:true,
|
has_restricted_raw_disk_access:true,
|
||||||
use_dont_resolve_hack:false,
|
use_dont_resolve_hack:false,
|
||||||
|
@ -160,7 +155,6 @@ wincaps wincap_10 __attribute__((section (".cygwin_dll_common"), shared)) = {
|
||||||
has_gaa_largeaddress_bug:false,
|
has_gaa_largeaddress_bug:false,
|
||||||
has_transactions:true,
|
has_transactions:true,
|
||||||
has_broken_alloc_console:true,
|
has_broken_alloc_console:true,
|
||||||
has_localenames:true,
|
|
||||||
has_fast_cwd:true,
|
has_fast_cwd:true,
|
||||||
has_restricted_raw_disk_access:true,
|
has_restricted_raw_disk_access:true,
|
||||||
use_dont_resolve_hack:false,
|
use_dont_resolve_hack:false,
|
||||||
|
@ -187,7 +181,6 @@ wincaps wincap_10_1511 __attribute__((section (".cygwin_dll_common"), shared)) =
|
||||||
has_gaa_largeaddress_bug:false,
|
has_gaa_largeaddress_bug:false,
|
||||||
has_transactions:true,
|
has_transactions:true,
|
||||||
has_broken_alloc_console:true,
|
has_broken_alloc_console:true,
|
||||||
has_localenames:true,
|
|
||||||
has_fast_cwd:true,
|
has_fast_cwd:true,
|
||||||
has_restricted_raw_disk_access:true,
|
has_restricted_raw_disk_access:true,
|
||||||
use_dont_resolve_hack:false,
|
use_dont_resolve_hack:false,
|
||||||
|
|
|
@ -18,7 +18,6 @@ struct wincaps
|
||||||
unsigned has_gaa_largeaddress_bug : 1;
|
unsigned has_gaa_largeaddress_bug : 1;
|
||||||
unsigned has_transactions : 1;
|
unsigned has_transactions : 1;
|
||||||
unsigned has_broken_alloc_console : 1;
|
unsigned has_broken_alloc_console : 1;
|
||||||
unsigned has_localenames : 1;
|
|
||||||
unsigned has_fast_cwd : 1;
|
unsigned has_fast_cwd : 1;
|
||||||
unsigned has_restricted_raw_disk_access : 1;
|
unsigned has_restricted_raw_disk_access : 1;
|
||||||
unsigned use_dont_resolve_hack : 1;
|
unsigned use_dont_resolve_hack : 1;
|
||||||
|
@ -70,7 +69,6 @@ public:
|
||||||
bool IMPLEMENT (has_gaa_largeaddress_bug)
|
bool IMPLEMENT (has_gaa_largeaddress_bug)
|
||||||
bool IMPLEMENT (has_transactions)
|
bool IMPLEMENT (has_transactions)
|
||||||
bool IMPLEMENT (has_broken_alloc_console)
|
bool IMPLEMENT (has_broken_alloc_console)
|
||||||
bool IMPLEMENT (has_localenames)
|
|
||||||
bool IMPLEMENT (has_fast_cwd)
|
bool IMPLEMENT (has_fast_cwd)
|
||||||
bool IMPLEMENT (has_restricted_raw_disk_access)
|
bool IMPLEMENT (has_restricted_raw_disk_access)
|
||||||
bool IMPLEMENT (use_dont_resolve_hack)
|
bool IMPLEMENT (use_dont_resolve_hack)
|
||||||
|
|
Loading…
Reference in New Issue