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]

[PATCH] Fix localedef, so that programs don't sigbus on SPARC


Hi!

The following is needed to get say ls run on sparc32 with e.g. LC_ALL=en_US.
There were a few problems: missing alignments, CTYPE had one uninitialized 4
byte gap at the end of idx vector, week_1stday is declared as word but was
set as 1 byte long field.
What I wonder is in both ld-monetary and ld-numeric there was a line like:
  idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
in the middle of the vector in addition to such line when cnt == 2.
I suppose it was a typo, so I have removed it in the patch and replaced with
what is done with other fields.

2000-04-18  Jakub Jelinek  <jakub@redhat.com>

	* locale/programs/ld-ctype.c (ctype_output): Set size of the idx
	field to nelems * sizeof (uint32_t).
	Initialize offset to 2 and replace all 2 + elem + offset expressions
	with elem + offset.
	* 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.
	* 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	Thu Apr 13 10:57:51 2000
+++ libc/locale/programs/ld-ctype.c	Tue Apr 18 13:54:35 2000
@@ -796,10 +796,10 @@ 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;
+  offset = 2;
 
   for (elem = 0; elem < nelems; ++elem)
     {
@@ -808,10 +808,9 @@ ctype_output (struct localedef_t *locale
 	  {
 #define CTYPE_DATA(name, base, len)					      \
 	  case _NL_ITEM_INDEX (name):					      \
-	    iov[2 + elem + offset].iov_base = (base);			      \
-	    iov[2 + elem + offset].iov_len = (len);			      \
-	    if (elem + 1 < nelems)					      \
-	      idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;     \
+	    iov[elem + offset].iov_base = (base);			      \
+	    iov[elem + offset].iov_len = (len);			      \
+	    idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;	      \
 	    break
 
 	  CTYPE_DATA (_NL_CTYPE_CLASS,
@@ -873,14 +872,14 @@ ctype_output (struct localedef_t *locale
 	    total = 0;
 	    for (cnt = 0; cnt < ctype->nr_charclass; ++cnt, ++offset)
 	      {
-		iov[2 + elem + offset].iov_base
+		iov[elem + offset].iov_base
 		  = (void *) ctype->classnames[cnt];
-		iov[2 + elem + offset].iov_len
+		iov[elem + offset].iov_len
 		  = strlen (ctype->classnames[cnt]) + 1;
-		total += iov[2 + elem + offset].iov_len;
+		total += iov[elem + offset].iov_len;
 	      }
-	    iov[2 + elem + offset].iov_base = (void *) "\0\0\0";
-	    iov[2 + elem + offset].iov_len = 1 + (4 - ((total + 1) % 4));
+	    iov[elem + offset].iov_base = (void *) "\0\0\0";
+	    iov[elem + offset].iov_len = 1 + (4 - ((total + 1) % 4));
 	    total += 1 + (4 - ((total + 1) % 4));
 
 	    idx[elem + 1] = idx[elem] + total;
@@ -891,14 +890,14 @@ ctype_output (struct localedef_t *locale
 	    total = 0;
 	    for (cnt = 0; cnt < ctype->map_collection_nr; ++cnt, ++offset)
 	      {
-		iov[2 + elem + offset].iov_base
+		iov[elem + offset].iov_base
 		  = (void *) ctype->mapnames[cnt];
-		iov[2 + elem + offset].iov_len
+		iov[elem + offset].iov_len
 		  = strlen (ctype->mapnames[cnt]) + 1;
-		total += iov[2 + elem + offset].iov_len;
+		total += iov[elem + offset].iov_len;
 	      }
-	    iov[2 + elem + offset].iov_base = (void *) "\0\0\0";
-	    iov[2 + elem + offset].iov_len = 1 + (4 - ((total + 1) % 4));
+	    iov[elem + offset].iov_base = (void *) "\0\0\0";
+	    iov[elem + offset].iov_len = 1 + (4 - ((total + 1) % 4));
 	    total += 1 + (4 - ((total + 1) % 4));
 
 	    idx[elem + 1] = idx[elem] + total;
@@ -914,31 +913,31 @@ ctype_output (struct localedef_t *locale
 	  case _NL_ITEM_INDEX (_NL_CTYPE_CODESET_NAME):
 	    total = strlen (ctype->codeset_name) + 1;
 	    if (total % 4 == 0)
-	      iov[2 + elem + offset].iov_base = (char *) ctype->codeset_name;
+	      iov[elem + offset].iov_base = (char *) ctype->codeset_name;
 	    else
 	      {
-		iov[2 + elem + offset].iov_base = alloca ((total + 3) & ~3);
-		memset (mempcpy (iov[2 + elem + offset].iov_base,
+		iov[elem + offset].iov_base = alloca ((total + 3) & ~3);
+		memset (mempcpy (iov[elem + offset].iov_base,
 				 ctype->codeset_name, total),
 			'\0', 4 - (total & 3));
 		total = (total + 3) & ~3;
 	      }
-	    iov[2 + elem + offset].iov_len = total;
-	    idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
+	    iov[elem + offset].iov_len = total;
+	    idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
 	    break;
 
 	  case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS_MB_LEN):
-	    iov[2 + elem + offset].iov_base = alloca (sizeof (uint32_t));
-	    iov[2 + elem + offset].iov_len = sizeof (uint32_t);
-	    *(uint32_t *) iov[2 + elem + offset].iov_base =
+	    iov[elem + offset].iov_base = alloca (sizeof (uint32_t));
+	    iov[elem + offset].iov_len = sizeof (uint32_t);
+	    *(uint32_t *) iov[elem + offset].iov_base =
 	      ctype->mbdigits_act / 10;
 	    idx[elem + 1] = idx[elem] + sizeof (uint32_t);
 	    break;
 
 	  case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS_WC_LEN):
-	    iov[2 + elem + offset].iov_base = alloca (sizeof (uint32_t));
-	    iov[2 + elem + offset].iov_len = sizeof (uint32_t);
-	    *(uint32_t *) iov[2 + elem + offset].iov_base =
+	    iov[elem + offset].iov_base = alloca (sizeof (uint32_t));
+	    iov[elem + offset].iov_len = sizeof (uint32_t);
+	    *(uint32_t *) iov[elem + offset].iov_base =
 	      ctype->wcdigits_act / 10;
 	    idx[elem + 1] = idx[elem] + sizeof (uint32_t);
 	    break;
@@ -952,10 +951,10 @@ ctype_output (struct localedef_t *locale
 	    for (cnt = elem - _NL_CTYPE_INDIGITS0_MB;
 		 cnt < ctype->mbdigits_act; cnt += 10)
 	      total += ctype->mbdigits[cnt]->nbytes + 1;
-	    iov[2 + elem + offset].iov_base = (char *) alloca (total);
-	    iov[2 + elem + offset].iov_len = total;
+	    iov[elem + offset].iov_base = (char *) alloca (total);
+	    iov[elem + offset].iov_len = total;
 
-	    cp = iov[2 + elem + offset].iov_base;
+	    cp = iov[elem + offset].iov_base;
 	    for (cnt = elem - _NL_CTYPE_INDIGITS0_MB;
 		 cnt < ctype->mbdigits_act; cnt += 10)
 	      {
@@ -963,7 +962,7 @@ ctype_output (struct localedef_t *locale
 			      ctype->mbdigits[cnt]->nbytes);
 		*cp++ = '\0';
 	      }
-	    idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
+	    idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
 	    break;
 
 	  case _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT0_MB) ... _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT9_MB):
@@ -973,34 +972,34 @@ ctype_output (struct localedef_t *locale
 	       necessary but it makes it easier for the user.  */
 	    cnt = elem - _NL_CTYPE_OUTDIGIT0_MB;
 	    total = ctype->mboutdigits[cnt]->nbytes + 1;
-	    iov[2 + elem + offset].iov_base = (char *) alloca (total);
-	    iov[2 + elem + offset].iov_len = total;
+	    iov[elem + offset].iov_base = (char *) alloca (total);
+	    iov[elem + offset].iov_len = total;
 
-	    *(char *) mempcpy (iov[2 + elem + offset].iov_base,
+	    *(char *) mempcpy (iov[elem + offset].iov_base,
 			       ctype->mbdigits[cnt]->bytes,
 			       ctype->mbdigits[cnt]->nbytes) = '\0';
-	    idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
+	    idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
 	    break;
 
 	  case _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS0_WC) ... _NL_ITEM_INDEX (_NL_CTYPE_INDIGITS9_WC):
 	    total = ctype->wcdigits_act / 10;
 
-	    iov[2 + elem + offset].iov_base =
+	    iov[elem + offset].iov_base =
 	      (uint32_t *) alloca (total * sizeof (uint32_t));
-	    iov[2 + elem + offset].iov_len = total * sizeof (uint32_t);
+	    iov[elem + offset].iov_len = total * sizeof (uint32_t);
 
 	    for (cnt = elem - _NL_CTYPE_INDIGITS0_WC;
 		 cnt < ctype->wcdigits_act; cnt += 10)
-	      ((uint32_t *) iov[2 + elem + offset].iov_base)[cnt / 10]
+	      ((uint32_t *) iov[elem + offset].iov_base)[cnt / 10]
 		= ctype->wcdigits[cnt];
-	    idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
+	    idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
 	    break;
 
 	  case _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT0_WC) ... _NL_ITEM_INDEX (_NL_CTYPE_OUTDIGIT9_WC):
 	    cnt = elem - _NL_CTYPE_OUTDIGIT0_WC;
-	    iov[2 + elem + offset].iov_base = &ctype->wcoutdigits[cnt];
-	    iov[2 + elem + offset].iov_len = sizeof (uint32_t);
-	    idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
+	    iov[elem + offset].iov_base = &ctype->wcoutdigits[cnt];
+	    iov[elem + offset].iov_len = sizeof (uint32_t);
+	    idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
 	    break;
 
 	  default:
@@ -1011,19 +1010,19 @@ ctype_output (struct localedef_t *locale
 	  /* Handle extra maps.  */
 	  size_t nr = (elem - _NL_ITEM_INDEX (_NL_NUM_LC_CTYPE)) + 2;
 
-	  iov[2 + elem + offset].iov_base = ctype->map32[nr];
-	  iov[2 + elem + offset].iov_len = ((ctype->plane_size
+	  iov[elem + offset].iov_base = ctype->map32[nr];
+	  iov[elem + offset].iov_len = ((ctype->plane_size
 					     * ctype->plane_cnt)
 					    * sizeof (uint32_t));
 
-	  idx[elem + 1] = idx[elem] + iov[2 + elem + offset].iov_len;
+	  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
 	}
     }
 
-  assert (2 + elem + offset == (nelems + ctype->nr_charclass
+  assert (elem + offset == (nelems + ctype->nr_charclass
 				+ ctype->map_collection_nr + 2));
 
-  write_locale_data (output_path, "LC_CTYPE", 2 + elem + offset, iov);
+  write_locale_data (output_path, "LC_CTYPE", elem + offset, iov);
 }
 
 
--- libc/locale/programs/ld-address.c.jj	Wed Mar 22 22:36:05 2000
+++ libc/locale/programs/ld-address.c	Tue Apr 18 14:23:43 2000
@@ -328,85 +328,90 @@ 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;
+  size_t elem = 0, offset = 2;
 
   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;
-  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;
-  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;
-  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;
-  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;
-  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;
-  iov[cnt].iov_base = (void *) address->lang_lib;
-  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
-  ++cnt;
+  iov[0].iov_base = (void *) &data;
+  iov[0].iov_len = sizeof (data);
 
-  assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS));
+  iov[1].iov_base = (void *) idx;
+  iov[1].iov_len = sizeof (idx);
+
+  idx[0] = iov[0].iov_len + iov[1].iov_len;
+
+  iov[elem + offset].iov_base = (void *) address->postal_fmt;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) address->country_name;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) address->country_post;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) address->country_ab2;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) address->country_ab3;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) address->country_car;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  /* Align following data */
+  iov[elem + offset].iov_base = (void *) "\0\0";
+  iov[elem + offset].iov_len = ((idx[elem] + 3) & ~3) - idx[elem];
+  idx[elem] = (idx[elem] + 3) & ~3;
+  ++offset;
+
+  iov[elem + offset].iov_base = (void *) &address->country_num;
+  iov[elem + offset].iov_len = sizeof (uint32_t);
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) address->country_isbn;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) address->lang_name;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) address->lang_ab;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) address->lang_term;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) address->lang_lib;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  ++elem;
+
+  assert (elem == _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS));
 
   write_locale_data (output_path, "LC_ADDRESS",
-		     2 + _NL_ITEM_INDEX (_NL_NUM_LC_ADDRESS), iov);
+		     elem + offset, iov);
 }
 
 
--- libc/locale/programs/ld-monetary.c.jj	Wed Mar 22 22:36:05 2000
+++ libc/locale/programs/ld-monetary.c	Tue Apr 18 14:23:31 2000
@@ -361,250 +361,255 @@ 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;
+  size_t elem = 0, offset = 2;
 
   data.magic = LIMAGIC (LC_MONETARY);
   data.n = _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY);
-  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 *) monetary->int_curr_symbol;
-  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 *) monetary->currency_symbol;
-  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 *) monetary->mon_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 *) monetary->mon_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 = monetary->mon_grouping;
-  iov[cnt].iov_len = monetary->mon_grouping_len;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) monetary->positive_sign;
-  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 *) monetary->negative_sign;
-  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 *) &monetary->int_frac_digits;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->frac_digits;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->p_cs_precedes;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->p_sep_by_space;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->n_cs_precedes;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->n_sep_by_space;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->p_sign_posn;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->n_sign_posn;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->crncystr;
-  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 *) &monetary->int_p_cs_precedes;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->int_p_sep_by_space;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->int_n_cs_precedes;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->int_n_sep_by_space;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->int_p_sign_posn;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->int_n_sign_posn;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
-  iov[cnt].iov_base = (void *) monetary->duo_int_curr_symbol;
-  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 *) monetary->duo_currency_symbol;
-  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 *) &monetary->duo_int_frac_digits;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_frac_digits;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_p_cs_precedes;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_p_sep_by_space;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_n_cs_precedes;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_n_sep_by_space;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_int_p_cs_precedes;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_int_p_sep_by_space;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_int_n_cs_precedes;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_int_n_sep_by_space;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_p_sign_posn;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_n_sign_posn;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_int_p_sign_posn;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_int_n_sign_posn;
-  iov[cnt].iov_len = 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->uno_valid_from;
-  iov[cnt].iov_len = 4;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->uno_valid_to;
-  iov[cnt].iov_len = 4;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_valid_from;
-  iov[cnt].iov_len = 4;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) &monetary->duo_valid_to;
-  iov[cnt].iov_len = 4;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) monetary->conversion_rate;
-  iov[cnt].iov_len = 8;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + 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;
-  iov[cnt].iov_base = (void *) &monetary->mon_thousands_sep_wc;
-  iov[cnt].iov_len = sizeof (uint32_t);
-  ++cnt;
+  iov[0].iov_base = (void *) &data;
+  iov[0].iov_len = sizeof (data);
 
-  assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY));
+  iov[1].iov_base = (void *) idx;
+  iov[1].iov_len = sizeof (idx);
+
+  idx[0] = iov[0].iov_len + iov[1].iov_len;
+
+  iov[elem + offset].iov_base = (void *) monetary->int_curr_symbol;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) monetary->currency_symbol;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) monetary->mon_decimal_point;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) monetary->mon_thousands_sep;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = monetary->mon_grouping;
+  iov[elem + offset].iov_len = monetary->mon_grouping_len;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) monetary->positive_sign;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) monetary->negative_sign;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->int_frac_digits;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->frac_digits;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->p_cs_precedes;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->p_sep_by_space;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->n_cs_precedes;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->n_sep_by_space;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->p_sign_posn;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->n_sign_posn;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->crncystr;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->int_p_cs_precedes;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->int_p_sep_by_space;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->int_n_cs_precedes;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->int_n_sep_by_space;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->int_p_sign_posn;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->int_n_sign_posn;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) monetary->duo_int_curr_symbol;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) monetary->duo_currency_symbol;
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_int_frac_digits;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_frac_digits;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_p_cs_precedes;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_p_sep_by_space;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_n_cs_precedes;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_n_sep_by_space;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_int_p_cs_precedes;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_int_p_sep_by_space;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_int_n_cs_precedes;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_int_n_sep_by_space;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_p_sign_posn;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_n_sign_posn;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_int_p_sign_posn;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_int_n_sign_posn;
+  iov[elem + offset].iov_len = 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  /* Align following data */
+  iov[elem + offset].iov_base = (void *) "\0\0";
+  iov[elem + offset].iov_len = ((idx[elem] + 3) & ~3) - idx[elem];
+  idx[elem] = (idx[elem] + 3) & ~3;
+  ++offset;
+          
+  iov[elem + offset].iov_base = (void *) &monetary->uno_valid_from;
+  iov[elem + offset].iov_len = 4;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->uno_valid_to;
+  iov[elem + offset].iov_len = 4;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_valid_from;
+  iov[elem + offset].iov_len = 4;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->duo_valid_to;
+  iov[elem + offset].iov_len = 4;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) monetary->conversion_rate;
+  iov[elem + offset].iov_len = 8;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->mon_decimal_point_wc;
+  iov[elem + offset].iov_len = sizeof (uint32_t);
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &monetary->mon_thousands_sep_wc;
+  iov[elem + offset].iov_len = sizeof (uint32_t);
+  ++elem;
+
+  assert (elem == _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY));
 
   write_locale_data (output_path, "LC_MONETARY",
-		     2 + _NL_ITEM_INDEX (_NL_NUM_LC_MONETARY), iov);
+		     elem + offset, iov);
 }
 
 
--- libc/locale/programs/ld-time.c.jj	Wed Mar 22 22:36:06 2000
+++ libc/locale/programs/ld-time.c	Tue Apr 18 15:04:30 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-numeric.c.jj	Wed Mar 22 22:36:05 2000
+++ libc/locale/programs/ld-numeric.c	Tue Apr 18 14:38:18 2000
@@ -133,49 +133,55 @@ 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;
+  size_t elem = 0, offset = 2;
 
   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] = iov[0].iov_len + iov[1].iov_len;
-  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;
-  iov[cnt].iov_base = (void *) &numeric->thousands_sep_wc;
-  iov[cnt].iov_len = sizeof (uint32_t);
+  iov[0].iov_base = (void *) &data;
+  iov[0].iov_len = sizeof (data);
 
-  assert (cnt + 1 == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC));
+  iov[1].iov_base = (void *) idx;
+  iov[1].iov_len = sizeof (idx);
+
+  idx[0] = iov[0].iov_len + iov[1].iov_len;
+
+  iov[elem + offset].iov_base = (void *) (numeric->decimal_point ?: "");
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) (numeric->thousands_sep ?: "");
+  iov[elem + offset].iov_len = strlen (iov[elem + offset].iov_base) + 1;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = numeric->grouping;
+  iov[elem + offset].iov_len = numeric->grouping_len;
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  /* Align following data */
+  iov[elem + offset].iov_base = (void *) "\0\0";
+  iov[elem + offset].iov_len = ((idx[elem] + 3) & ~3) - idx[elem];
+  idx[elem] = (idx[elem] + 3) & ~3;
+  ++offset;
+
+  iov[elem + offset].iov_base = (void *) &numeric->decimal_point_wc;
+  iov[elem + offset].iov_len = sizeof (uint32_t);
+  idx[elem + 1] = idx[elem] + iov[elem + offset].iov_len;
+  ++elem;
+
+  iov[elem + offset].iov_base = (void *) &numeric->thousands_sep_wc;
+  iov[elem + offset].iov_len = sizeof (uint32_t);
+  ++elem;
+
+  assert (elem == _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC));
 
   write_locale_data (output_path, "LC_NUMERIC",
-		     2 + _NL_ITEM_INDEX (_NL_NUM_LC_NUMERIC), iov);
+		     elem + offset, iov);
 }
 
 

	Jakub

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]