mirror of git://sourceware.org/git/glibc.git
(struct element_t): Add mbseqorder and wcseqorder members. (struct locale_collate_t): Likewise. (collate_finish): Assign collation sequence value to each character. Create tables for output. (collate_output): Write out tables with collation sequence information
This commit is contained in:
parent
fff82885d2
commit
b7cbee1cb0
|
|
@ -87,7 +87,7 @@ struct element_t
|
||||||
weight computation.
|
weight computation.
|
||||||
|
|
||||||
XXX The type here restricts the number of levels to 32. It could
|
XXX The type here restricts the number of levels to 32. It could
|
||||||
we changed if necessary but I doubt this is necessary. */
|
be changed if necessary but I doubt this is necessary. */
|
||||||
unsigned int used_in_level;
|
unsigned int used_in_level;
|
||||||
|
|
||||||
struct element_list_t *weights;
|
struct element_list_t *weights;
|
||||||
|
|
@ -95,6 +95,11 @@ struct element_t
|
||||||
/* Nonzero if this is a real character definition. */
|
/* Nonzero if this is a real character definition. */
|
||||||
int is_character;
|
int is_character;
|
||||||
|
|
||||||
|
/* Order of the character in the sequence. This information will
|
||||||
|
be used in range expressions. */
|
||||||
|
int mbseqorder;
|
||||||
|
int wcseqorder;
|
||||||
|
|
||||||
/* Where does the definition come from. */
|
/* Where does the definition come from. */
|
||||||
const char *file;
|
const char *file;
|
||||||
size_t line;
|
size_t line;
|
||||||
|
|
@ -186,6 +191,10 @@ struct locale_collate_t
|
||||||
/* Arrays with heads of the list for each of the leading bytes in
|
/* Arrays with heads of the list for each of the leading bytes in
|
||||||
the multibyte sequences. */
|
the multibyte sequences. */
|
||||||
struct element_t **wcheads;
|
struct element_t **wcheads;
|
||||||
|
|
||||||
|
/* The arrays with the collation sequence order. */
|
||||||
|
unsigned char mbseqorder[256];
|
||||||
|
uint32_t *wcseqorder;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1401,6 +1410,8 @@ collate_finish (struct localedef_t *locale, struct charmap_t *charmap)
|
||||||
struct locale_collate_t *collate = locale->categories[LC_COLLATE].collate;
|
struct locale_collate_t *collate = locale->categories[LC_COLLATE].collate;
|
||||||
int mbact[nrules];
|
int mbact[nrules];
|
||||||
int wcact;
|
int wcact;
|
||||||
|
int mbseqact;
|
||||||
|
int wcseqact;
|
||||||
struct element_t *runp;
|
struct element_t *runp;
|
||||||
int i;
|
int i;
|
||||||
int need_undefined = 0;
|
int need_undefined = 0;
|
||||||
|
|
@ -1487,6 +1498,8 @@ collate_finish (struct localedef_t *locale, struct charmap_t *charmap)
|
||||||
for (i = 0; i < nrules; ++i)
|
for (i = 0; i < nrules; ++i)
|
||||||
mbact[i] = 2;
|
mbact[i] = 2;
|
||||||
wcact = 2;
|
wcact = 2;
|
||||||
|
mbseqact = 0;
|
||||||
|
wcseqact = 0;
|
||||||
runp = collate->start;
|
runp = collate->start;
|
||||||
while (runp != NULL)
|
while (runp != NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -1559,6 +1572,14 @@ collate_finish (struct localedef_t *locale, struct charmap_t *charmap)
|
||||||
++nr_wide_elems;
|
++nr_wide_elems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (runp->is_character)
|
||||||
|
{
|
||||||
|
if (runp->nmbs == 1)
|
||||||
|
collate->mbseqorder[((unsigned char *) runp->mbs)[0]] = mbseqact++;
|
||||||
|
|
||||||
|
runp->wcseqorder = wcseqact++;
|
||||||
|
}
|
||||||
|
|
||||||
/* Up to the next entry. */
|
/* Up to the next entry. */
|
||||||
runp = runp->next;
|
runp = runp->next;
|
||||||
}
|
}
|
||||||
|
|
@ -1668,6 +1689,14 @@ Computing table size for collation table might take a while..."),
|
||||||
* collate->plane_cnt
|
* collate->plane_cnt
|
||||||
* sizeof (struct element_t *)));
|
* 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)));
|
||||||
|
|
||||||
/* Start adding. */
|
/* Start adding. */
|
||||||
runp = collate->start;
|
runp = collate->start;
|
||||||
while (runp != NULL)
|
while (runp != NULL)
|
||||||
|
|
@ -1689,6 +1718,9 @@ Computing table size for collation table might take a while..."),
|
||||||
idx += collate->plane_size;
|
idx += collate->plane_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Insert the collation sequence value. */
|
||||||
|
collate->wcseqorder[idx] = runp->wcseqorder;
|
||||||
|
|
||||||
/* Find the point where to insert in the list. */
|
/* Find the point where to insert in the list. */
|
||||||
eptr = &collate->wcheads[idx];
|
eptr = &collate->wcheads[idx];
|
||||||
while (*eptr != NULL)
|
while (*eptr != NULL)
|
||||||
|
|
@ -2560,8 +2592,19 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
|
||||||
assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_EXTRAMB));
|
assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_EXTRAMB));
|
||||||
iov[2 + cnt].iov_len = obstack_object_size (&extrapool);
|
iov[2 + cnt].iov_len = obstack_object_size (&extrapool);
|
||||||
iov[2 + cnt].iov_base = obstack_finish (&extrapool);
|
iov[2 + cnt].iov_base = obstack_finish (&extrapool);
|
||||||
|
idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
|
||||||
++cnt;
|
++cnt;
|
||||||
|
|
||||||
|
assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_COLLSEQMB));
|
||||||
|
iov[2 + cnt].iov_base = collate->mbseqorder;
|
||||||
|
iov[2 + cnt].iov_len = 256;
|
||||||
|
idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
|
||||||
|
++cnt;
|
||||||
|
|
||||||
|
assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_COLLSEQWC));
|
||||||
|
iov[2 + cnt].iov_base = collate->wcseqorder;
|
||||||
|
iov[2 + cnt].iov_len = table_size * sizeof (uint32_t);
|
||||||
|
++cnt;
|
||||||
|
|
||||||
assert (cnt == _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE));
|
assert (cnt == _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue