summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2010-11-19 10:02:36 +0000
committerCorinna Vinschen <corinna@vinschen.de>2010-11-19 10:02:36 +0000
commitce386bafb7e370f5d2e5fac8d01ad7acebc830c0 (patch)
tree8b73acdd774231f766a08105868596f73c08ef64
parent5c6904b515d98647fdb35a4292cb6c9d8219fe2c (diff)
downloadcygnal-ce386bafb7e370f5d2e5fac8d01ad7acebc830c0.tar.gz
cygnal-ce386bafb7e370f5d2e5fac8d01ad7acebc830c0.tar.bz2
cygnal-ce386bafb7e370f5d2e5fac8d01ad7acebc830c0.zip
* libc/locale/locale.c (loadlocale): Recognise the "cjknarrow"
modifier on "C.<charset>" locales too.
-rw-r--r--newlib/ChangeLog5
-rw-r--r--newlib/libc/locale/locale.c31
2 files changed, 25 insertions, 11 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 6d9623861..62e26326a 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -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>
* libc/locale/locale.c (loadlocale): Fix width of CJK ambigous
diff --git a/newlib/libc/locale/locale.c b/newlib/libc/locale/locale.c
index a357a171e..37ac5e947 100644
--- a/newlib/libc/locale/locale.c
+++ b/newlib/libc/locale/locale.c
@@ -452,7 +452,7 @@ loadlocale(struct _reent *p, int category)
char *locale = NULL;
char charset[ENCODING_LEN + 1];
unsigned long val;
- char *end, *c;
+ char *end, *c = NULL;
int mbc_max;
int (*l_wctomb) (struct _reent *, char *, wchar_t, const char *, mbstate_t *);
int (*l_mbtowc) (struct _reent *, wchar_t *, const char *, size_t,
@@ -507,7 +507,16 @@ restart:
sticking to the C locale in terms
of sort order, etc. Proposed in
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 */
{
c = locale;
@@ -558,15 +567,15 @@ restart:
else
/* Invalid string */
FAIL;
- if (c[0] == '@')
- {
- /* Modifier */
- /* Only one modifier is recognized right now. "cjknarrow" is used
- to modify the behaviour of wcwidth() for East Asian languages.
- For details see the comment at the end of this function. */
- if (!strcmp (c + 1, "cjknarrow"))
- cjknarrow = 1;
- }
+ }
+ if (c && c[0] == '@')
+ {
+ /* Modifier */
+ /* Only one modifier is recognized right now. "cjknarrow" is used
+ to modify the behaviour of wcwidth() for East Asian languages.
+ For details see the comment at the end of this function. */
+ if (!strcmp (c + 1, "cjknarrow"))
+ cjknarrow = 1;
}
/* We only support this subset of charsets. */
switch (charset[0])