4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-03-03 21:45:51 +08:00

* libc/locale/locale.c (loadlocale): Recognise the "cjknarrow"

modifier on "C.<charset>" locales too.
This commit is contained in:
Corinna Vinschen 2010-11-19 10:02:36 +00:00
parent 5c6904b515
commit ce386bafb7
2 changed files with 25 additions and 11 deletions

View File

@ -1,3 +1,8 @@
2010-11-19 Andy Koppe <andy.koppe@gmail.com>
* libc/locale/locale.c (loadlocale): Recognise the "cjknarrow"
modifier on "C.<charset>" locales too.
2010-11-18 Andy Koppe <andy.koppe@gmail.com> 2010-11-18 Andy Koppe <andy.koppe@gmail.com>
* libc/locale/locale.c (loadlocale): Fix width of CJK ambigous * libc/locale/locale.c (loadlocale): Fix width of CJK ambigous

View File

@ -452,7 +452,7 @@ loadlocale(struct _reent *p, int category)
char *locale = NULL; char *locale = NULL;
char charset[ENCODING_LEN + 1]; char charset[ENCODING_LEN + 1];
unsigned long val; unsigned long val;
char *end, *c; char *end, *c = NULL;
int mbc_max; int mbc_max;
int (*l_wctomb) (struct _reent *, char *, wchar_t, const char *, mbstate_t *); int (*l_wctomb) (struct _reent *, char *, wchar_t, const char *, mbstate_t *);
int (*l_mbtowc) (struct _reent *, wchar_t *, const char *, size_t, int (*l_mbtowc) (struct _reent *, wchar_t *, const char *, size_t,
@ -507,7 +507,16 @@ restart:
sticking to the C locale in terms sticking to the C locale in terms
of sort order, etc. Proposed in of sort order, etc. Proposed in
the Debian project. */ the Debian project. */
strcpy (charset, locale + 2); {
char *chp;
c = locale + 2;
strcpy (charset, c);
if ((chp = strchr (charset, '@')))
/* Strip off modifier */
*chp = '\0';
c += strlen (charset);
}
else /* POSIX style */ else /* POSIX style */
{ {
c = locale; c = locale;
@ -558,15 +567,15 @@ restart:
else else
/* Invalid string */ /* Invalid string */
FAIL; FAIL;
if (c[0] == '@') }
{ if (c && c[0] == '@')
/* Modifier */ {
/* Only one modifier is recognized right now. "cjknarrow" is used /* Modifier */
to modify the behaviour of wcwidth() for East Asian languages. /* Only one modifier is recognized right now. "cjknarrow" is used
For details see the comment at the end of this function. */ to modify the behaviour of wcwidth() for East Asian languages.
if (!strcmp (c + 1, "cjknarrow")) For details see the comment at the end of this function. */
cjknarrow = 1; if (!strcmp (c + 1, "cjknarrow"))
} cjknarrow = 1;
} }
/* We only support this subset of charsets. */ /* We only support this subset of charsets. */
switch (charset[0]) switch (charset[0])