This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
On Tue, Apr 18, 2000 at 07:33:36PM -0700, Ulrich Drepper wrote: > Jakub Jelinek <jakub@redhat.com> writes: > > > The following is needed to get say ls run on sparc32 with e.g. LC_ALL=en_US. > > No, Jakub. Send me the *essential* patch and leave the rest to me. > There are reasons why the code is structured as it is today. Don't > remove or add variable or remove the indices. Ok, fine. Here is the *essential* patch. The reason why I added variables was that with alignment iov's in the middle one has to change the cnt - 2 to cnt - 3 etc., so I thought it would be better to avoid changing all the following fields when some iov is inserted in the middle. Anyway, this patch fixes one more problems (&crncystr passed instead of crncystr, causing the pointer to be written as the string) and uses sizeof(uint32_t) instead of 4 for some word fields to make it obvious it is not a 4 byte array but a word (requiring alignment). I added some fields to categories.def which are missing there, but as I want to leave that up to you, they are commented out at the moment. 2000-04-19 Jakub Jelinek <jakub@redhat.com> * locale/programs/ld-ctype.c (ctype_output): Set size of the idx field to nelems * sizeof (uint32_t). * locale/programs/ld-address.c (address_output): Align word fields properly. * locale/programs/ld-monetary.c (monetary_output): Likewise. Don't restart idx pointers to idx end at the duo_int_curr_symbol field. Avoid giving arbitrary garbage in the crncystr field. Use sizeof(uint32_t) instead of 4 for len in uno_valid_from, uno_valid_to, duo_valid_from, duo_valid_to and conversion_rate fields. * locale/programs/ld-numeric.c (numeric_output): Likewise. Don't restart idx pointers to idx end at the decimal_point_wc field. * locale/programs/ld-time.c (time_output): week_1stday should be word, not byte. Align it properly. --- libc/locale/programs/ld-ctype.c.jj Sat Apr 8 21:41:44 2000 +++ libc/locale/programs/ld-ctype.c Wed Apr 19 09:08:20 2000 @@ -796,7 +796,7 @@ ctype_output (struct localedef_t *locale iov[0].iov_len = sizeof (data); iov[1].iov_base = (void *) idx; - iov[1].iov_len = sizeof (idx); + iov[1].iov_len = nelems * sizeof (uint32_t); idx[0] = iov[0].iov_len + iov[1].iov_len; offset = 0; --- libc/locale/programs/ld-time.c.jj Tue Mar 21 11:58:14 2000 +++ libc/locale/programs/ld-time.c Wed Apr 19 09:41:21 2000 @@ -502,7 +502,7 @@ time_output (struct localedef_t *locale, struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_TIME) + time->num_era - 1 + 2 * 99 - + 1 + time->num_era * 10 - 1]; + + 2 + time->num_era * 10 - 1]; struct locale_file data; uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_TIME)]; size_t cnt, last_idx, num, n; @@ -811,8 +811,14 @@ time_output (struct localedef_t *locale, ++cnt; ++last_idx; + /* We must align the following data. */ + iov[2 + cnt].iov_base = (void *) "\0\0"; + iov[2 + cnt].iov_len = ((idx[last_idx] + 3) & ~3) - idx[last_idx]; + idx[last_idx] = (idx[last_idx] + 3) & ~3; + ++cnt; + iov[2 + cnt].iov_base = (void *) &time->week_1stday; - iov[2 + cnt].iov_len = 1; + iov[2 + cnt].iov_len = sizeof(uint32_t); idx[1 + last_idx] = idx[last_idx] + iov[2 + cnt].iov_len; ++cnt; ++last_idx; @@ -849,7 +855,7 @@ time_output (struct localedef_t *locale, assert (cnt == (_NL_ITEM_INDEX (_NL_NUM_LC_TIME) + time->num_era - 1 + 2 * 99 - + 1 + time->num_era * 10 - 1)); + + 2 + time->num_era * 10 - 1)); assert (last_idx == _NL_ITEM_INDEX (_NL_NUM_LC_TIME)); write_locale_data (output_path, "LC_TIME", 2 + cnt, iov); --- libc/locale/programs/ld-address.c.jj Mon Jan 17 07:58:51 2000 +++ libc/locale/programs/ld-address.c Wed Apr 19 09:11:20 2000 @@ -328,7 +328,7 @@ address_output (struct localedef_t *loca const char *output_path) { struct locale_address_t *address = locale->categories[LC_ADDRESS].address; - struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_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; @@ -374,39 +374,46 @@ address_output (struct localedef_t *loca ++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 - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + 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 - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + 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 - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + 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 - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + 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 - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + 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; - assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS)); + assert (cnt == 3 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS)); write_locale_data (output_path, "LC_ADDRESS", - 2 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS), iov); + 3 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS), iov); } --- libc/locale/programs/ld-monetary.c.jj Thu Feb 17 16:09:55 2000 +++ libc/locale/programs/ld-monetary.c Wed Apr 19 09:31:27 2000 @@ -361,7 +361,7 @@ monetary_output (struct localedef_t *loc { struct locale_monetary_t *monetary = locale->categories[LC_MONETARY].monetary; - struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY)]; + struct iovec iov[3 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY)]; struct locale_file data; uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_MONETARY)]; size_t cnt = 0; @@ -452,7 +452,7 @@ monetary_output (struct localedef_t *loc ++cnt; idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; - iov[cnt].iov_base = (void *) &monetary->crncystr; + iov[cnt].iov_base = (void *) monetary->crncystr; iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; ++cnt; @@ -486,7 +486,7 @@ monetary_output (struct localedef_t *loc iov[cnt].iov_len = 1; ++cnt; - idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len; + idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; iov[cnt].iov_base = (void *) monetary->duo_int_curr_symbol; iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1; ++cnt; @@ -567,44 +567,51 @@ monetary_output (struct localedef_t *loc ++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 *) &monetary->uno_valid_from; - iov[cnt].iov_len = 4; + iov[cnt].iov_len = sizeof(uint32_t); ++cnt; - idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len; iov[cnt].iov_base = (void *) &monetary->uno_valid_to; - iov[cnt].iov_len = 4; + iov[cnt].iov_len = sizeof(uint32_t); ++cnt; - idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len; iov[cnt].iov_base = (void *) &monetary->duo_valid_from; - iov[cnt].iov_len = 4; + iov[cnt].iov_len = sizeof(uint32_t); ++cnt; - idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len; iov[cnt].iov_base = (void *) &monetary->duo_valid_to; - iov[cnt].iov_len = 4; + iov[cnt].iov_len = sizeof(uint32_t); ++cnt; - idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len; iov[cnt].iov_base = (void *) monetary->conversion_rate; - iov[cnt].iov_len = 8; + iov[cnt].iov_len = 2 * sizeof(uint32_t); ++cnt; - idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len; iov[cnt].iov_base = (void *) &monetary->mon_decimal_point_wc; iov[cnt].iov_len = sizeof (uint32_t); ++cnt; - idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + idx[cnt - 3] = idx[cnt - 4] + iov[cnt - 1].iov_len; iov[cnt].iov_base = (void *) &monetary->mon_thousands_sep_wc; iov[cnt].iov_len = sizeof (uint32_t); ++cnt; - assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY)); + assert (cnt == 3 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY)); write_locale_data (output_path, "LC_MONETARY", - 2 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY), iov); + 3 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY), iov); } --- libc/locale/programs/ld-numeric.c.jj Mon Jan 31 09:39:45 2000 +++ libc/locale/programs/ld-numeric.c Wed Apr 19 09:37:10 2000 @@ -133,7 +133,7 @@ numeric_output (struct localedef_t *loca const char *output_path) { struct locale_numeric_t *numeric = locale->categories[LC_NUMERIC].numeric; - struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_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; @@ -163,19 +163,26 @@ numeric_output (struct localedef_t *loca iov[cnt].iov_len = numeric->grouping_len; ++cnt; - idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len; + 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 - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len; + 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); - assert (cnt + 1 == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC)); + assert (cnt + 1 == 3 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC)); write_locale_data (output_path, "LC_NUMERIC", - 2 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC), iov); + 3 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC), iov); } --- libc/locale/categories.def.jj Mon Jan 3 07:34:53 2000 +++ libc/locale/categories.def Wed Apr 19 09:40:37 2000 @@ -102,6 +102,7 @@ DEFINE_CATEGORY DEFINE_ELEMENT (N_SEP_BY_SPACE, "n_sep_by_space", std, byte, 0, 2) DEFINE_ELEMENT (P_SIGN_POSN, "p_sign_posn", std, byte, 0, 4) DEFINE_ELEMENT (N_SIGN_POSN, "n_sign_posn", std, byte, 0, 4) +/*DEFINE_ELEMENT (CRNCYSTR, "currency_string", std, string)*/ DEFINE_ELEMENT (_NL_MONETARY_INT_P_CS_PRECEDES, "int_p_cs_precedes", std, byte, 0, 1) DEFINE_ELEMENT (_NL_MONETARY_INT_P_SEP_BY_SPACE, "int_p_sep_by_space", std, byte, 0, 2) DEFINE_ELEMENT (_NL_MONETARY_INT_N_CS_PRECEDES, "int_n_cs_precedes", std, byte, 0, 1) @@ -128,7 +129,9 @@ DEFINE_CATEGORY DEFINE_ELEMENT (_NL_MONETARY_UNO_VALID_TO, "uno_valid_to", std, word) DEFINE_ELEMENT (_NL_MONETARY_DUO_VALID_FROM, "duo_valid_from", std, word) DEFINE_ELEMENT (_NL_MONETARY_DUO_VALID_TO, "duo_valid_to", std, word) - DEFINE_ELEMENT (_NL_MONETARY_CONVERSION_RATE, "conversion_rate", std, wordarray, 2, 2) + DEFINE_ELEMENT (_NL_MONETARY_CONVERSION_RATE, "conversion_rate", std, wordarray, 2, 2) +/*DEFINE_ELEMENT (_NL_MONETARY_DECIMAL_POINT_WC, "mon_decimal_point_wc", std, word)*/ +/*DEFINE_ELEMENT (_NL_MONETARY_THOUSANDS_SEP_WC, "mon_thousands_sep_wc", std, word)*/ ), NO_POSTLOAD) @@ -136,9 +139,11 @@ DEFINE_CATEGORY ( LC_NUMERIC, "LC_NUMERIC", ( - DEFINE_ELEMENT (DECIMAL_POINT, "decimal_point", std, string) - DEFINE_ELEMENT (THOUSANDS_SEP, "thousands_sep", std, string) - DEFINE_ELEMENT (GROUPING, "grouping", std, bytearray) + DEFINE_ELEMENT (DECIMAL_POINT, "decimal_point", std, string) + DEFINE_ELEMENT (THOUSANDS_SEP, "thousands_sep", std, string) + DEFINE_ELEMENT (GROUPING, "grouping", std, bytearray) +/*DEFINE_ELEMENT (_NL_NUMERIC_DECIMAL_POINT_WC, "decimal_point_wc", std, word)*/ +/*DEFINE_ELEMENT (_NL_NUMERIC_THOUSANDS_SEP_WC, "thousands_sep_wc", std, word)*/ ), NO_POSTLOAD) Jakub
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |