From 49f2be5b0eea30507a77e9467d0ef2c697953bca Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 8 Dec 1999 19:53:27 +0000 Subject: Update. * ctype/Versions: Add __ctype32_tolower and __ctype32_toupper. * ctype/ctype-info.c: Define __ctype32_tolower and __ctype32_toupper. * locale/C-ctype.c: Add _nl_C_LC_CTYPE_toupper32 and _nl_C_LC_CTYPE_tolower32 tables. Don't compile it names of 14652 classes and maps. * locale/langinfo.h: Define _NL_CTYPE_TOUPPER32 and _NL_CTYPE_TOLOWER32. * locale/lc-ctype.c (_nl_postload_ctype): Initialize __ctype32_toupper and __ctype32_tolower. * locale/programs/ld-ctype.c (struct locale_ctype_t): Add map32. (ctype_output): Write out map32 values. (allocate_arrays): Compute mapping tables correctly. * wctype/wcfuncs.c (towlower): Use __ctype32_tolower. (towupper): Use __ctype32_toupper. * wctype/wctype.h: Optimize towupper and towlower for values < 256. --- locale/programs/ld-ctype.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) (limited to 'locale/programs') diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c index a379b23ab9..1b8775efeb 100644 --- a/locale/programs/ld-ctype.c +++ b/locale/programs/ld-ctype.c @@ -146,6 +146,7 @@ struct locale_ctype_t char_class32_t *ctype32_b; uint32_t *names; uint32_t **map; + uint32_t **map32; uint32_t *class_name_ptr; uint32_t *map_name_ptr; unsigned char *width; @@ -793,6 +794,15 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap, (ctype->plane_size * ctype->plane_cnt + 128) * sizeof (uint32_t)); + CTYPE_DATA (_NL_CTYPE_TOUPPER32, + ctype->map32[0], + (ctype->plane_size * ctype->plane_cnt + 128) + * sizeof (uint32_t)); + CTYPE_DATA (_NL_CTYPE_TOLOWER32, + ctype->map32[1], + (ctype->plane_size * ctype->plane_cnt + 128) + * sizeof (uint32_t)); + CTYPE_DATA (_NL_CTYPE_CLASS32, ctype->ctype32_b, (ctype->plane_size * ctype->plane_cnt @@ -969,7 +979,7 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap, /* Handle extra maps. */ size_t nr = (elem - _NL_ITEM_INDEX (_NL_NUM_LC_CTYPE)) + 2; - iov[2 + elem + offset].iov_base = ctype->map[nr]; + iov[2 + elem + offset].iov_base = ctype->map32[nr]; iov[2 + elem + offset].iov_len = ((ctype->plane_size * ctype->plane_cnt + 128) * sizeof (uint32_t)); @@ -3019,22 +3029,17 @@ Computing table size for character classes might take a while..."), ctype->ctype32_b[ctype->charnames[idx]] = ctype->class_collection[idx]; /* Room for table of mappings. */ - ctype->map = (uint32_t **) xmalloc (ctype->map_collection_nr + ctype->map = (uint32_t **) xmalloc (2 * sizeof (uint32_t *)); + ctype->map32 = (uint32_t **) xmalloc (ctype->map_collection_nr * sizeof (uint32_t *)); /* Fill in all mappings. */ - for (idx = 0; idx < ctype->map_collection_nr; ++idx) + for (idx = 0; idx < 2; ++idx) { unsigned int idx2; /* Allocate table. */ - ctype->map[idx] = (uint32_t *) xmalloc ((ctype->plane_size - * ctype->plane_cnt + 128) - * sizeof (uint32_t)); - - /* Copy default value (identity mapping). */ - memcpy (&ctype->map[idx][128], ctype->names, - ctype->plane_size * ctype->plane_cnt * sizeof (uint32_t)); + ctype->map[idx] = (uint32_t *) xmalloc ((256 + 128) * sizeof (uint32_t)); /* Copy values from collection. */ for (idx2 = 0; idx2 < 256; ++idx2) @@ -3047,12 +3052,25 @@ Computing table size for character classes might take a while..."), /* EOF must map to EOF. */ ctype->map[idx][127] = EOF; + } - /* The 32 bit map collection. */ - for (idx2 = 0; idx2 < ctype->map_collection_act[idx]; ++idx2) + for (idx = 0; idx < ctype->map_collection_nr; ++idx) + { + unsigned int idx2; + + /* Allocate table. */ + ctype->map[idx] = (uint32_t *) xmalloc (ctype->plane_size + * ctype->plane_cnt + * sizeof (uint32_t)); + + /* Copy default value (identity mapping). */ + memcpy (ctype->map[idx], ctype->names, + ctype->plane_size * ctype->plane_cnt * sizeof (uint32_t)); + + /* Copy values from collection. */ + for (idx2 = 0; idx2 < 256; ++idx2) if (ctype->map_collection[idx][idx2] != 0) - ctype->map[idx][128 + ctype->charnames[idx2]] - = ctype->map_collection[idx][idx2]; + ctype->map[idx][idx2] = ctype->map_collection[idx][idx2]; } /* Extra array for class and map names. */ -- cgit v1.2.3