mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-22 16:49:45 +08:00
* getlocale.c (main): Revamp -a loop to avoid duplicates and to print
locales with the correct, supported modifiers.
This commit is contained in:
parent
3b994b1249
commit
96cbb3a380
@ -1,3 +1,8 @@
|
|||||||
|
2010-02-10 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* getlocale.c (main): Revamp -a loop to avoid duplicates and to print
|
||||||
|
locales with the correct, supported modifiers.
|
||||||
|
|
||||||
2010-01-25 Corinna Vinschen <corinna@vinschen.de>
|
2010-01-25 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* getlocale.c (main): Use setlocale and fetch string from Windows
|
* getlocale.c (main): Use setlocale and fetch string from Windows
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <wchar.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#define WINVER 0x0601
|
#define WINVER 0x0601
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -109,6 +110,14 @@ int main (int argc, char **argv)
|
|||||||
unsigned lang, sublang;
|
unsigned lang, sublang;
|
||||||
|
|
||||||
for (lang = 1; lang <= 0x3ff; ++lang)
|
for (lang = 1; lang <= 0x3ff; ++lang)
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
wchar_t lang[256];
|
||||||
|
wchar_t country[256];
|
||||||
|
char loc[32];
|
||||||
|
} loc_list[32];
|
||||||
|
int lcnt = 0;
|
||||||
|
|
||||||
for (sublang = 1; sublang <= 0x3f; ++sublang)
|
for (sublang = 1; sublang <= 0x3f; ++sublang)
|
||||||
{
|
{
|
||||||
lcid = (sublang << 10) | lang;
|
lcid = (sublang << 10) | lang;
|
||||||
@ -116,13 +125,64 @@ int main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
wchar_t lang[256];
|
wchar_t lang[256];
|
||||||
wchar_t country[256];
|
wchar_t country[256];
|
||||||
char loc[32];
|
int i;
|
||||||
|
char *c, loc[32];
|
||||||
|
wchar_t wbuf[9];
|
||||||
|
|
||||||
/* Go figure. Even the English name of a language or
|
/* Go figure. Even the English name of a language or
|
||||||
locale might contain native characters. */
|
locale might contain native characters. */
|
||||||
GetLocaleInfoW (lcid, LOCALE_SENGLANGUAGE, lang, 256);
|
GetLocaleInfoW (lcid, LOCALE_SENGLANGUAGE, lang, 256);
|
||||||
GetLocaleInfoW (lcid, LOCALE_SENGCOUNTRY, country, 256);
|
GetLocaleInfoW (lcid, LOCALE_SENGCOUNTRY, country, 256);
|
||||||
stpcpy (stpcpy (loc, name), utf);
|
/* Avoid dups */
|
||||||
|
for (i = 0; i < lcnt; ++ i)
|
||||||
|
if (!wcscmp (loc_list[i].lang, lang)
|
||||||
|
&& !wcscmp (loc_list[i].country, country))
|
||||||
|
break;
|
||||||
|
if (i < lcnt)
|
||||||
|
continue;
|
||||||
|
if (lcnt < 32)
|
||||||
|
{
|
||||||
|
wcscpy (loc_list[lcnt].lang, lang);
|
||||||
|
wcscpy (loc_list[lcnt].country, country);
|
||||||
|
}
|
||||||
|
/* Now check certain conditions to figure out if that
|
||||||
|
locale requires a modifier. */
|
||||||
|
c = stpcpy (loc, name);
|
||||||
|
if (wcsstr (lang, L"(Latin)")
|
||||||
|
&& (!strncmp (loc, "sr_", 3)
|
||||||
|
|| !strcmp (loc, "be_BY")))
|
||||||
|
stpcpy (c, "@latin");
|
||||||
|
else if (wcsstr (lang, L"(Cyrillic)")
|
||||||
|
&& !strcmp (loc, "uz_UZ"))
|
||||||
|
stpcpy (c, "@cyrillic");
|
||||||
|
/* Avoid more dups */
|
||||||
|
for (i = 0; i < lcnt; ++ i)
|
||||||
|
if (!strcmp (loc_list[i].loc, loc))
|
||||||
|
{
|
||||||
|
lcnt++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i < lcnt)
|
||||||
|
continue;
|
||||||
|
if (lcnt < 32)
|
||||||
|
strcpy (loc_list[lcnt++].loc, loc);
|
||||||
|
/* Print */
|
||||||
printf ("%-16s %ls (%ls)\n", loc, lang, country);
|
printf ("%-16s %ls (%ls)\n", loc, lang, country);
|
||||||
|
/* Check for locales which sport a modifier for
|
||||||
|
changing the codeset and other stuff. */
|
||||||
|
if (!strcmp (loc, "tt_RU"))
|
||||||
|
stpcpy (c, "@iqtelif");
|
||||||
|
else if (GetLocaleInfoW (lcid, LOCALE_SINTLSYMBOL, wbuf, 9)
|
||||||
|
&& !wcsncmp (wbuf, L"EUR", 3))
|
||||||
|
stpcpy (c, "@euro");
|
||||||
|
else if (!strncmp (loc, "ja_", 3)
|
||||||
|
|| !strncmp (loc, "ko_", 3)
|
||||||
|
|| !strncmp (loc, "zh_", 3))
|
||||||
|
stpcpy (c, "@cjknarrow");
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
printf ("%-16s %ls (%ls)\n", loc, lang, country);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user