Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2010-11-18 14:02:53 +0300
committerCorinna Vinschen <corinna@vinschen.de>2010-11-18 14:02:53 +0300
commit617dc68bfed4a8e9f4b8734e7819853432bded4e (patch)
treefd5c60f22c397c426d713466c51551303b9e4864 /newlib
parent9a984ac7cb2d9b585509a8f8ec8126d6c525b7c9 (diff)
* libc/locale/locale.c (loadlocale): Fix width of CJK ambigous
characters to 1 for singlebyte charsets and 2 for non-Unicode multibyte charsets. Change documentation accordingly.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog6
-rw-r--r--newlib/libc/locale/locale.c37
2 files changed, 25 insertions, 18 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 91168e54b..6d9623861 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,9 @@
+2010-11-18 Andy Koppe <andy.koppe@gmail.com>
+
+ * libc/locale/locale.c (loadlocale): Fix width of CJK ambigous
+ characters to 1 for singlebyte charsets and 2 for non-Unicode
+ multibyte charsets. Change documentation accordingly.
+
2010-11-17 Bernd Schmidt <bernds@codesourcery.com>
* configure.host (newlib_cflags): For tic6x, add -DCLOCK_PROVIDED.
diff --git a/newlib/libc/locale/locale.c b/newlib/libc/locale/locale.c
index 953da1376..a357a171e 100644
--- a/newlib/libc/locale/locale.c
+++ b/newlib/libc/locale/locale.c
@@ -90,16 +90,15 @@ Cygwin additionally supports locales from the file
(<<"">> is also accepted; if given, the settings are read from the
corresponding LC_* environment variables and $LANG according to POSIX rules.
-This implementation also supports a single modifier, <<"cjknarrow">>.
-Any other modifier is ignored. <<"cjknarrow">>, in conjunction with one
-of the language specifiers <<"ja">>, <<"ko">>, and <<"zh">> specifies
-how the functions <<wcwidth>> and <<wcswidth>> handle characters from
-the "CJK Ambiguous Width" character class described in
-http://www.unicode.org/unicode/reports/tr11/. Usually these characters
-have a width of 1, unless you specify one of the aforementioned
-languages, in which case these characters have a width of 2. By
-specifying the <<"cjknarrow">> modifier, these characters will have a
-width of one in the languages <<"ja">>, <<"ko">>, and <<"zh">> as well.
+This implementation also supports the modifier <<"cjknarrow">>, which
+affects how the functions <<wcwidth>> and <<wcswidth>> handle characters
+from the "CJK Ambiguous Width" category of characters described at
+http://www.unicode.org/reports/tr11/#Ambiguous. These characters have a width
+of 1 for singlebyte charsets and a width of 2 for multibyte charsets
+other than UTF-8. For UTF-8, their width depends on the language specifier:
+it is 2 for <<"zh">> (Chinese), <<"ja">> (Japanese), and <<"ko">> (Korean),
+and 1 for everything else. Specifying <<"cjknarrow">> forces a width of 1,
+independent of charset and language.
If you use <<NULL>> as the <[locale]> argument, <<setlocale>> returns a
pointer to the string representing the current locale. The acceptable
@@ -845,16 +844,18 @@ restart:
__wctomb = l_wctomb;
__mbtowc = l_mbtowc;
__set_ctype (charset);
- /* Check for the language part of the locale specifier. In case
- of "ja", "ko", or "zh", assume the use of CJK fonts, unless the
- "@cjknarrow" modifier has been specifed.
- The result is stored in lc_ctype_cjk_lang and tested in wcwidth()
- to figure out the width to return (1 or 2) for the "CJK Ambiguous
- Width" category of characters. */
+ /* Determine the width for the "CJK Ambiguous Width" category of
+ characters. This is used in wcwidth(). Assume single width for
+ single-byte charsets, and double width for multi-byte charsets
+ other than UTF-8. For UTF-8, use double width for the East Asian
+ languages ("ja", "ko", "zh"), and single width for everything else.
+ Single width can also be forced with the "@cjknarrow" modifier. */
lc_ctype_cjk_lang = !cjknarrow
- && ((strncmp (locale, "ja", 2) == 0
+ && mbc_max > 1
+ && (charset[0] != 'U'
+ || strncmp (locale, "ja", 2) == 0
|| strncmp (locale, "ko", 2) == 0
- || strncmp (locale, "zh", 2) == 0));
+ || strncmp (locale, "zh", 2) == 0);
#ifdef __HAVE_LOCALE_INFO__
ret = __ctype_load_locale (locale, (void *) l_wctomb, charset, mbc_max);
#endif /* __HAVE_LOCALE_INFO__ */