Mercurial > illumos > illumos-gate
changeset 13844:90142813f484
3154 Nonconforming tolower and toupper with UTF-8 locales
Reviewed by: Garrett D'Amore <garrett.damore@gmail.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
author | David Höppner <0xffea@gmail.com> |
---|---|
date | Mon, 01 Oct 2012 14:10:01 -0400 |
parents | ecae50d1b4e7 |
children | 025b7e65c7ac |
files | usr/src/cmd/localedef/ctype.c |
diffstat | 1 files changed, 15 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/localedef/ctype.c Mon Oct 01 11:32:38 2012 +0000 +++ b/usr/src/cmd/localedef/ctype.c Mon Oct 01 14:10:01 2012 -0400 @@ -211,6 +211,7 @@ _FileRuneEntry *ct = NULL; _FileRuneEntry *lo = NULL; _FileRuneEntry *up = NULL; + wchar_t wc; (void) memset(&rl, 0, sizeof (rl)); last_ct = NULL; @@ -223,11 +224,19 @@ (void) memcpy(rl.magic, _FILE_RUNE_MAGIC_1, 8); (void) strncpy(rl.encoding, get_wide_encoding(), sizeof (rl.encoding)); - for (ctn = avl_first(&ctypes); ctn; ctn = AVL_NEXT(&ctypes, ctn)) { + /* + * Initialize the identity map. + */ + for (wc = 0; (unsigned)wc < _CACHED_RUNES; wc++) { + rl.maplower[wc] = wc; + rl.mapupper[wc] = wc; + } - wchar_t wc = ctn->wc; + for (ctn = avl_first(&ctypes); ctn; ctn = AVL_NEXT(&ctypes, ctn)) { int conflict = 0; + wc = ctn->wc; + /* * POSIX requires certain portable characters have * certain types. Add them if they are missing. @@ -305,8 +314,10 @@ */ if ((unsigned)wc < _CACHED_RUNES) { rl.runetype[wc] = ctn->ctype; - rl.maplower[wc] = ctn->tolower ? ctn->tolower : wc; - rl.mapupper[wc] = ctn->toupper ? ctn->toupper : wc; + if (ctn->tolower) + rl.maplower[wc] = ctn->tolower; + if (ctn->toupper) + rl.mapupper[wc] = ctn->toupper; continue; }