From f175216dbf9354a73441b54f5135fe673f536c20 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 30 Jun 2000 00:11:52 +0000 Subject: Update. 2000-06-29 Ulrich Drepper * locale/programs/ld-ctype.c (ctype_output): Don't generate unaligned data files. --- locale/programs/ld-ctype.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'locale') diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c index 417660160f..c00d2cb2cc 100644 --- a/locale/programs/ld-ctype.c +++ b/locale/programs/ld-ctype.c @@ -833,11 +833,12 @@ void ctype_output (struct localedef_t *locale, struct charmap_t *charmap, const char *output_path) { + static const char nulbytes[3] = { 0, 0, 0 }; struct locale_ctype_t *ctype = locale->categories[LC_CTYPE].ctype; const size_t nelems = (_NL_ITEM_INDEX (_NL_NUM_LC_CTYPE) + (ctype->map_collection_nr - 2)); struct iovec iov[2 + nelems + ctype->nr_charclass - + ctype->map_collection_nr]; + + ctype->map_collection_nr + 2]; struct locale_file data; uint32_t idx[nelems + 1]; uint32_t default_missing_len; @@ -999,12 +1000,21 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap, idx[elem + 1] = idx[elem] + sizeof (uint32_t); break; - case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_MB) ... _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS9_MB): + case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_MB): + /* Align entries. */ + iov[2 + elem + offset].iov_base = (void *) nulbytes; + iov[2 + elem + offset].iov_len = (4 - idx[elem] % 4) % 4; + idx[elem] += iov[2 + elem + offset].iov_len; + ++offset; + /* FALLTRHOUGH */ + + case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS1_MB) ... _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS9_MB): /* Compute the length of all possible characters. For INDIGITS there might be more than one. We simply concatenate all of them with a NUL byte following. The NUL byte wouldn't be necessary but it makes it easier for the user. */ total = 0; + for (cnt = elem - _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_MB); cnt < ctype->mbdigits_act; cnt += 10) total += ctype->mbdigits[cnt]->nbytes + 1; @@ -1038,7 +1048,15 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap, idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len; break; - case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_WC) ... _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS9_WC): + case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_WC): + /* Align entries. */ + iov[2 + elem + offset].iov_base = (void *) nulbytes; + iov[2 + elem + offset].iov_len = (4 - idx[elem] % 4) % 4; + idx[elem] += iov[2 + elem + offset].iov_len; + ++offset; + /* FALLTHROUGH */ + + case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS1_WC) ... _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS9_WC): total = ctype->wcdigits_act / 10; iov[2 + elem + offset].iov_base = @@ -1124,9 +1142,9 @@ ctype_output (struct localedef_t *locale, struct charmap_t *charmap, } assert (2 + elem + offset == (nelems + ctype->nr_charclass - + ctype->map_collection_nr + 2)); + + ctype->map_collection_nr + 2 + 2)); - write_locale_data (output_path, "LC_CTYPE", 2 + elem + offset, iov); + write_locale_data (output_path, "LC_CTYPE", 2 + elem + offset + 2, iov); } -- cgit 1.4.1