diff options
author | Richard Sandiford <richard@codesourcery.com> | 2013-09-06 17:20:45 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2013-09-06 17:20:45 +0000 |
commit | 1ecbb381aeed75d52f8abf47e03a31bb8212984e (patch) | |
tree | f6244ddf2f45891065af57085bc81775c83142c3 /locale/programs/ld-address.c | |
parent | 2618d9db2da5d5f59adb8120fc6b58d8f96f5528 (diff) | |
download | glibc-1ecbb381aeed75d52f8abf47e03a31bb8212984e.tar.gz glibc-1ecbb381aeed75d52f8abf47e03a31bb8212984e.tar.xz glibc-1ecbb381aeed75d52f8abf47e03a31bb8212984e.zip |
Make localedef output generation use more logical interfaces.
Diffstat (limited to 'locale/programs/ld-address.c')
-rw-r--r-- | locale/programs/ld-address.c | 108 |
1 files changed, 17 insertions, 91 deletions
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); } |