Print this page
3154 Nonconforming tolower and toupper with UTF-8 locales
*** 209,218 ****
--- 209,219 ----
_FileRuneLocale rl;
ctype_node_t *ctn, *last_ct, *last_lo, *last_up;
_FileRuneEntry *ct = NULL;
_FileRuneEntry *lo = NULL;
_FileRuneEntry *up = NULL;
+ wchar_t wc;
(void) memset(&rl, 0, sizeof (rl));
last_ct = NULL;
last_lo = NULL;
last_up = NULL;
*** 221,235 ****
return;
(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)) {
! wchar_t wc = ctn->wc;
int conflict = 0;
/*
* POSIX requires certain portable characters have
* certain types. Add them if they are missing.
*/
if ((wc >= 1) && (wc <= 127)) {
--- 222,244 ----
return;
(void) memcpy(rl.magic, _FILE_RUNE_MAGIC_1, 8);
(void) strncpy(rl.encoding, get_wide_encoding(), sizeof (rl.encoding));
! /*
! * Preinit the identity map.
! */
! for (wc = 0; (unsigned)wc < _CACHED_RUNES; wc++) {
! rl.maplower[wc] = wc;
! rl.mapupper[wc] = 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.
*/
if ((wc >= 1) && (wc <= 127)) {
*** 303,314 ****
* optimization. Note that if we have not defined the
* upper/lower case, then we identity map it.
*/
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;
continue;
}
if ((last_ct != NULL) && (last_ct->ctype == ctn->ctype)) {
ct[rl.runetype_ext_nranges-1].max = wc;
--- 312,325 ----
* optimization. Note that if we have not defined the
* upper/lower case, then we identity map it.
*/
if ((unsigned)wc < _CACHED_RUNES) {
rl.runetype[wc] = ctn->ctype;
! if (ctn->tolower)
! rl.maplower[wc] = ctn->tolower;
! if (ctn->toupper)
! rl.mapupper[wc] = ctn->toupper;
continue;
}
if ((last_ct != NULL) && (last_ct->ctype == ctn->ctype)) {
ct[rl.runetype_ext_nranges-1].max = wc;