aboutsummaryrefslogtreecommitdiff
path: root/locale
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 /locale
parentaebb1faa198634a318bc14cf1e577f5806fafc38 (diff)
downloadglibc-4c7d276eb123523c66c1d8cbf7dbb10fac674cd2.zip
glibc-4c7d276eb123523c66c1d8cbf7dbb10fac674cd2.tar.gz
glibc-4c7d276eb123523c66c1d8cbf7dbb10fac674cd2.tar.bz2
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.
Diffstat (limited to 'locale')
-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
8 files changed, 286 insertions, 896 deletions
diff --git a/locale/C-collate.c b/locale/C-collate.c
index a0ba0ff..964ea50 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 4f8e204..f9eee1c 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 95873d0..2ec45e4 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 6a94a87..494b14e 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 4b40b8a..bf7b525 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 6513d89..1bfce61 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 1f40fe8..c29b980 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 92bf47a..5af88ae 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. */