aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard@codesourcery.com>2013-09-06 17:20:45 +0000
committerJoseph Myers <joseph@codesourcery.com>2013-09-06 17:20:45 +0000
commit1ecbb381aeed75d52f8abf47e03a31bb8212984e (patch)
treef6244ddf2f45891065af57085bc81775c83142c3
parent2618d9db2da5d5f59adb8120fc6b58d8f96f5528 (diff)
downloadglibc-1ecbb381aeed75d52f8abf47e03a31bb8212984e.tar.xz
glibc-1ecbb381aeed75d52f8abf47e03a31bb8212984e.zip
Make localedef output generation use more logical interfaces.
-rw-r--r--ChangeLog80
-rw-r--r--locale/programs/3level.h54
-rw-r--r--locale/programs/ld-address.c108
-rw-r--r--locale/programs/ld-collate.c199
-rw-r--r--locale/programs/ld-ctype.c518
-rw-r--r--locale/programs/ld-identification.c130
-rw-r--r--locale/programs/ld-measurement.c35
-rw-r--r--locale/programs/ld-messages.c52
-rw-r--r--locale/programs/ld-monetary.c307
-rw-r--r--locale/programs/ld-name.c65
-rw-r--r--locale/programs/ld-numeric.c65
-rw-r--r--locale/programs/ld-paper.c41
-rw-r--r--locale/programs/ld-telephone.c53
-rw-r--r--locale/programs/ld-time.c440
-rw-r--r--locale/programs/locfile.c171
-rw-r--r--locale/programs/locfile.h31
16 files changed, 738 insertions, 1611 deletions
diff --git a/ChangeLog b/ChangeLog
index b107551fad..81615fb445 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,83 @@
+2013-09-06 Richard Sandiford <richard@codesourcery.com>
+ Joseph Myers <joseph@codesourcery.com>
+
+ * locale/programs/locfile.c: Include <assert.h>, <wchar.h> and
+ "localeinfo.h".
+ (obstack_chunk_alloc): New macro.
+ (obstack_chunk_free): Likewise.
+ (record_offset): New function.
+ (init_locale_data): Likewise.
+ (align_locale_data): Likewise.
+ (add_locale_empty): Likewise.
+ (add_locale_raw_data): Likewise.
+ (add_locale_raw_obstack): Likewise.
+ (add_locale_string): Likewise.
+ (add_locale_wstring): Likewise.
+ (add_locale_uint32): Likewise.
+ (add_locale_uint32_array): Likewise.
+ (add_locale_char): Likewise.
+ (start_locale_structure): Likewise.
+ (end_locale_structure): Likewise.
+ (start_locale_prelude): Likewise.
+ (end_locale_prelude): Likewise.
+ (write_locale_data): Take locale_file structure rather than an
+ iovec.
+ * locale/programs/locfile.h: Include "obstack.h".
+ (struct locale_file): Change to store locale file contents instead
+ of header.
+ (init_locale_data): New prototype.
+ (align_locale_data): Likewise.
+ (add_locale_empty): Likewise.
+ (add_locale_raw_data): Likewise.
+ (add_locale_raw_obstack): Likewise.
+ (add_locale_string): Likewise.
+ (add_locale_wstring): Likewise.
+ (add_locale_uint32): Likewise.
+ (add_locale_uint32_array): Likewise.
+ (add_locale_char): Likewise.
+ (start_locale_structure): Likewise.
+ (end_locale_structure): Likewise.
+ (start_locale_prelude): Likewise.
+ (end_locale_prelude): Likewise.
+ (write_locale_data): Update prototype.
+ * locale/programs/3level.h (struct TABLE): Remove result field.
+ (CONCAT(TABLE,_finalize)): Change to CONCAT(add_locale_,TABLE).
+ Use new locale_file interface.
+ [!NO_FINALIZE]: Change condition to [!NO_ADD_LOCALE].
+ (NO_FINALIZE): Change #undef to #undef of NO_ADD_LOCALE.
+ * locale/programs/ld-address.c (address_output): Use new
+ locale_file interface.
+ * locale/programs/ld-collate.c (NO_FINALIZE): Change to
+ NO_ADD_LOCALE.
+ (collate_finish): Don't call collseq_table_finalize.
+ (collate_output): Use new locale_file interface.
+ * locale/programs/ld-ctype.c: Move includes of "3level.h" earlier
+ in file.
+ (NO_FINALIZE): Change to NO_ADD_LOCALE.
+ (TABLE): Move defines earlier in file.
+ (ELEMENT): Likewise.
+ (DEFAULT): Likewise.
+ (wctrans_table_add): Move macro and inline function earlier in
+ file.
+ (struct wctype_table): Move type earlier in file.
+ (add_locale_wctype_table): New static prototype.
+ (struct locale_ctype_t): Use logical types instead of struct iovec
+ pointers for members.
+ (ctype_output): Use new locale_file interface.
+ (wctype_table_finalize): Change to add_locale_wctype_table. Use
+ new locale_file interface.
+ (allocate_arrays): Update for use of new locale_file interface.
+ * locale/programs/ld-identification.c (identification_output): Use
+ new locale_file interface.
+ * locale/programs/ld-measurement.c (measurement_output): Likewise.
+ * locale/programs/ld-messages.c (messages_output): Likewise.
+ * locale/programs/ld-monetary.c (monetary_output): Likewise.
+ * locale/programs/ld-name.c (name_output): Likewise.
+ * locale/programs/ld-numeric.c (numeric_output): Likewise.
+ * locale/programs/ld-paper.c (paper_output): Likewise.
+ * locale/programs/ld-telephone.c (telephone_output): Likewise.
+ * locale/programs/ld-time.c (time_output): Likewise.
+
2013-09-06 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
* benchtests/Makefile: Add memrchr benchmark.
diff --git a/locale/programs/3level.h b/locale/programs/3level.h
index 9b8b1b96ad..b8d6ca0235 100644
--- a/locale/programs/3level.h
+++ b/locale/programs/3level.h
@@ -26,7 +26,8 @@
ELEMENT to the type of every entry
DEFAULT to the default value for empty entries
ITERATE if you want the TABLE_iterate function to be defined
- NO_FINALIZE if you don't want the TABLE_finalize function to be defined
+ NO_ADD_LOCALE if you don't want the add_locale_TABLE function
+ to be defined
This will define
@@ -36,7 +37,7 @@
void TABLE_add (struct TABLE *t, uint32_t wc, ELEMENT value);
void TABLE_iterate (struct TABLE *t,
void (*fn) (uint32_t wc, ELEMENT value));
- void TABLE_finalize (struct TABLE *t);
+ void add_locale_TABLE (struct locale_file *file, struct TABLE *t);
*/
#define CONCAT(a,b) CONCAT1(a,b)
@@ -57,9 +58,8 @@ struct TABLE
size_t level3_alloc;
size_t level3_size;
ELEMENT *level3;
- /* Compressed representation. */
+ /* Size of compressed representation. */
size_t result_size;
- char *result;
};
/* Initialize. Assumes t->p and t->q have already been set. */
@@ -206,15 +206,15 @@ CONCAT(TABLE,_iterate) (struct TABLE *t,
}
#endif
-#ifndef NO_FINALIZE
+#ifndef NO_ADD_LOCALE
/* Finalize and shrink. */
static void
-CONCAT(TABLE,_finalize) (struct TABLE *t)
+CONCAT(add_locale_,TABLE) (struct locale_file *file, struct TABLE *t)
{
size_t i, j, k;
uint32_t reorder3[t->level3_size];
uint32_t reorder2[t->level2_size];
- uint32_t level1_offset, level2_offset, level3_offset, last_offset;
+ uint32_t level2_offset, level3_offset, last_offset;
/* Uniquify level3 blocks. */
k = 0;
@@ -271,10 +271,7 @@ CONCAT(TABLE,_finalize) (struct TABLE *t)
+ (t->level2_size << t->q) * sizeof (uint32_t)
+ (t->level3_size << t->p) * sizeof (ELEMENT);
t->result_size = (last_offset + 3) & ~3ul;
- t->result = (char *) xmalloc (t->result_size);
- level1_offset =
- 5 * sizeof (uint32_t);
level2_offset =
5 * sizeof (uint32_t)
+ t->level1_size * sizeof (uint32_t);
@@ -283,29 +280,36 @@ CONCAT(TABLE,_finalize) (struct TABLE *t)
+ t->level1_size * sizeof (uint32_t)
+ (t->level2_size << t->q) * sizeof (uint32_t);
- ((uint32_t *) t->result)[0] = t->q + t->p;
- ((uint32_t *) t->result)[1] = t->level1_size;
- ((uint32_t *) t->result)[2] = t->p;
- ((uint32_t *) t->result)[3] = (1 << t->q) - 1;
- ((uint32_t *) t->result)[4] = (1 << t->p) - 1;
+ start_locale_structure (file);
+ add_locale_uint32 (file, t->q + t->p);
+ add_locale_uint32 (file, t->level1_size);
+ add_locale_uint32 (file, t->p);
+ add_locale_uint32 (file, (1 << t->q) - 1);
+ add_locale_uint32 (file, (1 << t->p) - 1);
for (i = 0; i < t->level1_size; i++)
- ((uint32_t *) (t->result + level1_offset))[i] =
- (t->level1[i] == EMPTY
+ add_locale_uint32
+ (file,
+ t->level1[i] == EMPTY
? 0
: (t->level1[i] << t->q) * sizeof (uint32_t) + level2_offset);
for (i = 0; i < (t->level2_size << t->q); i++)
- ((uint32_t *) (t->result + level2_offset))[i] =
- (t->level2[i] == EMPTY
+ add_locale_uint32
+ (file,
+ t->level2[i] == EMPTY
? 0
: (t->level2[i] << t->p) * sizeof (ELEMENT) + level3_offset);
- for (i = 0; i < (t->level3_size << t->p); i++)
- ((ELEMENT *) (t->result + level3_offset))[i] = t->level3[i];
-
- if (last_offset < t->result_size)
- memset (t->result + last_offset, 0, t->result_size - last_offset);
+ if (sizeof (ELEMENT) == 1)
+ add_locale_raw_data (file, t->level3, t->level3_size << t->p);
+ else if (sizeof (ELEMENT) == sizeof (uint32_t))
+ add_locale_uint32_array (file, (uint32_t *) t->level3,
+ t->level3_size << t->p);
+ else
+ abort ();
+ align_locale_data (file, 4);
+ end_locale_structure (file);
if (t->level1_alloc > 0)
free (t->level1);
@@ -321,4 +325,4 @@ CONCAT(TABLE,_finalize) (struct TABLE *t)
#undef ELEMENT
#undef DEFAULT
#undef ITERATE
-#undef NO_FINALIZE
+#undef NO_ADD_LOCALE
diff --git a/locale/programs/ld-address.c b/locale/programs/ld-address.c
index 39b9a836f4..291e7b787f 100644
--- a/locale/programs/ld-address.c
+++ b/locale/programs/ld-address.c
@@ -349,97 +349,23 @@ address_output (struct localedef_t *locale, const struct charmap_t *charmap,
const char *output_path)
{
struct locale_address_t *address = locale->categories[LC_ADDRESS].address;
- struct iovec iov[3 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS)];
- struct locale_file data;
- uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS)];
- size_t cnt = 0;
-
- data.magic = LIMAGIC (LC_ADDRESS);
- data.n = _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS);
- iov[cnt].iov_base = (void *) &data;
- iov[cnt].iov_len = sizeof (data);
- ++cnt;
-
- iov[cnt].iov_base = (void *) idx;
- iov[cnt].iov_len = sizeof (idx);
- ++cnt;
-
- idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
- iov[cnt].iov_base = (void *) address->postal_fmt;
- iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
- ++cnt;
-
- idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
- iov[cnt].iov_base = (void *) address->country_name;
- iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
- ++cnt;
-
- idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
- iov[cnt].iov_base = (void *) address->country_post;
- iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
- ++cnt;
-
- idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
- iov[cnt].iov_base = (void *) address->country_ab2;
- iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
- ++cnt;
-
- idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
- iov[cnt].iov_base = (void *) address->country_ab3;
- iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
- ++cnt;
-
- idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
- iov[cnt].iov_base = (void *) address->country_car;
- iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
- ++cnt;
-
- idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-
- /* Align following data */
- iov[cnt].iov_base = (void *) "\0\0";
- iov[cnt].iov_len = ((idx[cnt - 2] + 3) & ~3) - idx[cnt - 2];
- idx[cnt - 2] = (idx[cnt - 2] + 3) & ~3;
- ++cnt;
-
- iov[cnt].iov_base = (void *) &address->country_num;
- iov[cnt].iov_len = sizeof (uint32_t);
- ++cnt;
-
- idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
- iov[cnt].iov_base = (void *) address->country_isbn;
- iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
- ++cnt;
-
- idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
- iov[cnt].iov_base = (void *) address->lang_name;
- iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
- ++cnt;
-
- idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
- iov[cnt].iov_base = (void *) address->lang_ab;
- iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
- ++cnt;
-
- idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
- iov[cnt].iov_base = (void *) address->lang_term;
- iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
- ++cnt;
-
- idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
- iov[cnt].iov_base = (void *) address->lang_lib;
- iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
- ++cnt;
-
- idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len;
- iov[cnt].iov_base = (void *) charmap->code_set_name;
- iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
- ++cnt;
-
- assert (cnt == 3 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS));
-
- write_locale_data (output_path, LC_ADDRESS, "LC_ADDRESS",
- 3 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS), iov);
+ struct locale_file file;
+
+ init_locale_data (&file, _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS));
+ add_locale_string (&file, address->postal_fmt);
+ add_locale_string (&file, address->country_name);
+ add_locale_string (&file, address->country_post);
+ add_locale_string (&file, address->country_ab2);
+ add_locale_string (&file, address->country_ab3);
+ add_locale_string (&file, address->country_car);
+ add_locale_uint32 (&file, address->country_num);
+ add_locale_string (&file, address->country_isbn);
+ add_locale_string (&file, address->lang_name);
+ add_locale_string (&file, address->lang_ab);
+ add_locale_string (&file, address->lang_term);
+ add_locale_string (&file, address->lang_lib);
+ add_locale_string (&file, charmap->code_set_name);
+ write_locale_data (output_path, LC_ADDRESS, "LC_ADDRESS", &file);
}
diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
index e58c8f7020..c4d7e3d3d2 100644
--- a/locale/programs/ld-collate.c
+++ b/locale/programs/ld-collate.c
@@ -165,7 +165,7 @@ struct symbol_t
#define ELEMENT struct element_t *
#define DEFAULT NULL
#define ITERATE
-#define NO_FINALIZE
+#define NO_ADD_LOCALE
#include "3level.h"
/* Sparse table of int32_t. */
@@ -1813,8 +1813,6 @@ symbol `%s' has the same encoding as"), (*eptr)->name);
runp = runp->next;
}
- collseq_table_finalize (&collate->wcseqorder);
-
/* Now determine whether the UNDEFINED entry is needed and if yes,
whether it was defined. */
collate->undefined.used_in_level = need_undefined ? ~0ul : 0;
@@ -2098,10 +2096,7 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
{
struct locale_collate_t *collate = locale->categories[LC_COLLATE].collate;
const size_t nelems = _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE);
- struct iovec iov[2 + nelems];
- struct locale_file data;
- uint32_t idx[nelems];
- size_t cnt;
+ struct locale_file file;
size_t ch;
int32_t tablemb[256];
struct obstack weightpool;
@@ -2114,51 +2109,22 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
int i;
struct element_t *runp;
- data.magic = LIMAGIC (LC_COLLATE);
- data.n = nelems;
- iov[0].iov_base = (void *) &data;
- iov[0].iov_len = sizeof (data);
-
- iov[1].iov_base = (void *) idx;
- iov[1].iov_len = sizeof (idx);
-
- idx[0] = iov[0].iov_len + iov[1].iov_len;
- cnt = 0;
-
- assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_NRULES));
- iov[2 + cnt].iov_base = &nrules;
- iov[2 + cnt].iov_len = sizeof (uint32_t);
- idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
- ++cnt;
+ init_locale_data (&file, nelems);
+ add_locale_uint32 (&file, nrules);
/* If we have no LC_COLLATE data emit only the number of rules as zero. */
if (collate == NULL)
{
- int32_t dummy = 0;
-
- while (cnt < _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE))
+ size_t idx;
+ for (idx = 1; idx < nelems; idx++)
{
/* The words have to be handled specially. */
- if (cnt == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_HASH_SIZEMB))
- {
- iov[2 + cnt].iov_base = &dummy;
- iov[2 + cnt].iov_len = sizeof (int32_t);
- }
+ if (idx == _NL_ITEM_INDEX (_NL_COLLATE_SYMB_HASH_SIZEMB))
+ add_locale_uint32 (&file, 0);
else
- {
- iov[2 + cnt].iov_base = NULL;
- iov[2 + cnt].iov_len = 0;
- }
-
- if (cnt + 1 < _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE))
- idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
- ++cnt;
+ add_locale_empty (&file);
}
-
- assert (cnt == _NL_ITEM_INDEX (_NL_NUM_LC_COLLATE));
-
- write_locale_data (output_path, LC_COLLATE, "LC_COLLATE", 2 + cnt, iov);
-
+ write_locale_data (output_path, LC_COLLATE, "LC_COLLATE", &file);
return;
}
@@ -2191,11 +2157,7 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
obstack_1grow (&weightpool, '\0');
while (++i < __alignof__ (int32_t));
- assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_RULESETS));
- iov[2 + cnt].iov_len = obstack_object_size (&weightpool);
- iov[2 + cnt].iov_base = obstack_finish (&weightpool);
- idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
- ++cnt;
+ add_locale_raw_obstack (&file, &weightpool);
/* Generate the 8-bit table. Walk through the lists of sequences
starting with the same byte and add them one after the other to
@@ -2382,55 +2344,16 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
obstack_1grow (&weightpool, 0);
/* Now add the four tables. */
- assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_TABLEMB));
- iov[2 + cnt].iov_base = tablemb;
- iov[2 + cnt].iov_len = sizeof (tablemb);
- idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
- assert ((iov[2 + cnt].iov_len & (__alignof__ (int32_t) - 1)) == 0);
- ++cnt;
-
- assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_WEIGHTMB));
- iov[2 + cnt].iov_len = obstack_object_size (&weightpool);
- iov[2 + cnt].iov_base = obstack_finish (&weightpool);
- idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
- ++cnt;
-
- assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_EXTRAMB));
- iov[2 + cnt].iov_len = obstack_object_size (&extrapool);
- iov[2 + cnt].iov_base = obstack_finish (&extrapool);
- idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
- ++cnt;
-
- assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_INDIRECTMB));
- iov[2 + cnt].iov_len = obstack_object_size (&indirectpool);
- iov[2 + cnt].iov_base = obstack_finish (&indirectpool);
- idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
- assert ((iov[2 + cnt].iov_len & (__alignof__ (int32_t) - 1)) == 0);
- ++cnt;
-
+ add_locale_uint32_array (&file, (const uint32_t *) tablemb, 256);
+ add_locale_raw_obstack (&file, &weightpool);
+ add_locale_raw_obstack (&file, &extrapool);
+ add_locale_raw_obstack (&file, &indirectpool);
/* Now the same for the wide character table. We need to store some
more information here. */
- 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] % __alignof__ (int32_t) == 0);
- ++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] % __alignof__ (int32_t) == 0);
- ++cnt;
-
- 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] % __alignof__ (int32_t) == 0);
- ++cnt;
+ add_locale_empty (&file);
+ add_locale_empty (&file);
+ add_locale_empty (&file);
/* 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
@@ -2462,41 +2385,11 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
memset (&atwc, 0, sizeof (atwc));
- collidx_table_finalize (&tablewc);
-
/* Now add the four tables. */
- assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_TABLEWC));
- 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] % __alignof__ (int32_t) == 0);
- ++cnt;
-
- assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_WEIGHTWC));
- iov[2 + cnt].iov_len = obstack_object_size (&weightpool);
- iov[2 + cnt].iov_base = obstack_finish (&weightpool);
- idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
- assert (iov[2 + cnt].iov_len % sizeof (int32_t) == 0);
- assert (idx[cnt] % __alignof__ (int32_t) == 0);
- ++cnt;
-
- assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_EXTRAWC));
- iov[2 + cnt].iov_len = obstack_object_size (&extrapool);
- 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 (idx[cnt] % __alignof__ (int32_t) == 0);
- ++cnt;
-
- assert (cnt == _NL_ITEM_INDEX (_NL_COLLATE_INDIRECTWC));
- iov[2 + cnt].iov_len = obstack_object_size (&indirectpool);
- iov[2 + cnt].iov_base = obstack_finish (&indirectpool);
- idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
- assert (iov[2 + cnt].iov_len % sizeof (int32_t) == 0);
- assert (idx[cnt] % __alignof__ (int32_t) == 0);
- ++cnt;
-
+ add_locale_collidx_table (&file, &tablewc);
+ add_locale_raw_obstack (&file, &weightpool);
+ add_locale_raw_obstack (&file, &extrapool);
+ add_locale_raw_obstack (&file, &indirectpool);
/* Finally write the table with collation element names out. It is
a hash table with a simple function which gets the name of the
@@ -2594,47 +2487,13 @@ collate_output (struct localedef_t *locale, const struct charmap_t *charmap,
}
/* Prep