aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-09-01 19:36:44 +0000
committerUlrich Drepper <drepper@redhat.com>2000-09-01 19:36:44 +0000
commit4c7d276eb123523c66c1d8cbf7dbb10fac674cd2 (patch)
tree05a73708dde7dc5e9bf16bbd35c82233c7f2afdc
parentaebb1faa198634a318bc14cf1e577f5806fafc38 (diff)
downloadglibc-4c7d276eb123523c66c1d8cbf7dbb10fac674cd2.tar
glibc-4c7d276eb123523c66c1d8cbf7dbb10fac674cd2.tar.gz
glibc-4c7d276eb123523c66c1d8cbf7dbb10fac674cd2.tar.bz2
glibc-4c7d276eb123523c66c1d8cbf7dbb10fac674cd2.zip
Update.
2000-08-31 Bruno Haible <haible@clisp.cons.org> * wctype/wcfuncs.c (iswblank): New function. * wctype/wcfuncs_l.c (__iswblank_l): New function. * wctype/wcextra.c: Remove file. * wctype/wcextra_l.c: Remove file. * wctype/Makefile (distribute): Remove wcextra and wcextra_l. 2000-08-31 Bruno Haible <haible@clisp.cons.org> * locale/programs/ld-collate.c (collate_output): Remove redundant assert call. * string/strcoll.c: Likewise. * string/strxfrm.c: Include assert.h. Add assert calls like in string/strcoll.c. 2000-08-31 Bruno Haible <haible@clisp.cons.org> * locale/categories.def (_NL_COLLATE_HASH_SIZE, _NL_COLLATE_HASH_LAYERS, _NL_COLLATE_NAMES, _NL_CTYPE_NAMES, _NL_CTYPE_HASH_SIZE, _NL_CTYPE_HASH_LAYERS): Remove definitions. * locale/langinfo.h (_NL_COLLATE_HASH_SIZE, _NL_COLLATE_HASH_LAYERS, _NL_COLLATE_NAMES): Rename to _NL_COLLATE_GAP1/2/3 respectively. (_NL_CTYPE_NAMES): Rename to _NL_CTYPE_GAP3. (_NL_CTYPE_GAP3): Rename to _NL_CTYPE_GAP4. (_NL_CTYPE_HASH_SIZE, _NL_CTYPE_HASH_LAYERS): Rename to _NL_CTYPE_GAP5/6 respectively. * locale/C-ctype.c (_nl_C_LC_CTYPE): Update. * ctype/ctype-info.c (__ctype_names, __ctype_width): Remove variables. * locale/lc-ctype.c (_nl_postload_ctype): Assume new locale format. Don't initialize __ctype_names and __ctype_width. * wctype/cname-lookup.h: Remove file. * wctype/Makefile (distribute): Remove cname-lookup.h. * wctype/wchar-lookup.h: Include stdint.h. * wctype/wctype.c (__wctype): Assume new locale format. * wctype/wctype_l.c (__wctype_l): Likewise. * wctype/iswctype.c: Don't include cname-lookup.h. (__iswctype): Assume new locale format. * wctype/iswctype_l.c: Don't include cname-lookup.h. (__iswctype_l): Assume new locale format. * wctype/wctrans.c: Don't include ctype.h. (wctrans): Assume new locale format. * wctype/wctrans_l.c (__wctrans_l): Likewise. * wctype/towctrans.c: Don't include cname-lookup.h. (__towctrans): Assume new locale format. * wctype/towctrans_l.c: Don't include cname-lookup.h. (__towctrans_l): Assume new locale format. * wctype/wcfuncs.c: Don't include ctype.h and cname-lookup.h. Include localeinfo.h instead. (__NO_WCTYPE): Remove unused macro. (__ctype32_b, __ctype32_toupper, __ctype32_tolower): Remove declarations. (iswalnum, iswalpha, iswcntrl, iswdigit, iswlower, iswgraph, iswprint, iswpunct, iswspace, iswupper, iswxdigit): Assume new locale format. (towlower, towupper): Likewise. * wctype/wcfuncs_l.c: Don't include cname-lookup.h. Include localeinfo.h instead. (__NO_WCTYPE): Remove unused macro. (__iswalnum_l, __iswalpha_l, __iswcntrl_l, __iswdigit_l, __iswlower_l, __iswgraph_l, __iswprint_l, __iswpunct_l, __iswspace_l, __iswupper_l, __iswxdigit_l): Assume new locale format. (__towlower_l, __towupper_l): Likewise. * wcsmbs/wcwidth.h: Don't include cname-lookup.h. (__ctype32_b): Remove declaration. (internal_wcwidth): Assume new locale format. * locale/programs/ld-ctype.c (struct locale_ctype_t): Remove fields plane_size, plane_cnt, names, width. Rename map to map_b, rename map32 to map32_b, rename width_3level to width. (ctype_output): Always create new locale format. Don't emit _NL_CTYPE_NAMES, _NL_CTYPE_HASH_SIZE, _NL_CTYPE_HASH_LAYERS any more. (allocate_arrays): Always create new locale format. * locale/C-collate.c (_nl_C_LC_COLLATE): Update. * locale/weightwc.h (findidx): Assume new locale format. * string/strcoll.c (wcscoll): Remove local variables size, layers, names. * string/strxfrm.c (wcsxfrm): Likewise. * posix/fnmatch_loop.c (internal_fnwmatch): Likewise. Change type of local variable collseq to 'const char *'. (SUFFIX): Don't use, don't undefine. * posix/fnmatch.c: Remove SUFFIX definition. * locale/programs/ld-collate.c (struct locale_collate_t): Remove fields plane_size, plane_cnt, wcheads, wcseqorder. Rename wcheads_3level to wcheads, rename wcseqorder_3level to wcseqorder. (collate_finish): Always create new locale format. Remove local variables min_total, act_size. (collate_output): Always create new locale format. Remove local variables table_size, names, tablewc. Rename tablewc_3level to tablewc. 2000-08-31 Bruno Haible <haible@clisp.cons.org> * locale/programs/ld-collate.c (obstack_int32_grow, obstack_int32_grow_fast): New inline functions. (output_weightwc, collate_output): Use them where possible.
-rw-r--r--ChangeLog97
-rw-r--r--ctype/ctype-info.c2
-rw-r--r--locale/C-collate.c10
-rw-r--r--locale/C-ctype.c12
-rw-r--r--locale/categories.def6
-rw-r--r--locale/langinfo.h12
-rw-r--r--locale/lc-ctype.c31
-rw-r--r--locale/programs/ld-collate.c430
-rw-r--r--locale/programs/ld-ctype.c659
-rw-r--r--locale/weightwc.h22
-rw-r--r--posix/fnmatch.c2
-rw-r--r--posix/fnmatch_loop.c153
-rw-r--r--string/strcoll.c20
-rw-r--r--string/strxfrm.c22
-rw-r--r--wcsmbs/wcwidth.h37
-rw-r--r--wctype/Makefile7
-rw-r--r--wctype/cname-lookup.h62
-rw-r--r--wctype/iswctype.c31
-rw-r--r--wctype/iswctype_l.c32
-rw-r--r--wctype/towctrans.c19
-rw-r--r--wctype/towctrans_l.c19
-rw-r--r--wctype/wcextra.c54
-rw-r--r--wctype/wcextra_l.c55
-rw-r--r--wctype/wcfuncs.c65
-rw-r--r--wctype/wcfuncs_l.c79
-rw-r--r--wctype/wchar-lookup.h4
-rw-r--r--wctype/wctrans.c25
-rw-r--r--wctype/wctrans_l.c20
-rw-r--r--wctype/wctype.c20
-rw-r--r--wctype/wctype_l.c20
30 files changed, 468 insertions, 1559 deletions
diff --git a/ChangeLog b/ChangeLog
index 3154ab2169..ff22322a70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,100 @@
+2000-08-31 Bruno Haible <haible@clisp.cons.org>
+
+ * wctype/wcfuncs.c (iswblank): New function.
+ * wctype/wcfuncs_l.c (__iswblank_l): New function.
+ * wctype/wcextra.c: Remove file.
+ * wctype/wcextra_l.c: Remove file.
+ * wctype/Makefile (distribute): Remove wcextra and wcextra_l.
+
+2000-08-31 Bruno Haible <haible@clisp.cons.org>
+
+ * locale/programs/ld-collate.c (collate_output): Remove redundant
+ assert call.
+ * string/strcoll.c: Likewise.
+ * string/strxfrm.c: Include assert.h. Add assert calls like in
+ string/strcoll.c.
+
+2000-08-31 Bruno Haible <haible@clisp.cons.org>
+
+ * locale/categories.def (_NL_COLLATE_HASH_SIZE,
+ _NL_COLLATE_HASH_LAYERS, _NL_COLLATE_NAMES, _NL_CTYPE_NAMES,
+ _NL_CTYPE_HASH_SIZE, _NL_CTYPE_HASH_LAYERS): Remove definitions.
+ * locale/langinfo.h (_NL_COLLATE_HASH_SIZE, _NL_COLLATE_HASH_LAYERS,
+ _NL_COLLATE_NAMES): Rename to _NL_COLLATE_GAP1/2/3 respectively.
+ (_NL_CTYPE_NAMES): Rename to _NL_CTYPE_GAP3.
+ (_NL_CTYPE_GAP3): Rename to _NL_CTYPE_GAP4.
+ (_NL_CTYPE_HASH_SIZE, _NL_CTYPE_HASH_LAYERS): Rename to
+ _NL_CTYPE_GAP5/6 respectively.
+
+ * locale/C-ctype.c (_nl_C_LC_CTYPE): Update.
+ * ctype/ctype-info.c (__ctype_names, __ctype_width): Remove variables.
+ * locale/lc-ctype.c (_nl_postload_ctype): Assume new locale format.
+ Don't initialize __ctype_names and __ctype_width.
+ * wctype/cname-lookup.h: Remove file.
+ * wctype/Makefile (distribute): Remove cname-lookup.h.
+ * wctype/wchar-lookup.h: Include stdint.h.
+ * wctype/wctype.c (__wctype): Assume new locale format.
+ * wctype/wctype_l.c (__wctype_l): Likewise.
+ * wctype/iswctype.c: Don't include cname-lookup.h.
+ (__iswctype): Assume new locale format.
+ * wctype/iswctype_l.c: Don't include cname-lookup.h.
+ (__iswctype_l): Assume new locale format.
+ * wctype/wctrans.c: Don't include ctype.h.
+ (wctrans): Assume new locale format.
+ * wctype/wctrans_l.c (__wctrans_l): Likewise.
+ * wctype/towctrans.c: Don't include cname-lookup.h.
+ (__towctrans): Assume new locale format.
+ * wctype/towctrans_l.c: Don't include cname-lookup.h.
+ (__towctrans_l): Assume new locale format.
+ * wctype/wcfuncs.c: Don't include ctype.h and cname-lookup.h. Include
+ localeinfo.h instead.
+ (__NO_WCTYPE): Remove unused macro.
+ (__ctype32_b, __ctype32_toupper, __ctype32_tolower): Remove
+ declarations.
+ (iswalnum, iswalpha, iswcntrl, iswdigit, iswlower, iswgraph, iswprint,
+ iswpunct, iswspace, iswupper, iswxdigit): Assume new locale format.
+ (towlower, towupper): Likewise.
+ * wctype/wcfuncs_l.c: Don't include cname-lookup.h. Include
+ localeinfo.h instead.
+ (__NO_WCTYPE): Remove unused macro.
+ (__iswalnum_l, __iswalpha_l, __iswcntrl_l, __iswdigit_l, __iswlower_l,
+ __iswgraph_l, __iswprint_l, __iswpunct_l, __iswspace_l, __iswupper_l,
+ __iswxdigit_l): Assume new locale format.
+ (__towlower_l, __towupper_l): Likewise.
+ * wcsmbs/wcwidth.h: Don't include cname-lookup.h.
+ (__ctype32_b): Remove declaration.
+ (internal_wcwidth): Assume new locale format.
+ * locale/programs/ld-ctype.c (struct locale_ctype_t): Remove fields
+ plane_size, plane_cnt, names, width. Rename map to map_b, rename map32
+ to map32_b, rename width_3level to width.
+ (ctype_output): Always create new locale format. Don't emit
+ _NL_CTYPE_NAMES, _NL_CTYPE_HASH_SIZE, _NL_CTYPE_HASH_LAYERS any more.
+ (allocate_arrays): Always create new locale format.
+
+ * locale/C-collate.c (_nl_C_LC_COLLATE): Update.
+ * locale/weightwc.h (findidx): Assume new locale format.
+ * string/strcoll.c (wcscoll): Remove local variables size, layers,
+ names.
+ * string/strxfrm.c (wcsxfrm): Likewise.
+ * posix/fnmatch_loop.c (internal_fnwmatch): Likewise. Change type of
+ local variable collseq to 'const char *'.
+ (SUFFIX): Don't use, don't undefine.
+ * posix/fnmatch.c: Remove SUFFIX definition.
+ * locale/programs/ld-collate.c (struct locale_collate_t): Remove
+ fields plane_size, plane_cnt, wcheads, wcseqorder. Rename
+ wcheads_3level to wcheads, rename wcseqorder_3level to wcseqorder.
+ (collate_finish): Always create new locale format. Remove local
+ variables min_total, act_size.
+ (collate_output): Always create new locale format. Remove local
+ variables table_size, names, tablewc. Rename tablewc_3level to
+ tablewc.
+
+2000-08-31 Bruno Haible <haible@clisp.cons.org>
+
+ * locale/programs/ld-collate.c (obstack_int32_grow,
+ obstack_int32_grow_fast): New inline functions.
+ (output_weightwc, collate_output): Use them where possible.
+
2000-09-01 Ulrich Drepper <drepper@redhat.com>
* libio/libio.h (_IO_flockfile, _IO_funlockfile): Fix typo in last
diff --git a/ctype/ctype-info.c b/ctype/ctype-info.c
index 57f1256572..5a210f66fd 100644
--- a/ctype/ctype-info.c
+++ b/ctype/ctype-info.c
@@ -48,8 +48,6 @@ const __int32_t *__ctype_tolower = b (__int32_t, tolower, 128);
const __int32_t *__ctype_toupper = b (__int32_t, toupper, 128);
const __uint32_t *__ctype32_tolower = b (__uint32_t, tolower, 128);
const __uint32_t *__ctype32_toupper = b (__uint32_t, toupper, 128);
-const __uint32_t *__ctype_names;
-const unsigned char *__ctype_width;
const char *__ctype32_wctype[12] =
{
b(char, class_upper, 32),
diff --git a/locale/C-collate.c b/locale/C-collate.c
index a0ba0ff691..964ea50113 100644
--- a/locale/C-collate.c
+++ b/locale/C-collate.c
@@ -119,11 +119,11 @@ const struct locale_data _nl_C_LC_COLLATE =
{ string: NULL },
/* _NL_COLLATE_INDIRECTMB */
{ string: NULL },
- /* _NL_COLLATE_HASH_SIZE */
- { word: 0 },
- /* _NL_COLLATE_HASH_LAYERS */
- { word: 0 },
- /* _NL_COLLATE_NAMES */
+ /* _NL_COLLATE_GAP1 */
+ { string: NULL },
+ /* _NL_COLLATE_GAP2 */
+ { string: NULL },
+ /* _NL_COLLATE_GAP3 */
{ string: NULL },
/* _NL_COLLATE_TABLEWC */
{ string: NULL },
diff --git a/locale/C-ctype.c b/locale/C-ctype.c
index 4f8e204a5d..f9eee1ca94 100644
--- a/locale/C-ctype.c
+++ b/locale/C-ctype.c
@@ -550,14 +550,14 @@ const struct locale_data _nl_C_LC_CTYPE =
{ string: NULL },
/* _NL_CTYPE_CLASS32 */
{ string: _nl_C_LC_CTYPE_class32 },
- /* _NL_CTYPE_NAMES */
- { string: NULL },
/* _NL_CTYPE_GAP3 */
{ string: NULL },
- /* _NL_CTYPE_HASH_SIZE */
- { word: 0 },
- /* _NL_CTYPE_HASH_LAYERS */
- { word: 0 },
+ /* _NL_CTYPE_GAP4 */
+ { string: NULL },
+ /* _NL_CTYPE_GAP5 */
+ { string: NULL },
+ /* _NL_CTYPE_GAP6 */
+ { string: NULL },
/* _NL_CTYPE_CLASS_NAMES */
{ string: "upper\0" "lower\0" "alpha\0" "digit\0" "xdigit\0" "space\0"
"print\0" "graph\0" "blank\0" "cntrl\0" "punct\0" "alnum\0"
diff --git a/locale/categories.def b/locale/categories.def
index 95873d0036..2ec45e477a 100644
--- a/locale/categories.def
+++ b/locale/categories.def
@@ -48,9 +48,6 @@ DEFINE_CATEGORY
DEFINE_ELEMENT (_NL_COLLATE_WEIGHTMB, "collate-weightmb", std, string)
DEFINE_ELEMENT (_NL_COLLATE_EXTRAMB, "collate-extramb", std, string)
DEFINE_ELEMENT (_NL_COLLATE_INDIRECTMB, "collate-indirectmb", std, string)
- DEFINE_ELEMENT (_NL_COLLATE_HASH_SIZE, "collate-hash-size", std, word)
- DEFINE_ELEMENT (_NL_COLLATE_HASH_LAYERS, "collate-hash-layers", std, word)
- DEFINE_ELEMENT (_NL_COLLATE_NAMES, "collate-names", std, string)
DEFINE_ELEMENT (_NL_COLLATE_TABLEWC, "collate-tablewc", std, string)
DEFINE_ELEMENT (_NL_COLLATE_WEIGHTWC, "collate-weightwc", std, string)
DEFINE_ELEMENT (_NL_COLLATE_EXTRAWC, "collate-extrawc", std, string)
@@ -74,9 +71,6 @@ DEFINE_CATEGORY
DEFINE_ELEMENT (_NL_CTYPE_TOUPPER, "ctype-toupper", std, string)
DEFINE_ELEMENT (_NL_CTYPE_TOLOWER, "ctype-tolower", std, string)
DEFINE_ELEMENT (_NL_CTYPE_CLASS32, "ctype-class32", std, string)
- DEFINE_ELEMENT (_NL_CTYPE_NAMES, "ctype-names", std, string)
- DEFINE_ELEMENT (_NL_CTYPE_HASH_SIZE, "ctype-hash-size", std, word)
- DEFINE_ELEMENT (_NL_CTYPE_HASH_LAYERS, "ctype-hash-layers", std, word)
DEFINE_ELEMENT (_NL_CTYPE_CLASS_NAMES, "ctype-class-names", std, stringlist)
DEFINE_ELEMENT (_NL_CTYPE_MAP_NAMES, "ctype-map-names", std, stringlist)
DEFINE_ELEMENT (_NL_CTYPE_WIDTH, "ctype-width", std, bytearray)
diff --git a/locale/langinfo.h b/locale/langinfo.h
index 6a94a8759b..494b14e413 100644
--- a/locale/langinfo.h
+++ b/locale/langinfo.h
@@ -238,9 +238,9 @@ enum
_NL_COLLATE_WEIGHTMB,
_NL_COLLATE_EXTRAMB,
_NL_COLLATE_INDIRECTMB,
- _NL_COLLATE_HASH_SIZE,
- _NL_COLLATE_HASH_LAYERS,
- _NL_COLLATE_NAMES,
+ _NL_COLLATE_GAP1,
+ _NL_COLLATE_GAP2,
+ _NL_COLLATE_GAP3,
_NL_COLLATE_TABLEWC,
_NL_COLLATE_WEIGHTWC,
_NL_COLLATE_EXTRAWC,
@@ -261,10 +261,10 @@ enum
_NL_CTYPE_TOLOWER,
_NL_CTYPE_GAP2,
_NL_CTYPE_CLASS32,
- _NL_CTYPE_NAMES,
_NL_CTYPE_GAP3,
- _NL_CTYPE_HASH_SIZE,
- _NL_CTYPE_HASH_LAYERS,
+ _NL_CTYPE_GAP4,
+ _NL_CTYPE_GAP5,
+ _NL_CTYPE_GAP6,
_NL_CTYPE_CLASS_NAMES,
_NL_CTYPE_MAP_NAMES,
_NL_CTYPE_WIDTH,
diff --git a/locale/lc-ctype.c b/locale/lc-ctype.c
index 4b40b8a22d..bf7b525129 100644
--- a/locale/lc-ctype.c
+++ b/locale/lc-ctype.c
@@ -41,41 +41,28 @@ _nl_postload_ctype (void)
((const type *) _NL_CURRENT (LC_CTYPE, paste(_NL_CTYPE_,x)) + offset)
extern const uint32_t *__ctype32_b;
- extern const uint32_t *__ctype_names;
- extern const unsigned char *__ctype_width;
extern const uint32_t *__ctype32_toupper;
extern const uint32_t *__ctype32_tolower;
extern const char *__ctype32_wctype[12];
extern const char *__ctype32_wctrans[2];
extern const char *__ctype32_width;
+ size_t offset, cnt;
+
__ctype_b = current (uint16_t, CLASS, 128);
__ctype_toupper = current (uint32_t, TOUPPER, 128);
__ctype_tolower = current (uint32_t, TOLOWER, 128);
__ctype32_b = current (uint32_t, CLASS32, 0);
__ctype32_toupper = current (uint32_t, TOUPPER32, 0);
__ctype32_tolower = current (uint32_t, TOLOWER32, 0);
- if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE) != 0)
- {
- /* Old locale format. */
- __ctype_names = current (uint32_t, NAMES, 0);
- __ctype_width = current (unsigned char, WIDTH, 0);
- }
- else
- {
- /* New locale format. */
- size_t offset, cnt;
- offset = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_CLASS_OFFSET);
- for (cnt = 0; cnt < 12; cnt++)
- __ctype32_wctype[cnt] =
- _nl_current_LC_CTYPE->values[offset + cnt].string;
+ offset = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_CLASS_OFFSET);
+ for (cnt = 0; cnt < 12; cnt++)
+ __ctype32_wctype[cnt] = _nl_current_LC_CTYPE->values[offset + cnt].string;
- offset = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_OFFSET);
- for (cnt = 0; cnt < 2; cnt++)
- __ctype32_wctrans[cnt] =
- _nl_current_LC_CTYPE->values[offset + cnt].string;
+ offset = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_OFFSET);
+ for (cnt = 0; cnt < 2; cnt++)
+ __ctype32_wctrans[cnt] = _nl_current_LC_CTYPE->values[offset + cnt].string;
- __ctype32_width = current (char, WIDTH, 0);
- }
+ __ctype32_width = current (char, WIDTH, 0);
}
diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
index 6513d89adf..1bfce616f3 100644
--- a/locale/programs/ld-collate.c
+++ b/locale/programs/ld-collate.c
@@ -41,6 +41,24 @@
#define obstack_chunk_alloc malloc
#define obstack_chunk_free free
+static inline void
+obstack_int32_grow (struct obstack *obstack, int32_t data)
+{
+ if (sizeof (int32_t) == sizeof (int))
+ obstack_int_grow (obstack, data);
+ else
+ obstack_grow (obstack, &data, sizeof (int32_t));
+}
+
+static inline void
+obstack_int32_grow_fast (struct obstack *obstack, int32_t data)
+{
+ if (sizeof (int32_t) == sizeof (int))
+ obstack_int_grow_fast (obstack, data);
+ else
+ obstack_grow (obstack, &data, sizeof (int32_t));
+}
+
/* Forward declaration. */
struct element_t;
@@ -212,19 +230,13 @@ struct locale_collate_t
the multibyte sequences. */
struct element_t *mbheads[256];
- /* Table size of wide character hash table. */
- uint32_t plane_size;
- uint32_t plane_cnt;
-
/* Arrays with heads of the list for each of the leading bytes in
the multibyte sequences. */
- struct element_t **wcheads;
- struct wchead_table wcheads_3level;
+ struct wchead_table wcheads;
/* The arrays with the collation sequence order. */
unsigned char mbseqorder[256];
- uint32_t *wcseqorder;
- struct collseq_table wcseqorder_3level;
+ struct collseq_table wcseqorder;
};
@@ -1468,8 +1480,6 @@ collate_finish (struct localedef_t *locale, struct charmap_t *charmap)
struct section_list *sect;
int ruleidx;
int nr_wide_elems = 0;
- size_t min_total;
- size_t act_size;
if (collate == NULL)
{
@@ -1645,125 +1655,13 @@ collate_finish (struct localedef_t *locale, struct charmap_t *charmap)
}
/* Now to the wide character case. */
- if (oldstyle_tables)
- {
- /* Here we have to find first a good mapping function to get the
- wide range of wide character values (0x00000000 to 0x7fffffff)
- to a managable table. This might take some time so we issue
- a warning.
-
- We use a very trivial hashing function to store the sparse
- table. CH % TABSIZE is used as an index. To solve multiple hits
- we have N planes. This guarantees a fixed search time for a
- character [N / 2]. In the following code we determine the minimum
- value for TABSIZE * N, where TABSIZE >= 256.
-
- Some people complained that this algorithm takes too long. Well,
- go on, improve it. But changing the step size is *not* an
- option. Some people changed this to use only sizes of prime
- numbers. Think again, do some math. We are looking for the
- optimal solution, not something which works in general. Unless
- somebody can provide a dynamic programming solution I think this
- implementation is as good as it can get. */
- if (nr_wide_elems > 512 && !be_quiet)
- fputs (_("\
-Computing table size for collation table might take a while..."),
- stderr);
-
- min_total = UINT_MAX;
- act_size = 256;
-
- /* While we want to have a small total size we are willing to use a
- little bit larger table if this reduces the number of layers.
- Therefore we add a little penalty to the number of planes.
- Maybe this constant has to be adjusted a bit. */
-#define PENALTY 128
- do
- {
- size_t cnt[act_size];
- struct element_t *elem[act_size];
- size_t act_planes = 1;
+ collate->wcheads.p = 6;
+ collate->wcheads.q = 10;
+ wchead_table_init (&collate->wcheads);
- memset (cnt, '\0', sizeof cnt);
- memset (elem, '\0', sizeof elem);
-
- runp = collate->start;
- while (runp != NULL)
- {
- if (runp->wcs != NULL)
- {
- size_t nr = runp->wcs[0] % act_size;
- struct element_t *elemp = elem[nr];
-
- while (elemp != NULL)
- {
- if (elemp->wcs[0] == runp->wcs[0])
- break;
- elemp = elemp->wcnext;
- }
-
- if (elemp == NULL && ++cnt[nr] > act_planes)
- {
- act_planes = cnt[nr];
-
- runp->wcnext = elem[nr];
- elem[nr] = runp;
-
- if ((act_size + PENALTY) * act_planes >= min_total)
- break;
- }
- }
-
- /* Up to the next entry. */
- runp = runp->next;
- }
-
- if ((act_size + PENALTY) * act_planes < min_total)
- {
- min_total = (act_size + PENALTY) * act_planes;
- collate->plane_size = act_size;
- collate->plane_cnt = act_planes;
- }
-
- ++act_size;
- }
- while (act_size < min_total);
-
- if (nr_wide_elems > 512 && !be_quiet)
- fputs (_(" done\n"), stderr);
-
- /* Now that we know how large the table has to be we are able to
- allocate the array and start adding the characters to the lists
- in the same way we did it for the multibyte characters. */
- collate->wcheads = (struct element_t **)
- obstack_alloc (&collate->mempool, (collate->plane_size
- * collate->plane_cnt
- * sizeof (struct element_t *)));
- memset (collate->wcheads, '\0', (collate->plane_size
- * collate->plane_cnt
- * sizeof (struct element_t *)));
-
- collate->wcseqorder = (uint32_t *)
- obstack_alloc (&collate->mempool, (collate->plane_size
- * collate->plane_cnt
- * sizeof (uint32_t)));
- memset (collate->wcseqorder, '\0', (collate->plane_size
- * collate->plane_cnt
- * sizeof (uint32_t)));
- }
- else
- {
- collate->plane_size = 0;
- collate->plane_cnt = 0;
-
- collate->wcheads_3level.p = 6;
- collate->wcheads_3level.q = 10;
- wchead_table_init (&collate->wcheads_3level);
-
- collate->wcseqorder_3level.p = 6;
- collate->wcseqorder_3level.q = 10;
- collseq_table_init (&collate->wcseqorder_3level);
- }
+ collate->wcseqorder.p = 6;
+ collate->wcseqorder.q = 10;
+ collseq_table_init (&collate->wcseqorder);
/* Start adding. */
runp = collate->start;
@@ -1774,38 +1672,14 @@ Computing table size for collation table might take a while..."),
struct element_t *e;
struct element_t **eptr;
struct element_t *lastp;
- size_t idx;
-
- if (oldstyle_tables)
- {
- /* Find a free index. */
- idx = runp->wcs[0] % collate->plane_size;
- while (collate->wcheads[idx] != NULL)
- {
- /* Stop if this is an entry with the same starting character. */
- if (collate->wcheads[idx]->wcs[0] == runp->wcs[0])
- break;
-
- idx += collate->plane_size;
- }
-
- /* Insert the collation sequence value. */
- collate->wcseqorder[idx] = runp->wcseqorder;
- /* Find the point where to insert in the list. */
- eptr = &collate->wcheads[idx];
- }
- else
- {
- /* Insert the collation sequence value. */
- collseq_table_add (&collate->wcseqorder_3level, runp->wcs[0],
- runp->wcseqorder);
-
- /* Find the point where to insert in the list. */
- e = wchead_table_get (&collate->wcheads_3level, runp->wcs[0]);
- eptr = &e;
- }
+ /* Insert the collation sequence value. */
+ collseq_table_add (&collate->wcseqorder, runp->wcs[0],
+ runp->wcseqorder);
+ /* Find the point where to insert in the list. */
+ e = wchead_table_get (&collate->wcheads, runp->wcs[0]);
+ eptr = &e;
lastp = NULL;
while (*eptr != NULL)
{
@@ -1845,8 +1719,8 @@ Computing table size for collation table might take a while..."),
if (*eptr != NULL)
(*eptr)->wclast = runp;
*eptr = runp;
- if (!oldstyle_tables && eptr == &e)
- wchead_table_add (&collate->wcheads_3level, runp->wcs[0], e);
+ if (eptr == &e)
+ wchead_table_add (&collate->wcheads, runp->wcs[0], e);
dont_insertwc:
}
@@ -1854,8 +1728,7 @@ Computing table size for collation table might take a while..."),
runp = runp->next;
}
- if (!oldstyle_tables)
- collseq_table_finalize (&collate->wcseqorder_3level);
+ collseq_table_finalize (&collate->wcseqorder);
/* Now determine whether the UNDEFINED entry is needed and if yes,
whether it was defined. */
@@ -1987,10 +1860,7 @@ output_weightwc (struct obstack *pool, struct locale_collate_t *collate,
buf[j++] = elem->weights[cnt].w[i]->wcorder;
/* And add the buffer content. */
- if (sizeof (int) == sizeof (int32_t))
- obstack_int_grow (pool, j);
- else
- obstack_grow (pool, &j, sizeof (int32_t));
+ obstack_int32_grow (pool, j);
obstack_grow (pool, buf, j * sizeof (int32_t));
}
@@ -2015,10 +1885,7 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
struct obstack extrapool;
struct obstack indirectpool;
struct section_list *sect;
- size_t table_size;
- uint32_t *names;
- uint32_t *tablewc;
- struct collidx_table tablewc_3level;
+ struct collidx_table tablewc;
uint32_t elem_size;
uint32_t *elem_table;
int i;
@@ -2049,16 +1916,14 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
while (cnt < _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE))
{
/* The words have to be handled specially. */
- if (cnt == _NL_ITEM_INDEX (_NL_COLLATE_HASH_SIZE)
- || cnt == _NL_ITEM_INDEX (_NL_COLLATE_HASH_LAYERS)
- || cnt == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_HASH_SIZEMB))
+ if (cnt == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_HASH_SIZEMB))
{
iov[2 + cnt].iov_base = &dummy;
iov[2 + cnt].iov_len = sizeof (int32_t);
}
else
{
- iov[2 + cnt].iov_base = (char *) "";
+ iov[2 + cnt].iov_base = NULL;
iov[2 + cnt].iov_len = 0;
}
@@ -2081,17 +1946,8 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
/* Since we are using the sign of an integer to mark indirection the
offsets in the arrays we are indirectly referring to must not be
zero since -0 == 0. Therefore we add a bit of dummy content. */
- if (sizeof (int) == sizeof (int32_t))
- {
- obstack_int_grow (&extrapool, 0);
- obstack_int_grow (&indirectpool, 0);
- }
- else
- {
- int32_t zero = 0;
- obstack_grow (&extrapool, &zero, sizeof (zero));
- obstack_grow (&indirectpool, &zero, sizeof (zero));
- }
+ obstack_int32_grow (&extrapool, 0);
+ obstack_int32_grow (&indirectpool, 0);
/* Prepare the ruleset table. */
for (sect = collate->sections, i = 0; sect != NULL; sect = sect->next)
@@ -2195,16 +2051,9 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
/* More than one consecutive entry. We mark this by having
a negative index into the indirect table. */
- if (sizeof (int32_t) == sizeof (int))
- obstack_int_grow_fast (&extrapool,
+ obstack_int32_grow_fast (&extrapool,
-(obstack_object_size (&indirectpool)
/ sizeof (int32_t)));
- else
- {
- int32_t i = -(obstack_object_size (&indirectpool)
- / sizeof (int32_t));
- obstack_grow (&extrapool, &i, sizeof (int32_t));
- }
/* Now search first the end of the series. */
do
@@ -2229,11 +2078,7 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
do
{
weightidx = output_weight (&weightpool, collate, curp);
- if (sizeof (int32_t) == sizeof (int))
- obstack_int_grow (&indirectpool, weightidx);
- else
- obstack_grow (&indirectpool, &weightidx,
- sizeof (int32_t));
+ obstack_int32_grow (&indirectpool, weightidx);
curp = curp->mblast;
}
@@ -2241,10 +2086,7 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
/* Add the final weight. */
weightidx = output_weight (&weightpool, collate, curp);
- if (sizeof (int32_t) == sizeof (int))
- obstack_int_grow (&indirectpool, weightidx);
- else
- obstack_grow (&indirectpool, &weightidx, sizeof (int32_t));
+ obstack_int32_grow (&indirectpool, weightidx);
/* And add the end byte sequence. Without length this
time. */
@@ -2268,10 +2110,7 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
& (__alignof__ (int32_t) - 1)) == 0);
obstack_make_room (&extrapool, added);
- if (sizeof (int32_t) == sizeof (int))
- obstack_int_grow_fast (&extrapool, weightidx);
- else
- obstack_grow (&extrapool, &weightidx, sizeof (int32_t));
+ obstack_int32_grow_fast (&extrapool, weightidx);
assert (runp->nmbs <= 256);
obstack_1grow_fast (&extrapool, runp->nmbs - 1);
@@ -2301,13 +2140,7 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
& ~(__alignof__ (int32_t) - 1));
obstack_make_room (&extrapool, added);
- if (sizeof (int32_t) == sizeof (int))
- obstack_int_grow_fast (&extrapool, 0);
- else
- {
- int32_t zero = 0;
- obstack_grow (&extrapool, &zero, sizeof (int32_t));
- }
+ obstack_int32_grow_fast (&extrapool, 0);
/* XXX What rule? We just pick the first. */
obstack_1grow_fast (&extrapool, 0);
/* Length is zero. */
@@ -2355,41 +2188,23 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
/* Now the same for the wide character table. We need to store some
more information here. */
- assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_HASH_SIZE));
- iov[2 + cnt].iov_base = &collate->plane_size;
- iov[2 + cnt].iov_len = sizeof (uint32_t);
+ assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_GAP1));
+ iov[2 + cnt].iov_base = NULL;
+ iov[2 + cnt].iov_len = 0;
idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
assert (idx[cnt] % 4 == 0);
++cnt;
- assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_HASH_LAYERS));
- iov[2 + cnt].iov_base = &collate->plane_cnt;
- iov[2 + cnt].iov_len = sizeof (collate->plane_cnt);
+ assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_GAP2));
+ iov[2 + cnt].iov_base = NULL;
+ iov[2 + cnt].iov_len = 0;
idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
assert (idx[cnt] % 4 == 0);
++cnt;
- if (oldstyle_tables)
- {
- /* Construct a table with the names. The size of the table is the same
- as the table with the pointers. */
- table_size = collate->plane_size * collate->plane_cnt;
- names = (uint32_t *) alloca (table_size * sizeof (uint32_t));
- for (ch = 0; ch < table_size; ++ch)
- if (collate->wcheads[ch] == NULL)
- names[ch] = 0;
- else
- names[ch] = collate->wcheads[ch]->wcs[0];
- }
- else
- {
- table_size = 0;
- names = NULL;
- }
-
- assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_NAMES));
- iov[2 + cnt].iov_base = names;
- iov[2 + cnt].iov_len = table_size * sizeof (uint32_t);
+ assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_GAP3));
+ iov[2 + cnt].iov_base = NULL;
+ iov[2 + cnt].iov_len = 0;
idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
assert (idx[cnt] % 4 == 0);
++cnt;
@@ -2397,17 +2212,8 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
/* Since we are using the sign of an integer to mark indirection the
offsets in the arrays we are indirectly referring to must not be
zero since -0 == 0. Therefore we add a bit of dummy content. */
- if (sizeof (int) == sizeof (int32_t))
- {
- obstack_int_grow (&extrapool, 0);
- obstack_int_grow (&indirectpool, 0);
- }
- else
- {
- int32_t zero = 0;
- obstack_grow (&extrapool, &zero, sizeof (zero));
- obstack_grow (&indirectpool, &zero, sizeof (zero));
- }
+ obstack_int32_grow (&extrapool, 0);
+ obstack_int32_grow (&indirectpool, 0);
/* Now insert the `UNDEFINED' value if it is used. Since this value
will probably be used more than once it is good to store the
@@ -2425,10 +2231,7 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
if (runp->wcnext == NULL && runp->nwcs == 1)
{
int32_t weigthidx = output_weightwc (&weightpool, collate, runp);
- if (oldstyle_tables)
- tablewc[ch] = weigthidx;
- else
- collidx_table_add (&tablewc_3level, ch, weigthidx);
+ collidx_table_add (&tablewc, ch, weigthidx);
}
else
{
@@ -2436,11 +2239,8 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
compress them. */
struct element_t *lastp;
- if (oldstyle_tables)
- tablewc[ch] = -(obstack_object_size (&extrapool) / sizeof (uint32_t));
- else
- collidx_table_add (&tablewc_3level, ch,
- -(obstack_object_size (&extrapool) / sizeof (uint32_t)));
+ collidx_table_add (&tablewc, ch,
+ -(obstack_object_size (&extrapool) / sizeof (uint32_t)));
do
{
@@ -2471,21 +2271,10 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
/* More than one consecutive entry. We mark this by having
a negative index into the indirect table. */
- if (sizeof (int32_t) == sizeof (int))
- {
- obstack_int_grow_fast (&extrapool,
- -(obstack_object_size (&indirectpool)
- / sizeof (int32_t)));
- obstack_int_grow_fast (&extrapool, runp->nwcs - 1);
- }
- else
- {
- int32_t i = -(obstack_object_size (&indirectpool)
- / sizeof (int32_t));
- obstack_grow (&extrapool, &i, sizeof (int32_t));
- i = runp->nwcs - 1;
- obstack_grow (&extrapool, &i, sizeof (int32_t));
- }
+ obstack_int32_grow_fast (&extrapool,
+ -(obstack_object_size (&indirectpool)
+ / sizeof (int32_t)));
+ obstack_int32_grow_fast (&extrapool, runp->nwcs - 1);
do
runp = runp->wcnext;
@@ -2501,11 +2290,7 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
curp = runp;
for (i = 1; i < runp->nwcs; ++i)
- if (sizeof (int32_t) == sizeof (int))
- obstack_int_grow_fast (&extrapool, curp->wcs[i]);
- else
- obstack_grow (&extrapool, &curp->wcs[i],
- sizeof (int32_t));
+ obstack_int32_grow_fast (&extrapool, curp->wcs[i]);
/* Now find the end of the consecutive sequence and
add all the indeces in the indirect pool. */
@@ -2513,11 +2298,7 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
{
weightidx = output_weightwc (&weightpool, collate,
curp);
- if (sizeof (int32_t) == sizeof (int))
- obstack_int_grow (&indirectpool, weightidx);
- else
- obstack_grow (&indirectpool, &weightidx,
- sizeof (int32_t));
+ obstack_int32_grow (&indirectpool, weightidx);
curp = curp->wclast;
}
@@ -2525,20 +2306,12 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
/* Add the final weight. */
weightidx = output_weightwc (&weightpool, collate, curp);
- if (sizeof (int32_t) == sizeof (int))
- obstack_int_grow (&indirectpool, weightidx);
- else
- obstack_grow (&indirectpool, &weightidx,
- sizeof (int32_t));
+ obstack_int32_grow (&indirectpool, weightidx);
/* And add the end byte sequence. Without length this
time. */
for (i = 1; i < curp->nwcs; ++i)
- if (sizeof (int32_t) == sizeof (int))
- obstack_int_grow (&extrapool, curp->wcs[i]);
- else
- obstack_grow (&extrapool, &curp->wcs[i],
- sizeof (int32_t));
+ obstack_int32_grow (&extrapool, curp->wcs[i]);
}
else
{
@@ -2554,24 +2327,10 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
if (sizeof (int) == sizeof (int32_t))
obstack_make_room (&extrapool, added);
- if (sizeof (int32_t) == sizeof (int))
- {
- obstack_int_grow_fast (&extrapool, weightidx);
- obstack_int_grow_fast (&extrapool, runp->nwcs - 1);
- }
- else
- {
- int32_t l = runp->nwcs - 1;
- obstack_grow (&extrapool, &weightidx,
- sizeof (int32_t));
- obstack_grow (&extrapool, &l, sizeof (int32_t));
- }
+ obstack_int32_grow_fast (&extrapool, weightidx);
+ obstack_int32_grow_fast (&extrapool, runp->nwcs - 1);
for (i = 1; i < runp->nwcs; ++i)
- if (sizeof (int32_t) == sizeof (int))
- obstack_int_grow_fast (&extrapool, runp->wcs[i]);
- else
- obstack_grow (&extrapool, &runp->wcs[i],
- sizeof (int32_t));
+ obstack_int32_grow_fast (&extrapool, runp->wcs[i]);
}
/* Next entry. */
@@ -2582,37 +2341,19 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
}
}
- if (oldstyle_tables)
- {
- tablewc = (uint32_t *) alloca (table_size * sizeof (uint32_t));
+ tablewc.p = 6;
+ tablewc.q = 10;
+ collidx_table_init (&tablewc);
- for (ch = 0; ch < table_size; ++ch)
- if (collate->wcheads[ch] == NULL)
- /* Set the entry to zero. */
- tablewc[ch] = 0;
- else
- add_to_tablewc (ch, collate->wcheads[ch]);
- }
- else
- {
- tablewc_3level.p = 6;
- tablewc_3level.q = 10;
- collidx_table_init (&tablewc_3level);
+ wchead_table_iterate (&collate->wcheads, add_to_tablewc);
- wchead_table_iterate (&collate->wcheads_3level, add_to_tablewc);
-
- collidx_table_finalize (&tablewc_3level);
- }
+ collidx_table_finalize (&tablewc);
}
/* Now add the four tables. */
assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_TABLEWC));
- iov[2 + cnt].iov_base = (oldstyle_tables
- ? (void *) tablewc
- : (void *) tablewc_3level.result);
- iov[2 + cnt].iov_len = (oldstyle_tables
- ? table_size * sizeof (uint32_t)
- : tablewc_3level.result_size);
+ iov[2 + cnt].iov_base = tablewc.result;
+ iov[2 + cnt].iov_len = tablewc.result_size;
idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
assert (iov[2 + cnt].iov_len % sizeof (int32_t) == 0);
assert (idx[cnt] % 4 == 0);
@@ -2631,7 +2372,6 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
iov[2 + cnt].iov_base = obstack_finish (&extrapool);
idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
assert (iov[2 + cnt].iov_len % sizeof (int32_t) == 0);
- assert (iov[2 + cnt].iov_len % sizeof (int32_t) == 0);
assert (idx[cnt] % 4 == 0);
++cnt;
@@ -2723,13 +2463,13 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
/* Now some 32-bit values: multibyte collation sequence,
wide char string (including length), and wide char
collation sequence. */
- obstack_int_grow (&extrapool, runp->mbseqorder);
+ obstack_int32_grow (&extrapool, runp->mbseqorder);
- obstack_int_grow (&extrapool, runp->nwcs);
+ obstack_int32_grow (&extrapool, runp->nwcs);
obstack_grow (&extrapool, runp->wcs,
runp->nwcs * sizeof (uint32_t));
- obstack_int_grow (&extrapool, runp->wcseqorder);
+ obstack_int32_grow (&extrapool, runp->wcseqorder);
}
}
@@ -2764,12 +2504,8 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
++cnt;
assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_COLLSEQWC));
- iov[2 + cnt].iov_base = (oldstyle_tables
- ? (void *) collate->wcseqorder
- : (void *) collate->wcseqorder_3level.result);
- iov[2 + cnt].iov_len = (oldstyle_tables
- ? table_size * sizeof (uint32_t)
- : collate->wcseqorder_3level.result_size);
+ iov[2 + cnt].iov_base = collate->wcseqorder.result;
+ iov[2 + cnt].iov_len = collate->wcseqorder.result_size;
assert (idx[cnt] % 4 == 0);
++cnt;
diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c
index 1f40fe84ba..c29b980ea5 100644
--- a/locale/programs/ld-ctype.c
+++ b/locale/programs/ld-ctype.c
@@ -166,20 +166,16 @@ struct locale_ctype_t
size_t default_missing_lineno;
/* The arrays for the binary representation. */
- uint32_t plane_size;
- uint32_t plane_cnt;
char_class_t *ctype_b;
char_class32_t *ctype32_b;
- uint32_t *names;
- uint32_t **map;
- uint32_t **map32;
+ uint32_t **map_b;
+ uint32_t **map32_b;
uint32_t **class_b;
struct iovec *class_3level;
struct iovec *map_3level;
uint32_t *class_name_ptr;
uint32_t *map_name_ptr;
- unsigned char *width;
- struct iovec width_3level;
+ struct iovec width;
uint32_t mb_cur_max;
const char *codeset_name;
uint32_t *translit_from_idx;
@@ -857,9 +853,7 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap,
static const char nulbytes[4] = { 0, 0, 0, 0 };
struct locale_ctype_t *ctype = locale->categories[LC_CTYPE].ctype;
const size_t nelems = (_NL_ITEM_INDEX (_NL_CTYPE_EXTRA_MAP_1)
- + (oldstyle_tables
- ? (ctype->map_collection_nr - 2)
- : (ctype->nr_charclass + ctype->map_collection_nr)));
+ + ctype->nr_charclass + ctype->map_collection_nr);
struct iovec iov[2 + nelems + 2 * ctype->nr_charclass
+ ctype->map_collection_nr + 4];
struct locale_file data;
@@ -889,7 +883,7 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap,
{
#define CTYPE_EMPTY(name) \
case name: \
- iov[2 + elem + offset].iov_base = (void *) ""; \
+ iov[2 + elem + offset].iov_base = NULL; \
iov[2 + elem + offset].iov_len = 0; \
idx[elem + 1] = idx[elem]; \
break
@@ -897,6 +891,9 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap,
CTYPE_EMPTY(_NL_CTYPE_GAP1);
CTYPE_EMPTY(_NL_CTYPE_GAP2);
CTYPE_EMPTY(_NL_CTYPE_GAP3);
+ CTYPE_EMPTY(_NL_CTYPE_GAP4);
+ CTYPE_EMPTY(_NL_CTYPE_GAP5);
+ CTYPE_EMPTY(_NL_CTYPE_GAP6);
#define CTYPE_DATA(name, base, len) \
case _NL_ITEM_INDEX (name): \
@@ -910,30 +907,22 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap,
(256 + 128) * sizeof (char_class_t));
CTYPE_DATA (_NL_CTYPE_TOUPPER,
- ctype->map[0],
+ ctype->map_b[0],
(256 + 128) * sizeof (uint32_t));
CTYPE_DATA (_NL_CTYPE_TOLOWER,
- ctype->map[1],
+ ctype->map_b[1],
(256 + 128) * sizeof (uint32_t));
CTYPE_DATA (_NL_CTYPE_TOUPPER32,
- ctype->map32[0],
- (oldstyle_tables ? ctype->plane_size * ctype->plane_cnt : 256)
- * sizeof (uint32_t));
+ ctype->map32_b[0],
+ 256 * sizeof (uint32_t));
CTYPE_DATA (_NL_CTYPE_TOLOWER32,
- ctype->map32[1],
- (oldstyle_tables ? ctype->plane_size * ctype->plane_cnt : 256)
- * sizeof (uint32_t));
+ ctype->map32_b[1],
+ 256 * sizeof (uint32_t));
CTYPE_DATA (_NL_CTYPE_CLASS32,
ctype->ctype32_b,
- (oldstyle_tables ? ctype->plane_size * ctype->plane_cnt : 256)
- * sizeof (char_class32_t));
-
- CTYPE_DATA (_NL_CTYPE_NAMES,
- ctype->names,
- (oldstyle_tables ? ctype->plane_size * ctype->plane_cnt : 0)
- * sizeof (uint32_t));
+ 256 * sizeof (char_class32_t));
CTYPE_DATA (_NL_CTYPE_CLASS_OFFSET,
&ctype->class_offset, sizeof (uint32_t));
@@ -959,11 +948,6 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap,
CTYPE_DATA (_NL_CTYPE_TRANSLIT_TO_TBL,
ctype->translit_to_tbl, ctype->translit_to_tbl_size);
- CTYPE_DATA (_NL_CTYPE_HASH_SIZE,
- &ctype->plane_size, sizeof (uint32_t));
- CTYPE_DATA (_NL_CTYPE_HASH_LAYERS,
- &ctype->plane_cnt, sizeof (uint32_t));
-
case _NL_ITEM_INDEX (_NL_CTYPE_CLASS_NAMES):
/* The class name array. */
total = 0;
@@ -1001,12 +985,8 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap,
break;
CTYPE_DATA (_NL_CTYPE_WIDTH,
- (oldstyle_tables
- ? ctype->width
- : ctype->width_3level.iov_base),
- (oldstyle_tables
- ? (ctype->plane_size * ctype->plane_cnt + 3) & ~3ul
- : ctype->width_3level.iov_len));
+ ctype->width.iov_base,
+ ctype->width.iov_len);
CTYPE_DATA (_NL_CTYPE_MB_CUR_MAX,
&ctype->mb_cur_max, sizeof (uint32_t));
@@ -1183,38 +1163,23 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap,
else
{
/* Handle extra maps. */
- if (oldstyle_tables)
+ size_t nr = elem - _NL_ITEM_INDEX (_NL_CTYPE_EXTRA_MAP_1);
+ if (nr < ctype->nr_charclass)
{
- size_t nr = (elem - _NL_ITEM_INDEX (_NL_CTYPE_EXTRA_MAP_1)) + 2;
+ iov[2 + elem + offset].iov_base = ctype->class_b[nr];
+ iov[2 + elem + offset].iov_len = 256 / 32 * sizeof (uint32_t);
+ idx[elem] += iov[2 + elem + offset].iov_len;
+ ++offset;
- iov[2 + elem + offset].iov_base = ctype->map32[nr];
- iov[2 + elem + offset].iov_len = ((ctype->plane_size
- * ctype->plane_cnt)
- * sizeof (uint32_t));
-
- idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
+ iov[2 + elem + offset] = ctype->class_3level[nr];
}
else
{
- size_t nr = elem - _NL_ITEM_INDEX (_NL_CTYPE_EXTRA_MAP_1);
- if (nr < ctype->nr_charclass)
- {
- iov[2 + elem + offset].iov_base = ctype->class_b[nr];
- iov[2 + elem + offset].iov_len = 256 / 32
- * sizeof (uint32_t);
- idx[elem] += iov[2 + elem + offset].iov_len;
- ++offset;
-
- iov[2 + elem + offset] = ctype->class_3level[nr];
- }
- else
- {
- nr -= ctype->nr_charclass;
- assert (nr < ctype->map_collection_nr);
- iov[2 + elem + offset] = ctype->map_3level[nr];
- }
- idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
+ nr -= ctype->nr_charclass;
+ assert (nr < ctype->map_collection_nr);
+ iov[2 + elem + offset] = ctype->map_3level[nr];
}
+ idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
}
}
@@ -3629,135 +3594,23 @@ static void
allocate_arrays (struct locale_ctype_t *ctype, struct charmap_t *charmap,
struct repertoire_t *repertoire)
{
- size_t idx;
- size_t width_table_size;
+ size_t idx, nr;
const void *key;
size_t len;
void *vdata;
void *curs;
- /* First we have to decide how we organize the arrays. It is easy
- for a one-byte character set. But multi-byte character set
- cannot be stored flat because the chars might be sparsely used.
- So we determine an optimal hashing function for the used
- characters.
-
- We use a very trivial hashing function to store the sparse
- table. CH % TABSIZE is used as an index. To solve multiple hits
- we have N planes. This guarantees a fixed search time for a
- character [N / 2]. In the following code we determine the minimum
- value for TABSIZE * N, where TABSIZE >= 256.
-
- Some people complained that this algorithm takes too long. Well,
- go on, improve it. But changing the step size is *not* an
- option. Some people changed this to use only sizes of prime
- numbers. Think again, do some math. We are looking for the
- optimal solution, not something which works in general. Unless
- somebody can provide a dynamic programming solution I think this
- implementation is as good as it can get. */
- size_t min_total = UINT_MAX;
- size_t act_size = 256;
-
- if (oldstyle_tables)
- {
- if (!be_quiet && ctype->charnames_act > 512)
- fputs (_("\
-Computing table size for character classes might take a while..."),
- stderr);
-
- /* While we want to have a small total size we are willing to use a
- little bit larger table if this reduces the number of layers.
- Therefore we add a little penalty to the number of planes.
- Maybe this constant has to be adjusted a bit. */
-#define PENALTY 128
- do
- {
- size_t cnt[act_size];
- size_t act_planes = 1;
-
- memset (cnt, '\0', sizeof cnt);
-
- for (idx = 0; idx < 256; ++idx)
- cnt[idx] = 1;
-
- for (idx = 0; idx < ctype->charnames_act; ++idx)
- if (ctype->charnames[idx] >= 256)
- {
- size_t nr = ctype->charnames[idx] % act_size;
-
- if (++cnt[nr] > act_planes)
- {
- act_planes = cnt[nr];
- if ((act_size + PENALTY) * act_planes >= min_total)
- break;
- }
- }
-
- if ((act_size + PENALTY) * act_planes < min_total)
- {
- min_total = (act_size + PENALTY) * act_planes;
- ctype->plane_size = act_size;
- ctype->plane_cnt = act_planes;
- }
-
- ++act_size;
- }
- while (act_size < min_total);
-
- if (!be_quiet && ctype->charnames_act > 512)
- fputs (_(" done\n"), stderr);
-
-
- ctype->names = (uint32_t *) xcalloc (ctype->plane_size
- * ctype->plane_cnt,
- sizeof (uint32_t));
-
- for (idx = 1; idx < 256; ++idx)
- ctype->names[idx] = idx;
-
- /* Trick: change the 0th entry's name to 1 to mark the cell occupied. */
- ctype->names[0] = 1;
-
- for (idx = 256; idx < ctype->charnames_act; ++idx)
- {
- size_t nr = (ctype->charnames[idx] % ctype->plane_size);
- size_t depth = 0;
-
- while (ctype->names[nr + depth * ctype->plane_size])
- ++depth;
- assert (depth < ctype->plane_cnt);
-
- ctype->names[nr + depth * ctype->plane_size] = ctype->charnames[idx];
-
- /* Now for faster access remember the index in the NAMES_B array. */
- ctype->charnames[idx] = nr + depth * ctype->plane_size;
- }
- ctype->names[0] = 0;
- }
- else
- {
- ctype->plane_size = 0;
- ctype->plane_cnt = 0;
- ctype->names = NULL;
- }
-
/* You wonder about this amount of memory? This is only because some
users do not manage to address the array with unsigned values or
data types with range >= 256. '\200' would result in the array
index -128. To help these poor people we duplicate the entries for
128 up to 255 below the entry for \0. */
- ctype->ctype_b = (char_class_t *) xcalloc (256 + 128,
- sizeof (char_class_t));
- ctype->ctype32_b = (char_class32_t *)
- xcalloc ((oldstyle_tables ? ctype->plane_size * ctype->plane_cnt : 256),
- sizeof (char_class32_t));
- if (!oldstyle_tables)
- {
- ctype->class_b = (uint32_t **)
- xmalloc (ctype->nr_charclass * sizeof (uint32_t *));
- ctype->class_3level = (struct iovec *)
- xmalloc (ctype->nr_charclass * sizeof (struct iovec));
- }
+ ctype->ctype_b = (char_class_t *) xcalloc (256 + 128, sizeof (char_class_t));
+ ctype->ctype32_b = (char_class32_t *) xcalloc (256, sizeof (char_class32_t));
+ ctype->class_b = (uint32_t **)
+ xmalloc (ctype->nr_charclass * sizeof (uint32_t *));
+ ctype->class_3level = (struct iovec *)
+ xmalloc (ctype->nr_charclass * sizeof (struct iovec));
/* This is the array accessed using the multibyte string elements. */
for (idx = 0; idx < 256; ++idx)
@@ -3768,65 +3621,49 @@ Computing table size for character classes might take a while..."),
for (idx = 0; idx < 127; ++idx)
ctype->ctype_b[idx] = ctype->ctype_b[256 + idx];
- if (oldstyle_tables)
- {
- /* The 32 bit array contains all characters. */
- for (idx = 0; idx < ctype->class_collection_act; ++idx)
- ctype->ctype32_b[ctype->charnames[idx]] = ctype->class_collection[idx];
- }
- else
- {
- /* The 32 bit array contains all characters < 0x100. */
- for (idx = 0; idx < ctype->class_collection_act; ++idx)
- if (ctype->charnames[idx] < 0x100)
- ctype->ctype32_b[ctype->charnames[idx]] = ctype->class_collection[idx];
- }
+ /* The 32 bit array contains all characters < 0x100. */
+ for (idx = 0; idx < ctype->class_collection_act; ++idx)
+ if (ctype->charnames[idx] < 0x100)
+ ctype->ctype32_b[ctype->charnames[idx]] = ctype->class_collection[idx];
- if (!oldstyle_tables)
+ for (nr = 0; nr < ctype->nr_charclass; nr++)
{
- size_t nr;
+ ctype->class_b[nr] = (uint32_t *) xcalloc (256 / 32, sizeof (uint32_t));
- for (nr = 0; nr < ctype->nr_charclass; nr++)
- {
- ctype->class_b[nr] = (uint32_t *)
- xcalloc (256 / 32, sizeof (uint32_t));
-
- for (idx = 0; idx < 256; ++idx)
- if (ctype->class256_collection[idx] & _ISbit (nr))
- ctype->class_b[nr][idx >> 5] |= (uint32_t)1 << (idx & 0x1f);
- }
+ for (idx = 0; idx < 256; ++idx)
+ if (ctype->class256_collection[idx] & _ISbit (nr))
+ ctype->class_b[nr][idx >> 5] |= (uint32_t)1 << (idx & 0x1f);
+ }
- for (nr = 0; nr < ctype->nr_charclass; nr++)
- {
- struct wctype_table t;
+ for (nr = 0; nr < ctype->nr_charclass; nr++)
+ {
+ struct wctype_table t;
- t.p = 4; /* or: 5 */
- t.q = 7; /* or: 6 */
- wctype_table_init (&t);
+ t.p = 4; /* or: 5 */
+ t.q = 7; /* or: 6 */
+ wctype_table_init (&t);
- for (idx = 0; idx < ctype->class_collection_act; ++idx)
- if (ctype->class_collection[idx] & _ISwbit (nr))
- wctype_table_add (&t, ctype->charnames[idx]);
+ for (idx = 0; idx < ctype->class_collection_act; ++idx)
+ if (ctype->class_collection[idx] & _ISwbit (nr))
+ wctype_table_add (&t, ctype->charnames[idx]);
- wctype_table_finalize (&t);
+ wctype_table_finalize (&t);
- if (verbose)
- fprintf (stderr, _("%s: table for class \"%s\": %lu bytes\n"),
- "LC_CTYPE", ctype->classnames[nr],
- (unsigned long int) t.result_size);
+ if (verbose)
+ fprintf (stderr, _("%s: table for class \"%s\": %lu bytes\n"),
+ "LC_CTYPE", ctype->classnames[nr],
+ (unsigned long int) t.result_size);
- ctype->class_3level[nr].iov_base = t.result;
- ctype->class_3level[nr].iov_len = t.result_size;
- }
+ ctype->class_3level[nr].iov_base = t.result;
+ ctype->class_3level[nr].iov_len = t.result_size;
}
/* Room for table of mappings. */
- ctype->map = (uint32_t **) xmalloc (2 * sizeof (uint32_t *));
- ctype->map32 = (uint32_t **) xmalloc (ctype->map_collection_nr
- * sizeof (uint32_t *));
- if (!oldstyle_tables)
- ctype->map_3level = (struct iovec *)
- xmalloc (ctype->map_collection_nr * sizeof (struct iovec));
+ ctype->map_b = (uint32_t **) xmalloc (2 * sizeof (uint32_t *));
+ ctype->map32_b = (uint32_t **) xmalloc (ctype->map_collection_nr
+ * sizeof (uint32_t *));
+ ctype->map_3level = (struct iovec *)
+ xmalloc (ctype->map_collection_nr * sizeof (struct iovec));
/* Fill in all mappings. */
for (idx = 0; idx < 2; ++idx)
@@ -3834,19 +3671,20 @@ Computing table size for character classes might take a while..."),
unsigned int idx2;
/* Allocate table. */
- ctype->map[idx] = (uint32_t *) xmalloc ((256 + 128) * sizeof (uint32_t));
+ ctype->map_b[idx] = (uint32_t *)
+ xmalloc ((256 + 128) * sizeof (uint32_t));
/* Copy values from collection. */
for (idx2 = 0; idx2 < 256; ++idx2)
- ctype->map[idx][128 + idx2] = ctype->map256_collection[idx][idx2];
+ ctype->map_b[idx][128 + idx2] = ctype->map256_collection[idx][idx2];
/* Mirror first 127 entries. We must take care not to map entry
-1 because EOF == -1. */
for (idx2 = 0; idx2 < 127; ++idx2)
- ctype->map[idx][idx2] = ctype->map[idx][256 + idx2];
+ ctype->map_b[idx][idx2] = ctype->map_b[idx][256 + idx2];
/* EOF must map to EOF. */
- ctype->map[idx][127] = EOF;
+ ctype->map_b[idx][127] = EOF;
}
for (idx = 0; idx < ctype->map_collection_nr; ++idx)
@@ -3854,60 +3692,38 @@ Computing table size for character classes might take a while..."),
unsigned int idx2;
/* Allocate table. */
- ctype->map32[idx] = (uint32_t *)
- xmalloc ((oldstyle_tables ? ctype->plane_size * ctype->plane_cnt : 256)
- * sizeof (uint32_t));
-
- /* Copy default value (identity mapping). */
- if (oldstyle_tables)
- memcpy (ctype->map32[idx], ctype->names,
- ctype->plane_size * ctype->plane_cnt * sizeof (uint32_t));
- else
- for (idx2 = 0; idx2 < 256; ++idx2)
- ctype->map32[idx][idx2] = idx2;
+ ctype->map32_b[idx] = (uint32_t *) xmalloc (256 * sizeof (uint32_t));
- /* Copy values from collection. */
+ /* Copy values from collection. Default is identity mapping. */
for (idx2 = 0; idx2 < 256; ++idx2)
- if (ctype->map_collection[idx][idx2] != 0)
- ctype->map32[idx][idx2] = ctype->map_collection[idx][idx2];
-
- if (oldstyle_tables)
- while (idx2 < ctype->map_collection_act[idx])
- {
- if (ctype->map_collection[idx][idx2] != 0)
- ctype->map32[idx][ctype->charnames[idx2]] =
- ctype->map_collection[idx][idx2];
- ++idx2;
- }
+ ctype->map32_b[idx][idx2] =
+ (ctype->map_collection[idx][idx2] != 0
+ ? ctype->map_collection[idx][idx2]
+ : idx2);
}
- if (!oldstyle_tables)
+ for (nr = 0; nr < ctype->map_collection_nr; nr++)
{
- size_t nr;
+ struct wctrans_table t;
- for (nr = 0; nr < ctype->map_collection_nr; nr++)
- {
- struct wctrans_table t;
-
- t.p = 7;
- t.q = 9;
- wctrans_table_init (&t);
+ t.p = 7;
+ t.q = 9;
+ wctrans_table_init (&t);
- for (idx = 0; idx < ctype->map_collection_act[nr]; ++idx)
- if (ctype->map_collection[nr][idx] != 0)
- wctrans_table_add (&t, ctype->charnames[idx],
- ctype->map_collection[nr][idx]);
+ for (idx = 0; idx < ctype->map_collection_act[nr]; ++idx)
+ if (ctype->map_collection[nr][idx] != 0)
+ wctrans_table_add (&t, ctype->charnames[idx],
+ ctype->map_collection[nr][idx]);
- wctrans_table_finalize (&t);
+ wctrans_table_finalize (&t);
- if (verbose)
- fprintf (stderr, _("%s: table for map \"%s\": %lu bytes\n"),
- "LC_CTYPE", ctype->mapnames[nr],
- (unsigned long int) t.result_size);
+ if (verbose)
+ fprintf (stderr, _("%s: table for map \"%s\": %lu bytes\n"),
+ "LC_CTYPE", ctype->mapnames[nr],
+ (unsigned long int) t.result_size);
- ctype->map_3level[nr].iov_base = t.result;
- ctype->map_3level[nr].iov_len = t.result_size;
- }
+ ctype->map_3level[nr].iov_base = t.result;
+ ctype->map_3level[nr].iov_len = t.result_size;
}
/* Extra array for class and map names. */
@@ -3916,229 +3732,106 @@ Computing table size for character classes might take a while..."),
ctype->map_name_ptr = (uint32_t *) xmalloc (ctype->map_collection_nr
* sizeof (uint32_t));
- if (oldstyle_tables)
- {
- ctype->class_offset = 0; /* not really used */
- ctype->map_offset = 0; /* not really used */
- }
- else
- {
- ctype->class_offset = _NL_ITEM_INDEX (_NL_CTYPE_EXTRA_MAP_1);
- ctype->map_offset = ctype->class_offset + ctype->nr_charclass;
- }
+ ctype->class_offset = _NL_ITEM_INDEX (_NL_CTYPE_EXTRA_MAP_1);
+ ctype->map_offset = ctype->class_offset + ctype->nr_charclass;
/* Array for width information. Because the expected width are very
small we use only one single byte. This saves space. */
- if (oldstyle_tables)
- {
- width_table_size = (ctype->plane_size * ctype->plane_cnt + 3) & ~3ul;
- ctype->width = (unsigned char *) xmalloc (width_table_size);
-
- /* Initialize with -1. */
- memset (ctype->width, '\xff', width_table_size);
- if (charmap->width_rules != NULL)
- {
- size_t cnt;
-
- for (cnt = 0; cnt < charmap->nwidth_rules; ++cnt)
- {
- unsigned char bytes[charmap->mb_cur_max];
- int nbytes = charmap->width_rules[cnt].from->nbytes;
-
- /* We have the range of character for which the width is
- specified described using byte sequences of the multibyte
- charset. We have to convert this to UCS4 now. And we
- cannot simply convert the beginning and the end of the
- sequence, we have to iterate over the byte sequence and
- convert it for every single character. */
- memcpy (bytes, charmap->width_rules[cnt].from->bytes, nbytes);
-
- while (nbytes < charmap->width_rules[cnt].to->nbytes
- || memcmp (bytes, charmap->width_rules[cnt].to->bytes,
- nbytes) <= 0)
- {
- /* Find the UCS value for `bytes'. */
- int inner;
- uint32_t wch;
- struct charseq *seq =
- charmap_find_symbol (charmap, bytes, nbytes);
-
- if (seq == NULL)
- wch = ILLEGAL_CHAR_VALUE;
- else if (seq->ucs4 != UNINITIALIZED_CHAR_VALUE)
- wch = seq->ucs4;
- else
- wch = repertoire_find_value (ctype->repertoire, seq->name,
- strlen (seq->name));
-
- if (wch != ILLEGAL_CHAR_VALUE)
- {
- /* Store the value. */
- size_t nr = wch % ctype->plane_size;
- size_t depth = 0;
-
- while (ctype->names[nr + depth * ctype->plane_size] != wch)
- {
- ++depth;
- assert (depth < ctype->plane_cnt);
- }
-
- ctype->width[nr + depth * ctype->plane_size]
- = charmap->width_rules[cnt].width;
- }
-
- /* "Increment" the bytes sequence. */
- inner = nbytes - 1;
- while (inner >= 0 && bytes[inner] == 0xff)
- --inner;
-
- if (inner < 0)
- {
- /* We have to extend the byte sequence. */
- if (nbytes >= charmap->width_rules[cnt].to->nbytes)
- break;
-
- bytes[0] = 1;
- memset (&bytes[1], 0, nbytes);
- ++nbytes;
- }
- else
- {
- ++bytes[inner];
- while (++inner < nbytes)
- bytes[inner] = 0;
- }
- }
- }
- }
-
- /* Now set all the other characters of the character set to the
- default width. */
- curs = NULL;
- while (iterate_table (&charmap->char_table, &curs, &key, &len, &vdata) == 0)
- {
- struct charseq *data = (struct charseq *) vdata;
- size_t nr;
- size_t depth;
-
- if (data->ucs4 == UNINITIALIZED_CHAR_VALUE)
- data->ucs4 = repertoire_find_value (ctype->repertoire,
- data->name, len);
-
- if (data->ucs4 != ILLEGAL_CHAR_VALUE)
- {
- nr = data->ucs4 % ctype->plane_size;
- depth = 0;
+ {
+ struct wcwidth_table t;
- while (ctype->names[nr + depth * ctype->plane_size] != data->ucs4)
- {
- ++depth;
- assert (depth < ctype->plane_cnt);
- }
+ t.p = 7;
+ t.q = 9;
+ wcwidth_table_init (&t);
- if (ctype->width[nr + depth * ctype->plane_size]
- == (unsigned char) '\xff')
- ctype->width[nr + depth * ctype->plane_size] =
- charmap->width_default;
- }
- }
- }
- else
- {
- struct wcwidth_table t;
-
- t.p = 7;
- t.q = 9;
- wcwidth_table_init (&t);
+ /* First set all the characters of the character set to the default width. */
+ curs = NULL;
+ while (iterate_table (&charmap->char_table, &curs, &key, &len, &vdata) == 0)
+ {
+ struct charseq *data = (struct charseq *) vdata;
- /* First set all the characters of the character set to the default width. */
- curs = NULL;
- while (iterate_table (&charmap->char_table, &curs, &key, &len, &vdata) == 0)
- {
- struct charseq *data = (struct charseq *) vdata;
+ if (data->ucs4 == UNINITIALIZED_CHAR_VALUE)
+ data->ucs4 = repertoire_find_value (ctype->repertoire,
+ data->name, len);
- if (data->ucs4 == UNINITIALIZED_CHAR_VALUE)
- data->ucs4 = repertoire_find_value (ctype->repertoire,
- data->name, len);
+ if (data->ucs4 != ILLEGAL_CHAR_VALUE)
+ wcwidth_table_add (&t, data->ucs4, charmap->width_default);
+ }
- if (data->ucs4 != ILLEGAL_CHAR_VALUE)
- wcwidth_table_add (&t, data->ucs4, charmap->width_default);
- }
+ /* Now add the explicitly specified widths. */
+ if (charmap->width_rules != NULL)
+ {
+ size_t cnt;
- /* Now add the explicitly specified widths. */
- if (charmap->width_rules != NULL)
- {
- size_t cnt;
+ for (cnt = 0; cnt < charmap->nwidth_rules; ++cnt)
+ {
+ unsigned char bytes[charmap->mb_cur_max];
+ int nbytes = charmap->width_rules[cnt].from->nbytes;
+
+ /* We have the range of character for which the width is
+ specified described using byte sequences of the multibyte
+ charset. We have to convert this to UCS4 now. And we
+ cannot simply convert the beginning and the end of the
+ sequence, we have to iterate over the byte sequence and
+ convert it for every single character. */
+ memcpy (bytes, charmap->width_rules[cnt].from->bytes, nbytes);
+
+ while (nbytes < charmap->width_rules[cnt].to->nbytes
+ || memcmp (bytes, charmap->width_rules[cnt].to->bytes,
+ nbytes) <= 0)
+ {
+ /* Find the UCS value for `bytes'. */
+ int inner;
+ uint32_t wch;
+ struct charseq *seq =
+ charmap_find_symbol (charmap, bytes, nbytes);
- for (cnt = 0; cnt < charmap->nwidth_rules; ++cnt)
- {
- unsigned char bytes[charmap->mb_cur_max];
- int nbytes = charmap->width_rules[cnt].from->nbytes;
-
- /* We have the range of character for which the width is
- specified described using byte sequences of the multibyte
- charset. We have to convert this to UCS4 now. And we
- cannot simply convert the beginning and the end of the
- sequence, we have to iterate over the byte sequence and
- convert it for every single character. */
- memcpy (bytes, charmap->width_rules[cnt].from->bytes, nbytes);
-
- while (nbytes < charmap->width_rules[cnt].to->nbytes
- || memcmp (bytes, charmap->width_rules[cnt].to->bytes,
- nbytes) <= 0)
- {
- /* Find the UCS value for `bytes'. */
- int inner;
- uint32_t wch;
- struct charseq *seq =
- charmap_find_symbol (charmap, bytes, nbytes);
-
- if (seq == NULL)
- wch = ILLEGAL_CHAR_VALUE;
- else if (seq->ucs4 != UNINITIALIZED_CHAR_VALUE)
- wch = seq->ucs4;
- else
- wch = repertoire_find_value (ctype->repertoire, seq->name,
- strlen (seq->name));
+ if (seq == NULL)
+ wch = ILLEGAL_CHAR_VALUE;
+ else if (seq->ucs4 != UNINITIALIZED_CHAR_VALUE)
+ wch = seq->ucs4;
+ else
+ wch = repertoire_find_value (ctype->repertoire, seq->name,
+ strlen (seq->name));
- if (wch != ILLEGAL_CHAR_VALUE)
- /* Store the value. */
- wcwidth_table_add (&t, wch, charmap->width_rules[cnt].width);
+ if (wch != ILLEGAL_CHAR_VALUE)
+ /* Store the value. */
+ wcwidth_table_add (&t, wch, charmap->width_rules[cnt].width);
- /* "Increment" the bytes sequence. */
- inner = nbytes - 1;
- while (inner >= 0 && bytes[inner] == 0xff)
- --inner;
+ /* "Increment" the bytes sequence. */
+ inner = nbytes - 1;
+ while (inner >= 0 && bytes[inner] == 0xff)
+ --inner;
- if (inner < 0)
- {
- /* We have to extend the byte sequence. */
- if (nbytes >= charmap->width_rules[cnt].to->nbytes)
- break;
+ if (inner < 0)
+ {
+ /* We have to extend the byte sequence. */
+ if (nbytes >= charmap->width_rules[cnt].to->nbytes)
+ break;
- bytes[0] = 1;
- memset (&bytes[1], 0, nbytes);
- ++nbytes;
- }
- else
- {
- ++bytes[inner];
- while (++inner < nbytes)
- bytes[inner] = 0;
- }
- }
- }
- }
+ bytes[0] = 1;
+ memset (&bytes[1], 0, nbytes);
+ ++nbytes;
+ }
+ else
+ {
+ ++bytes[inner];
+ while (++inner < nbytes)
+ bytes[inner] = 0;
+ }
+ }
+ }
+ }
- wcwidth_table_finalize (&t);
+ wcwidth_table_finalize (&t);
- if (verbose)
- fprintf (stderr, _("%s: table for width: %lu bytes\n"),
- "LC_CTYPE", (unsigned long int) t.result_size);
+ if (verbose)
+ fprintf (stderr, _("%s: table for width: %lu bytes\n"),
+ "LC_CTYPE", (unsigned long int) t.result_size);
- ctype->width_3level.iov_base = t.result;
- ctype->width_3level.iov_len = t.result_size;
- }
+ ctype->width.iov_base = t.result;
+ ctype->width.iov_len = t.result_size;
+ }
/* Set MB_CUR_MAX. */
ctype->mb_cur_max = charmap->mb_cur_max;
diff --git a/locale/weightwc.h b/locale/weightwc.h
index 92bf47ab5f..5af88aed09 100644
--- a/locale/weightwc.h
+++ b/locale/weightwc.h
@@ -24,29 +24,9 @@ findidx (const wint_t **cpp)
int_fast32_t i;
const wint_t *cp;
wint_t ch;
- size_t cnt = 0;
ch = *(*cpp)++;
- if (size != 0)
- {
- /* Old locale format. */
- size_t idx;
-
- idx = ch % size;
- while (names[idx] != ch)
- {
- if (++cnt == layers)
- /* We didn't find the name. It is case for UNDEFINED. */
- return 0;
- idx += size;
- }
- i = table[idx];
- }
- else
- {
- /* New locale format. */
- i = collidx_table_lookup ((const char *) table, ch);
- }
+ i = collidx_table_lookup ((const char *) table, ch);
if (i >= 0)
/* This is an index into the weight table. Cool. */
diff --git a/posix/fnmatch.c b/posix/fnmatch.c
index d1777d179e..d0d70027d6 100644
--- a/posix/fnmatch.c
+++ b/posix/fnmatch.c
@@ -205,7 +205,6 @@ __wcschrnul (s, c)
# define STRCHR(S, C) strchr (S, C)
# define STRCHRNUL(S, C) __strchrnul (S, C)
# define STRCOLL(S1, S2) strcoll (S1, S2)
-# define SUFFIX MB
# include "fnmatch_loop.c"
@@ -224,7 +223,6 @@ __wcschrnul (s, c)
# define STRCHR(S, C) wcschr (S, C)
# define STRCHRNUL(S, C) __wcschrnul (S, C)
# define STRCOLL(S1, S2) wcscoll (S1, S2)
-# define SUFFIX WC
# define WIDE_CHAR_VERSION 1
# undef IS_CHAR_CLASS
diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c
index c933346877..6b20aa4304 100644
--- a/posix/fnmatch_loop.c
+++ b/posix/fnmatch_loop.c
@@ -32,13 +32,12 @@ FCT (pattern, string, no_leading_period, flags)
register const CHAR *p = pattern, *n = string;
register UCHAR c;
#ifdef _LIBC
+# if WIDE_CHAR_VERSION
+ const char *collseq = (const char *)
+ _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQWC);
+# else
const UCHAR *collseq = (const UCHAR *)
- _NL_CURRENT(LC_COLLATE, CONCAT(_NL_COLLATE_COLLSEQ,SUFFIX));
-# ifdef WIDE_CHAR_VERSION
- const wint_t *names = (const wint_t *)
- _NL_CURRENT (LC_COLLATE, _NL_COLLATE_NAMES);
- size_t size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_HASH_SIZE);
- size_t layers = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_HASH_LAYERS);
+ _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQMB);
# endif
#endif
@@ -260,33 +259,8 @@ FCT (pattern, string, no_leading_period, flags)
/* The following code is glibc specific but does
there a good job in speeding up the code since
we can avoid the btowc() call. */
- if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE) != 0)
- {
- /* Old locale format. */
-# if __BYTE_ORDER == __LITTLE_ENDIAN
- if ((wt & 0xf0ffff) == 0)
- {
- wt >>= 16;
- if ((__ctype_b[(UCHAR) *n] & wt) != 0)
- goto matched;
- }
-# else
- if (wt <= 0x800)
- {
- if ((__ctype_b[(UCHAR) *n] & wt) != 0)
- goto matched;
- }
-# endif
- else
- if (ISWCTYPE (BTOWC ((UCHAR) *n), wt))
- goto matched;
- }
- else
- {
- /* New locale format. */
- if (_ISCTYPE ((UCHAR) *n, wt))
- goto matched;
- }
+ if (_ISCTYPE ((UCHAR) *n, wt))
+ goto matched;
# else
if (ISWCTYPE (BTOWC ((UCHAR) *n), wt))
goto matched;
@@ -621,68 +595,17 @@ FCT (pattern, string, no_leading_period, flags)
# ifdef WIDE_CHAR_VERSION
/* Search in the `names' array for the characters. */
- if (size != 0)
- {
- /* Old locale format. */
- int idx;
- size_t cnt;
-
- idx = fn % size;
- cnt = 0;
- while (names[idx] != fn)
- {
- if (++cnt == layers)
- /* XXX We don't know anything about
- the character we are supposed to
- match. This means we are failing. */
- goto range_not_matched;
-
- idx += size;
- }
- fcollseq = collseq[idx];
- }
- else
- {
- /* New locale format. */
- fcollseq =
- collseq_table_lookup ((const char *) collseq, fn);
- if (fcollseq == ~((uint32_t) 0))
- /* XXX We don't know anything about
- the character we are supposed to
- match. This means we are failing. */
- goto range_not_matched;
- }
+ fcollseq = collseq_table_lookup (collseq, fn);
+ if (fcollseq == ~((uint32_t) 0))
+ /* XXX We don't know anything about the character
+ we are supposed to match. This means we are
+ failing. */
+ goto range_not_matched;
if (is_seqval)
lcollseq = cold;
else
- {
- if (size != 0)
- {
- /* Old locale format. */
- int idx;
- size_t cnt;
-
- idx = cold % size;
- cnt = 0;
- while (names[idx] != cold)
- {
- if (++cnt == layers)
- {
- idx = -1;
- break;
- }
- idx += size;
- }
-
- lcollseq =
- idx == -1 ? 0xffffffff : collseq[idx];
- }
- else
- /* New locale format. */
- lcollseq =
- collseq_table_lookup ((const char *) collseq, cold);
- }
+ lcollseq = collseq_table_lookup (collseq, cold);
# else
fcollseq = collseq[fn];
lcollseq = is_seqval ? cold : collseq[(UCHAR) cold];
@@ -843,46 +766,17 @@ FCT (pattern, string, no_leading_period, flags)
else
{
# ifdef WIDE_CHAR_VERSION
- if (size != 0)
+ hcollseq =
+ collseq_table_lookup (collseq, cend);
+ if (hcollseq == ~((uint32_t) 0))
{
- /* Old locale format. */
- int idx;
- size_t cnt;
+ /* Hum, no information about the upper
+ bound. The matching succeeds if the
+ lower bound is matched exactly. */
+ if (lcollseq != fcollseq)
+ goto range_not_matched;
- idx = cend % size;
- cnt = 0;
- while (names[idx] != cend)
- {
- if (++cnt == layers)
- {
- /* Hum, no information about the
- upper bound. The matching
- succeeds if the lower bound is
- matched exactly. */
- if (lcollseq != fcollseq)
- goto range_not_matched;
-
- goto matched;
- }
- }
- hcollseq = collseq[idx];
- }
- else
- {
- /* New locale format. */
- hcollseq =
- collseq_table_lookup ((const char *) collseq, cend);
- if (hcollseq == ~((uint32_t) 0))
- {
- /* Hum, no information about the
- upper bound. The matching succeeds
- if the lower bound is matched
- exactly. */
- if (lcollseq != fcollseq)
- goto range_not_matched;
-
- goto matched;
- }
+ goto matched;
}
# else
hcollseq = collseq[cend];
@@ -1025,4 +919,3 @@ FCT (pattern, string, no_leading_period, flags)
#undef STRCOLL
#undef L
#undef BTOWC
-#undef SUFFIX
diff --git a/string/strcoll.c b/string/strcoll.c
index 0df5752e50..14b2039478 100644
--- a/string/strcoll.c
+++ b/string/strcoll.c
@@ -96,11 +96,6 @@ STRCOLL (s1, s2, l)
int seq1len;
int seq2len;
int use_malloc;
-#ifdef WIDE_CHAR_VERSION
- size_t size;
- size_t layers;
- const wint_t *names;
-#endif
#include WEIGHT_H
@@ -118,12 +113,6 @@ STRCOLL (s1, s2, l)
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_EXTRA,SUFFIX))].string;
indirect = (const int32_t *)
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_INDIRECT,SUFFIX))].string;
-# ifdef WIDE_CHAR_VERSION
- names = (const wint_t *)
- current->values[_NL_ITEM_INDEX (_NL_COLLATE_NAMES)].string;
- size = current->values[_NL_ITEM_INDEX (_NL_COLLATE_HASH_SIZE)].word;
- layers = current->values[_NL_ITEM_INDEX (_NL_COLLATE_HASH_LAYERS)].word;
-# endif
#else
rulesets = (const unsigned char *)
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_RULESETS);
@@ -135,22 +124,13 @@ STRCOLL (s1, s2, l)
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_EXTRA,SUFFIX));
indirect = (const int32_t *)
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_INDIRECT,SUFFIX));
-# ifdef WIDE_CHAR_VERSION
- names = (const wint_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_NAMES);
- size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_HASH_SIZE);
- layers = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_HASH_LAYERS);
-# endif
#endif
use_malloc = 0;
assert (((uintptr_t) table) % sizeof (table[0]) == 0);
assert (((uintptr_t) weights) % sizeof (weights[0]) == 0);
- assert (((uintptr_t) weights) % sizeof (weights[0]) == 0);
assert (((uintptr_t) extra) % sizeof (extra[0]) == 0);
assert (((uintptr_t) indirect) % sizeof (indirect[0]) == 0);
-#ifdef WIDE_CHAR_VERSION
- assert (((uintptr_t) names) % sizeof (names[0]) == 0);
-#endif
/* We need this a few times. */
s1len = STRLEN (s1);
diff --git a/string/strxfrm.c b/string/strxfrm.c
index b655daf9e4..b9d320922f 100644
--- a/string/strxfrm.c
+++ b/string/strxfrm.c
@@ -17,6 +17,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <assert.h>
#include <langinfo.h>
#include <stddef.h>
#include <stdint.h>
@@ -114,11 +115,6 @@ STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
size_t idxmax;
size_t idxcnt;
int use_malloc;
-#ifdef WIDE_CHAR_VERSION
- size_t size;
- size_t layers;
- const wint_t *names;
-#endif
#include WEIGHT_H
@@ -141,12 +137,6 @@ STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_EXTRA,SUFFIX))].string;
indirect = (const int32_t *)
current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_INDIRECT,SUFFIX))].string;
-# ifdef WIDE_CHAR_VERSION
- names = (const wint_t *)
- current->values[_NL_ITEM_INDEX (_NL_COLLATE_NAMES)].string;
- size = current->values[_NL_ITEM_INDEX (_NL_COLLATE_HASH_SIZE)].word;
- layers = current->values[_NL_ITEM_INDEX (_NL_COLLATE_HASH_LAYERS)].word;
-# endif
#else
rulesets = (const unsigned char *)
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_RULESETS);
@@ -158,14 +148,14 @@ STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_EXTRA,SUFFIX));
indirect = (const int32_t *)
_NL_CURRENT (LC_COLLATE, CONCAT(_NL_COLLATE_INDIRECT,SUFFIX));
-# ifdef WIDE_CHAR_VERSION
- names = (const wint_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_NAMES);
- size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_HASH_SIZE);
- layers = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_HASH_LAYERS);
-# endif
#endif
use_malloc = 0;
+ assert (((uintptr_t) table) % sizeof (table[0]) == 0);
+ assert (((uintptr_t) weights) % sizeof (weights[0]) == 0);
+ assert (((uintptr_t) extra) % sizeof (extra[0]) == 0);
+ assert (((uintptr_t) indirect) % sizeof (indirect[0]) == 0);
+
/* Handle an empty string as a special case. */
if (srclen == 0)
{
diff --git a/wcsmbs/wcwidth.h b/wcsmbs/wcwidth.h
index 86a2f216bd..d13a5f59ae 100644
--- a/wcsmbs/wcwidth.h
+++ b/wcsmbs/wcwidth.h
@@ -20,48 +20,25 @@
#include <wchar.h>
#include <wctype.h>
-#include "../wctype/cname-lookup.h"
#include "../wctype/wchar-lookup.h"
/* Tables containing character property information. */
extern const char *__ctype32_wctype[12];
-/* Tables containing width information. */
-extern unsigned char *__ctype_width;
+/* Table containing width information. */
extern const char *__ctype32_width;
-/* If the program is compiled without optimization the following declaration
- is not visible in the header. */
-extern unsigned int *__ctype32_b;
-
static __inline int
internal_wcwidth (wint_t wc)
{
+ unsigned char res;
+
if (wc == L'\0')
return 0;
- if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE) != 0)
- {
- /* Old locale format. */
- size_t idx;
- unsigned char res;
-
- idx = cname_lookup (wc);
- if (idx == ~((size_t) 0) || (__ctype32_b[idx] & _ISwprint) == 0)
- return -1;
-
- res = __ctype_width[idx];
- return res == (unsigned char) '\xff' ? -1 : (int) res;
- }
- else
- {
- /* New locale format. */
- unsigned char res;
-
- if (wctype_table_lookup (__ctype32_wctype[__ISwprint], wc) == 0)
- return -1;
+ if (wctype_table_lookup (__ctype32_wctype[__ISwprint], wc) == 0)
+ return -1;
- res = wcwidth_table_lookup (__ctype32_width, wc);
- return res == (unsigned char) '\xff' ? -1 : (int) res;
- }
+ res = wcwidth_table_lookup (__ctype32_width, wc);
+ return res == (unsigned char) '\xff' ? -1 : (int) res;
}
diff --git a/wctype/Makefile b/wctype/Makefile
index 78f66e7aed..c1a2de7e6b 100644
--- a/wctype/Makefile
+++ b/wctype/Makefile
@@ -22,10 +22,9 @@
subdir := wctype
headers := wctype.h
-distribute := cname-lookup.h wchar-lookup.h
-routines := wcfuncs wctype iswctype wctrans towctrans wcextra \
- wcfuncs_l wctype_l iswctype_l wctrans_l towctrans_l \
- wcextra_l
+distribute := wchar-lookup.h
+routines := wcfuncs wctype iswctype wctrans towctrans \
+ wcfuncs_l wctype_l iswctype_l wctrans_l towctrans_l
tests := test_wctype test_wcfuncs
diff --git a/wctype/cname-lookup.h b/wctype/cname-lookup.h
deleted file mode 100644
index 62111b60d1..0000000000
--- a/wctype/cname-lookup.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#include <endian.h>
-#include "../locale/localeinfo.h"
-
-/* Some words on the runtime of this functions. Although there is a
- loop in the function the runtime is asymptotically quasi constant.
- The reason is that even for the largest character sets HASH_LAYERS
- will not grow beyond 15 (a guess!). */
-#ifndef USE_IN_EXTENDED_LOCALE_MODEL
-static __inline size_t
-cname_lookup (wint_t wc)
-#else
-static __inline size_t
-cname_lookup (wint_t wc, __locale_t locale)
-#endif
-{
- unsigned int hash_size, hash_layers;
- size_t result, cnt;
-
-#ifndef USE_IN_EXTENDED_LOCALE_MODEL
- extern unsigned int *__ctype_names;
- hash_size = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE);
- hash_layers = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_LAYERS);
-
-#else
- struct locale_data *current = locale->__locales[LC_CTYPE];
- unsigned int *__ctype_names =
- (unsigned int *) current->values[_NL_ITEM_INDEX (_NL_CTYPE_NAMES)].string;
- hash_size =
- current->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE)].word;
- hash_layers =
- current->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_LAYERS)].word;
-#endif
-
- result = wc % hash_size;
- for (cnt = 0; cnt < hash_layers; ++cnt)
- {
- if (__ctype_names[result] == wc)
- break;
- result += hash_size;
- }
-
- return cnt < hash_layers ? result : ~((size_t) 0);
-}
diff --git a/wctype/iswctype.c b/wctype/iswctype.c
index 60475d0192..82d7ad14c4 100644
--- a/wctype/iswctype.c
+++ b/wctype/iswctype.c
@@ -20,36 +20,17 @@
#include <ctype.h>
#include <wctype.h>
-#include "cname-lookup.h"
#include "wchar-lookup.h"
-extern unsigned int *__ctype32_b;
-
-
int
__iswctype (wint_t wc, wctype_t desc)
{
- if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE) != 0)
- {
- /* Old locale format. */
- size_t idx;
-
- idx = cname_lookup (wc);
- if (idx == ~((size_t) 0))
- return 0;
-
- return __ctype32_b[idx] & desc;
- }
- else
- {
- /* If the user passes in an invalid DESC valid (the one returned from
- `wctype' in case of an error) simply return 0. */
- if (desc == (wctype_t) 0)
- return 0;
-
- /* New locale format. */
- return wctype_table_lookup ((const char *) desc, wc);
- }
+ /* If the user passes in an invalid DESC valid (the one returned from
+ `wctype' in case of an error) simply return 0. */
+ if (desc == (wctype_t) 0)
+ return 0;
+
+ return wctype_table_lookup ((const char *) desc, wc);
}
weak_alias (__iswctype, iswctype)
diff --git a/wctype/iswctype_l.c b/wctype/iswctype_l.c
index 192001e033..3bc25fdb6f 100644
--- a/wctype/iswctype_l.c
+++ b/wctype/iswctype_l.c
@@ -21,36 +21,16 @@
#include <wctype.h>
#define USE_IN_EXTENDED_LOCALE_MODEL 1
-#include "cname-lookup.h"
#include "wchar-lookup.h"
int
__iswctype_l (wint_t wc, wctype_t desc, __locale_t locale)
{
- if (locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE)].word != 0)
- {
- /* Old locale format. */
- const uint32_t *class32_b;
- size_t idx;
-
- idx = cname_lookup (wc, locale);
- if (idx == ~((size_t) 0))
- return 0;
-
- class32_b = (uint32_t *)
- locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS32)].string;
-
- return class32_b[idx] & desc;
- }
- else
- {
- /* If the user passes in an invalid DESC valid (the one returned from
- `__wctype_l' in case of an error) simply return 0. */
- if (desc == (wctype_t) 0)
- return 0;
-
- /* New locale format. */
- return wctype_table_lookup ((const char *) desc, wc);
- }
+ /* If the user passes in an invalid DESC valid (the one returned from
+ `__wctype_l' in case of an error) simply return 0. */
+ if (desc == (wctype_t) 0)
+ return 0;
+
+ return wctype_table_lookup ((const char *) desc, wc);
}
diff --git a/wctype/towctrans.c b/wctype/towctrans.c
index 498417b80a..86814477de 100644
--- a/wctype/towctrans.c
+++ b/wctype/towctrans.c
@@ -20,7 +20,6 @@
#include <wctype.h>
/* Define the lookup function. */
-#include "cname-lookup.h"
#include "wchar-lookup.h"
wint_t
@@ -31,22 +30,6 @@ __towctrans (wint_t wc, wctrans_t desc)
if (desc == (wctrans_t) 0)
return wc;
- if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE) != 0)
- {
- /* Old locale format. */
- size_t idx;
-
- idx = cname_lookup (wc);
- if (idx == ~((size_t) 0))
- /* Character is not known. Default action is to simply return it. */
- return wc;
-
- return (wint_t) desc[idx];
- }
- else
- {
- /* New locale format. */
- return wctrans_table_lookup ((const char *) desc, wc);
- }
+ return wctrans_table_lookup ((const char *) desc, wc);
}
weak_alias (__towctrans, towctrans)
diff --git a/wctype/towctrans_l.c b/wctype/towctrans_l.c
index e3624441ca..ae8f2ac3f0 100644
--- a/wctype/towctrans_l.c
+++ b/wctype/towctrans_l.c
@@ -21,7 +21,6 @@
/* Define the lookup function. */
#define USE_IN_EXTENDED_LOCALE_MODEL 1
-#include "cname-lookup.h"
#include "wchar-lookup.h"
wint_t
@@ -32,21 +31,5 @@ __towctrans_l (wint_t wc, wctrans_t desc, __locale_t locale)
if (desc == (wctrans_t) 0)
return wc;
- if (locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE)].word != 0)
- {
- /* Old locale format. */
- size_t idx;
-
- idx = cname_lookup (wc, locale);
- if (idx == ~((size_t) 0))
- /* Character is not known. Default action is to simply return it. */
- return wc;
-
- return (wint_t) desc[idx];
- }
- else
- {
- /* New locale format. */
- return wctrans_table_lookup ((const char *) desc, wc);
- }
+ return wctrans_table_lookup ((const char *) desc, wc);
}
diff --git a/wctype/wcextra.c b/wctype/wcextra.c
deleted file mode 100644
index 581c6807de..0000000000
--- a/wctype/wcextra.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Additional non standardized wide character classification functions.
- Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#include <stdint.h>
-#define __NO_WCTYPE 1
-#include <wctype.h>
-
-#include "cname-lookup.h"
-#include "wchar-lookup.h"
-
-/* If the program is compiled without optimization the following declaration
- is not visible in the header. */
-extern unsigned int *__ctype32_b;
-
-/* This is not exported. */
-extern const char *__ctype32_wctype[12];
-
-int
-(iswblank) (wint_t wc)
-{
- if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE) != 0)
- {
- /* Old locale format. */
- size_t idx;
-
- idx = cname_lookup (wc);
- if (idx == ~((size_t) 0))
- return 0;
-
- return __ctype32_b[idx] & _ISwblank;
- }
- else
- {
- /* New locale format. */
- return wctype_table_lookup (__ctype32_wctype[__ISwblank], wc);
- }
-}
diff --git a/wctype/wcextra_l.c b/wctype/wcextra_l.c
deleted file mode 100644
index 8fc9c2733d..0000000000
--- a/wctype/wcextra_l.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Additional non standardized wide character classification functions.
- Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#include <stdint.h>
-#define __NO_WCTYPE 1
-#include <wctype.h>
-
-#define USE_IN_EXTENDED_LOCALE_MODEL 1
-#include "cname-lookup.h"
-#include "wchar-lookup.h"
-
-
-int
-(__iswblank_l) (wint_t wc, __locale_t locale)
-{
- if (locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE)].word != 0)
- {
- /* Old locale format. */
- const uint32_t *class32_b;
- size_t idx;
-
- idx = cname_lookup (wc, locale);
- if (idx == ~((size_t) 0))
- return 0;
-
- class32_b = (uint32_t *)
- locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS32)].string;
-
- return class32_b[idx] & _ISwbit (__ISwblank);
- }
- else
- {
- /* New locale format. */
- size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS_OFFSET)].word + __ISwblank;
- const char *desc = locale->__locales[LC_CTYPE]->values[i].string;
- return wctype_table_lookup (desc, wc);
- }
-}
diff --git a/wctype/wcfuncs.c b/wctype/wcfuncs.c
index ea697c2729..bed70b37de 100644
--- a/wctype/wcfuncs.c
+++ b/wctype/wcfuncs.c
@@ -16,20 +16,12 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#define __NO_WCTYPE
#include <wctype.h>
-#include <ctype.h> /* For __ctype_tolower and __ctype_toupper. */
+#include <locale/localeinfo.h>
-#include "cname-lookup.h"
#include "wchar-lookup.h"
-/* If the program is compiled without optimization the following declaration
- is not visible in the header. */
-extern unsigned int *__ctype32_b;
-
/* These are not exported. */
-extern const uint32_t *__ctype32_toupper;
-extern const uint32_t *__ctype32_tolower;
extern const char *__ctype32_wctype[12];
extern const char *__ctype32_wctrans[2];
@@ -39,22 +31,7 @@ extern const char *__ctype32_wctrans[2];
int \
__##name (wint_t wc) \
{ \
- if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE) != 0) \
- { \
- /* Old locale format. */ \
- size_t idx; \
- \
- idx = cname_lookup (wc); \
- if (idx == ~((size_t) 0)) \
- return 0; \
- \
- return __ctype32_b[idx] & _ISwbit (type); \
- } \
- else \
- { \
- /* New locale format. */ \
- return wctype_table_lookup (__ctype32_wctype[type], wc); \
- } \
+ return wctype_table_lookup (__ctype32_wctype[type], wc); \
} \
weak_alias (__##name, name)
@@ -62,6 +39,8 @@ extern const char *__ctype32_wctrans[2];
func (iswalnum, __ISwalnum)
#undef iswalpha
func (iswalpha, __ISwalpha)
+#undef iswblank
+func (iswblank, __ISwblank)
#undef iswcntrl
func (iswcntrl, __ISwcntrl)
#undef iswdigit
@@ -85,44 +64,12 @@ wint_t
(towlower) (wc)
wint_t wc;
{
- if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE) != 0)
- {
- /* Old locale format. */
- size_t idx;
-
- idx = cname_lookup (wc);
- if (idx == ~((size_t) 0))
- /* Character is not known. Default action is to simply return it. */
- return wc;
-
- return (wint_t) __ctype32_tolower[idx];
- }
- else
- {
- /* New locale format. */
- return wctrans_table_lookup (__ctype32_wctrans[__TOW_tolower], wc);
- }
+ return wctrans_table_lookup (__ctype32_wctrans[__TOW_tolower], wc);
}
wint_t
(towupper) (wc)
wint_t wc;
{
- if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE) != 0)
- {
- /* Old locale format. */
- size_t idx;
-
- idx = cname_lookup (wc);
- if (idx == ~((size_t) 0))
- /* Character is not known. Default action is to simply return it. */
- return wc;
-
- return (wint_t) __ctype32_toupper[idx];
- }
- else
- {
- /* New locale format. */
- return wctrans_table_lookup (__ctype32_wctrans[__TOW_toupper], wc);
- }
+ return wctrans_table_lookup (__ctype32_wctrans[__TOW_toupper], wc);
}
diff --git a/wctype/wcfuncs_l.c b/wctype/wcfuncs_l.c
index 5ef543cc47..a552895316 100644
--- a/wctype/wcfuncs_l.c
+++ b/wctype/wcfuncs_l.c
@@ -16,12 +16,11 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#define __NO_WCTYPE
#include <wctype.h>
#include <stdint.h>
+#include <locale/localeinfo.h>
#define USE_IN_EXTENDED_LOCALE_MODEL
-#include "cname-lookup.h"
#include "wchar-lookup.h"
/* Provide real-function versions of all the wctype macros. */
@@ -29,32 +28,14 @@
#define func(name, type) \
int name (wint_t wc, __locale_t locale) \
{ \
- if (locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE)].word != 0) \
- { \
- /* Old locale format. */ \
- const uint32_t *class32_b; \
- size_t idx; \
- \
- idx = cname_lookup (wc, locale); \
- if (idx == ~((size_t) 0)) \
- return 0; \
- \
- class32_b = (uint32_t *) \
- locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS32)].string; \
- \
- return class32_b[idx] & _ISwbit (type); \
- } \
- else \
- { \
- /* New locale format. */ \
- size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS_OFFSET)].word + type; \
- const char *desc = locale->__locales[LC_CTYPE]->values[i].string; \
- return wctype_table_lookup (desc, wc); \
- } \
+ size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS_OFFSET)].word + type; \
+ const char *desc = locale->__locales[LC_CTYPE]->values[i].string; \
+ return wctype_table_lookup (desc, wc); \
}
func (__iswalnum_l, __ISwalnum)
func (__iswalpha_l, __ISwalpha)
+func (__iswblank_l, __ISwblank)
func (__iswcntrl_l, __ISwcntrl)
func (__iswdigit_l, __ISwdigit)
func (__iswlower_l, __ISwlower)
@@ -68,53 +49,15 @@ func (__iswxdigit_l, __ISwxdigit)
wint_t
(__towlower_l) (wint_t wc, __locale_t locale)
{
- if (locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE)].word != 0)
- {
- /* Old locale format. */
- const int32_t *class32_tolower;
- size_t idx;
-
- idx = cname_lookup (wc, locale);
- if (idx == ~((size_t) 0))
- return 0;
-
- class32_tolower = (const int32_t *)
- locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_TOLOWER32)].string;
-
- return class32_tolower[idx];
- }
- else
- {
- /* New locale format. */
- size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET)].word + __TOW_tolower;
- const char *desc = locale->__locales[LC_CTYPE]->values[i].string;
- return wctrans_table_lookup (desc, wc);
- }
+ size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET)].word + __TOW_tolower;
+ const char *desc = locale->__locales[LC_CTYPE]->values[i].string;
+ return wctrans_table_lookup (desc, wc);
}
wint_t
(__towupper_l) (wint_t wc, __locale_t locale)
{
- if (locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE)].word != 0)
- {
- /* Old locale format. */
- const int32_t *class32_toupper;
- size_t idx;
-
- idx = cname_lookup (wc, locale);
- if (idx == ~((size_t) 0))
- return 0;
-
- class32_toupper = (const int32_t *)
- locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_TOUPPER32)].string;
-
- return class32_toupper[idx];
- }
- else
- {
- /* New locale format. */
- size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET)].word + __TOW_toupper;
- const char *desc = locale->__locales[LC_CTYPE]->values[i].string;
- return wctrans_table_lookup (desc, wc);
- }
+ size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET)].word + __TOW_toupper;
+ const char *desc = locale->__locales[LC_CTYPE]->values[i].string;
+ return wctrans_table_lookup (desc, wc);
}
diff --git a/wctype/wchar-lookup.h b/wctype/wchar-lookup.h
index 1d08492035..6941d21479 100644
--- a/wctype/wchar-lookup.h
+++ b/wctype/wchar-lookup.h
@@ -17,9 +17,11 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <stdint.h>
+
/* Tables indexed by a wide character are compressed through the use
of a multi-level lookup. The compression effect comes from blocks
- that don't need particular data and from block that can share their
+ that don't need particular data and from blocks that can share their
data. */
/* Bit tables are accessed by cutting wc in four blocks of bits:
diff --git a/wctype/wctrans.c b/wctype/wctrans.c
index 6c61c0b630..c35fe0ec17 100644
--- a/wctype/wctrans.c
+++ b/wctype/wctrans.c
@@ -17,21 +17,17 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <ctype.h>
#include <inttypes.h>
#include <string.h>
#include <wctype.h>
#include "../locale/localeinfo.h"
-/* These are not exported. */
-extern const uint32_t *__ctype32_toupper;
-extern const uint32_t *__ctype32_tolower;
-
wctrans_t
wctrans (const char *property)
{
const char *names;
size_t cnt;
+ size_t i;
names = _NL_CURRENT (LC_CTYPE, _NL_CTYPE_MAP_NAMES);
cnt = 0;
@@ -47,21 +43,6 @@ wctrans (const char *property)
if (names[0] == '\0')
return 0;
- if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE) != 0)
- {
- /* Old locale format. */
- if (cnt == __TOW_toupper)
- return (wctrans_t) __ctype32_toupper;
- else if (cnt == __TOW_tolower)
- return (wctrans_t) __ctype32_tolower;
-
- /* We have to search the table. */
- return (wctrans_t) (const int32_t *) _NL_CURRENT (LC_CTYPE, _NL_NUM_LC_CTYPE + cnt - 2);
- }
- else
- {
- /* New locale format. */
- size_t i = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_OFFSET) + cnt;
- return (wctrans_t) _nl_current_LC_CTYPE->values[i].string;
- }
+ i = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_OFFSET) + cnt;
+ return (wctrans_t) _nl_current_LC_CTYPE->values[i].string;
}
diff --git a/wctype/wctrans_l.c b/wctype/wctrans_l.c
index 3b8b6050b5..94e2451926 100644
--- a/wctype/wctrans_l.c
+++ b/wctype/wctrans_l.c
@@ -25,6 +25,7 @@ __wctrans_l (const char *property, __locale_t locale)
{
const char *names;
size_t cnt;
+ size_t i;
names = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_NAMES)].string;
cnt = 0;
@@ -40,21 +41,6 @@ __wctrans_l (const char *property, __locale_t locale)
if (names[0] == '\0')
return 0;
- if (locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE)].word == 0)
- {
- /* Old locale format. */
- if (cnt == __TOW_toupper)
- return (wctrans_t) locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_TOUPPER32)].string;
- else if (cnt == __TOW_tolower)
- return (wctrans_t) locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_TOLOWER32)].string;
-
- /* We have to search the table. */
- return (wctrans_t) (const int32_t *) locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_NUM_LC_CTYPE + cnt - 2)].string;
- }
- else
- {
- /* New locale format. */
- size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET)].word + cnt;
- return (wctrans_t) locale->__locales[LC_CTYPE]->values[i].string;
- }
+ i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_MAP_OFFSET)].word + cnt;
+ return (wctrans_t) locale->__locales[LC_CTYPE]->values[i].string;
}
diff --git a/wctype/wctype.c b/wctype/wctype.c
index 476707cfd2..7f2112e6ff 100644
--- a/wctype/wctype.c
+++ b/wctype/wctype.c
@@ -28,6 +28,7 @@ __wctype (const char *property)
const char *names;
unsigned int result;
size_t proplen = strlen (property);
+ size_t i;
names = _NL_CURRENT (LC_CTYPE, _NL_CTYPE_CLASS_NAMES);
for (result = 0; ; result++)
@@ -42,22 +43,7 @@ __wctype (const char *property)
return 0;
}
- if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_HASH_SIZE) != 0)
- {
- /* Old locale format. */
-#if __BYTE_ORDER == __BIG_ENDIAN
- return 1 << result;
-#else
-# define SWAPU32(w) \
- (((w) << 24) | (((w) & 0xff00) << 8) | (((w) >> 8) & 0xff00) | ((w) >> 24))
- return 1 << (result ^ 0x18); /* = SWAPU32 (1 << result); */
-#endif
- }
- else
- {
- /* New locale format. */
- size_t i = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_CLASS_OFFSET) + result;
- return (wctype_t) _nl_current_LC_CTYPE->values[i].string;
- }
+ i = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_CLASS_OFFSET) + result;
+ return (wctype_t) _nl_current_LC_CTYPE->values[i].string;
}
weak_alias (__wctype, wctype)
diff --git a/wctype/wctype_l.c b/wctype/wctype_l.c
index fdbd1ff451..72d79659dd 100644
--- a/wctype/wctype_l.c
+++ b/wctype/wctype_l.c
@@ -28,6 +28,7 @@ __wctype_l (const char *property, __locale_t locale)
const char *names;
unsigned int result;
size_t proplen = strlen (property);
+ size_t i;
names = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS_NAMES)].string;
for (result = 0; ; result++)
@@ -42,21 +43,6 @@ __wctype_l (const char *property, __locale_t locale)
return 0;
}
- if (locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_HASH_SIZE)].word == 0)
- {
- /* Old locale format. */
-#if __BYTE_ORDER == __BIG_ENDIAN
- return 1 << result;
-#else
-# define SWAPU32(w) \
- (((w) << 24) | (((w) & 0xff00) << 8) | (((w) >> 8) & 0xff00) | ((w) >> 24))
- return 1 << (result ^ 0x18); /* = SWAPU32 (1 << result); */
-#endif
- }
- else
- {
- /* New locale format. */
- size_t i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS_OFFSET)].word + result;
- return (wctype_t) locale->__locales[LC_CTYPE]->values[i].string;
- }
+ i = locale->__locales[LC_CTYPE]->values[_NL_ITEM_INDEX (_NL_CTYPE_CLASS_OFFSET)].word + result;
+ return (wctype_t) locale->__locales[LC_CTYPE]->values[i].string;
}