diff options
Diffstat (limited to 'locale/programs/ld-numeric.c')
-rw-r--r-- | locale/programs/ld-numeric.c | 65 |
1 files changed, 10 insertions, 55 deletions
diff --git a/locale/programs/ld-numeric.c b/locale/programs/ld-numeric.c index 929409cb7a..093a04951e 100644 --- a/locale/programs/ld-numeric.c +++ b/locale/programs/ld-numeric.c @@ -133,61 +133,16 @@ numeric_output (struct localedef_t *locale, const struct charmap_t *charmap, const char *output_path) { struct locale_numeric_t *numeric = locale->categories[LC_NUMERIC].numeric; - struct iovec iov[3 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC)]; - struct locale_file data; - uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC)]; - size_t cnt = 0; - - data.magic = LIMAGIC (LC_NUMERIC); - data.n = _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC); - 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 *) (numeric->decimal_point ?: ""); - 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 *) (numeric->thousands_sep ?: ""); - 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 = numeric->grouping; - iov[cnt].iov_len = numeric->grouping_len; - ++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 *) &numeric->decimal_point_wc; - iov[cnt].iov_len = sizeof (uint32_t); - ++cnt; - - idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len; - iov[cnt].iov_base = (void *) &numeric->thousands_sep_wc; - iov[cnt].iov_len = sizeof (uint32_t); - ++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; - - assert (cnt + 1 == 3 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC)); - - write_locale_data (output_path, LC_NUMERIC, "LC_NUMERIC", - 3 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC), iov); + struct locale_file file; + + init_locale_data (&file, _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC)); + add_locale_string (&file, numeric->decimal_point ?: ""); + add_locale_string (&file, numeric->thousands_sep ?: ""); + add_locale_raw_data (&file, numeric->grouping, numeric->grouping_len); + add_locale_uint32 (&file, numeric->decimal_point_wc); + add_locale_uint32 (&file, numeric->thousands_sep_wc); + add_locale_string (&file, charmap->code_set_name); + write_locale_data (output_path, LC_NUMERIC, "LC_NUMERIC", &file); } |