diff options
-rw-r--r-- | newlib/ChangeLog | 8 | ||||
-rw-r--r-- | newlib/libc/locale/locale.c | 31 | ||||
-rw-r--r-- | newlib/libc/locale/nl_langinfo.c | 2 |
3 files changed, 32 insertions, 9 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 0bacfd7db..4d6016200 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,11 @@ +2010-03-27 Corinna Vinschen <corinna@vinschen.de> + + * libc/locale/locale.c (loadlocale): Optimize "EUC" charset check. + Cygwin only: Allow GB2312 and EUC-CN as alternative codeset names + for GBK. Add to documentation. + * libc/locale/nl_langinfo.c (nl_langinfo): On Cygwin, translate EUCCN + to GB2312. + 2010-03-17 Craig Howland <howland@LGSInnovations.com> * libc/include/sys/features.h: Allow for _XOPEN_SOURCE to have an diff --git a/newlib/libc/locale/locale.c b/newlib/libc/locale/locale.c index 7e28511f8..b8e86de5d 100644 --- a/newlib/libc/locale/locale.c +++ b/newlib/libc/locale/locale.c @@ -81,7 +81,8 @@ build with multibyte support and support for all ISO and Windows Codepage. Otherwise all singlebyte charsets are simply mapped to ASCII. Right now, only newlib for Cygwin is built with full charset support by default. Under Cygwin, this implementation additionally supports the charsets -<<"GBK">>, <<"eucKR">>, and <<"Big5">>. Cygwin does not support <<"JIS">>. +<<"GBK">>, <<"GB2312">>, <<"eucCN">>, <<"eucKR">>, and <<"Big5">>. Cygwin +does not support <<"JIS">>. Cygwin additionally supports locales from the file /usr/share/locale/locale.alias. @@ -587,7 +588,12 @@ restart: #endif /* !__CYGWIN__ */ case 'E': case 'e': - if (!strcasecmp (charset, "EUCJP") || !strcasecmp (charset, "EUC-JP")) + if (strncasecmp (charset, "EUC", 3)) + FAIL; + c = charset + 3; + if (*c == '-') + ++c; + if (!strcasecmp (c, "JP")) { strcpy (charset, "EUCJP"); mbc_max = 3; @@ -595,16 +601,22 @@ restart: l_mbtowc = __eucjp_mbtowc; } #ifdef __CYGWIN__ - /* Newlib does not provide EUC-KR and Cygwin's implementation - requires Windows support. */ - else if (!strcasecmp (charset, "EUCKR") - || !strcasecmp (charset, "EUC-KR")) + /* Newlib does neither provide EUC-KR nor EUC-CN, and Cygwin's + implementation requires Windows support. */ + else if (!strcasecmp (c, "KR")) { strcpy (charset, "EUCKR"); mbc_max = 2; l_wctomb = __kr_wctomb; l_mbtowc = __kr_mbtowc; } + else if (!strcasecmp (c, "CN")) + { + strcpy (charset, "EUCCN"); + mbc_max = 2; + l_wctomb = __gbk_wctomb; + l_mbtowc = __gbk_mbtowc; + } #endif /* __CYGWIN__ */ else FAIL; @@ -735,11 +747,12 @@ restart: case 'G': case 'g': #ifdef __CYGWIN__ - /* Newlib does not provide GBK and Cygwin's implementation + /* Newlib does not provide GBK/GB2312 and Cygwin's implementation requires Windows support. */ - if (!strcasecmp (charset, "GBK")) + if (!strcasecmp (charset, "GBK") + || !strcasecmp (charset, "GB2312")) { - strcpy (charset, "GBK"); + strcpy (charset, charset[2] == '2' ? "GB2312" : "GBK"); mbc_max = 2; l_wctomb = __gbk_wctomb; l_mbtowc = __gbk_mbtowc; diff --git a/newlib/libc/locale/nl_langinfo.c b/newlib/libc/locale/nl_langinfo.c index 14cd07a5e..d4f30e932 100644 --- a/newlib/libc/locale/nl_langinfo.c +++ b/newlib/libc/locale/nl_langinfo.c @@ -69,6 +69,8 @@ _DEFUN(nl_langinfo, (item), ret = "EUC-JP"; else if (strcmp (ret, "EUCKR") == 0) ret = "EUC-KR"; + else if (strcmp (ret, "EUCCN") == 0) + ret = "GB2312"; } else if (ret[0] == 'C'/*Pxxxx*/) { |