for (cnt = 0; cnt < ctype->nr_charclass; ++cnt, ++elem) { iov[2 + elem].iov_base = (void *) ctype->classnames[cnt]; iov[2 + elem].iov_len = strlen (ctype->classnames[cnt]) + 1;  ctype->class_name_ptr[cnt] = offset; offset += iov[2 + elem].iov_len; } iov[2 + elem].iov_base = (void *) ""; iov[2 + elem].iov_len = 1; ++elem;   for (cnt = 0; cnt < ctype->map_collection_nr; ++cnt, ++elem) { iov[2 + elem].iov_base = (void *) ctype->mapnames[cnt]; iov[2 + elem].iov_len = strlen (ctype->mapnames[cnt]) + 1;  ctype->map_name_ptr[cnt] = offset; offset += iov[2 + elem].iov_len; } iov[2 + elem].iov_base = (void *) ""; iov[2 + elem].iov_len = 1; ++elem;  assert (elem == nelems + ctype->nr_charclass + ctype->map_collection_nr + 2);  write_locale_data (output_path, "LC_CTYPE", 2 + elem, iov);
write_locale_data (output_path, "LC_CTYPE", 2 + elem + offset, iov);
ctype_output (struct localedef_t *locale, const char *output_path){  struct locale_ctype_t *ctype = locale->categories[LC_CTYPE].ctype;  const size_t nelems = (_NL_ITEM_INDEX (_NL_NUM_LC_CTYPE)			 + 2 * (ctype->map_collection_nr - 2));  struct iovec iov[2 + nelems + (ctype->nr_charclass + 1)		  + (ctype->map_collection_nr + 1)];  struct locale_file data;  u32_t idx[nelems];  size_t elem, cnt, offset;  if ((locale->binary & (1 << LC_CTYPE)) != 0)    {      iov[0].iov_base = ctype;      iov[0].iov_len = locale->len[LC_CTYPE];      write_locale_data (output_path, "LC_CTYPE", 1, iov);      return;    }  /* Now prepare the output: Find the sizes of the table we can use.  */  allocate_arrays (ctype);  data.magic = LIMAGIC (LC_CTYPE);  data.n = nelems;  iov[0].iov_base = (void *) &data;  iov[0].iov_len = sizeof (data);  iov[1].iov_base = (void *) idx;  iov[1].iov_len = sizeof (idx);  idx[0] = iov[0].iov_len + iov[1].iov_len;  offset = 0;  for (elem = 0; elem < nelems; ++elem)    {      if (elem < _NL_ITEM_INDEX (_NL_NUM_LC_CTYPE))	switch (elem)	  {#define CTYPE_DATA(name, base, len)					      \	  case _NL_ITEM_INDEX (name):					      \	    iov[2 + elem].iov_base = base;				      \	    iov[2 + elem].iov_len = len;				      \	    break	  CTYPE_DATA (_NL_CTYPE_CLASS,		      ctype->ctype_b,		      (256 + 128) * sizeof (char_class_t));	  CTYPE_DATA (_NL_CTYPE_TOUPPER_EB,		      ctype->map_eb[0],		      (ctype->plane_size * ctype->plane_cnt + 128)		      * sizeof (u32_t));	  CTYPE_DATA (_NL_CTYPE_TOLOWER_EB,		      ctype->map_eb[1],		      (ctype->plane_size * ctype->plane_cnt + 128)		      * sizeof (u32_t));	  CTYPE_DATA (_NL_CTYPE_TOUPPER_EL,		      ctype->map_el[0],		      (ctype->plane_size * ctype->plane_cnt + 128)		      * sizeof (u32_t));	  CTYPE_DATA (_NL_CTYPE_TOLOWER_EL,		      ctype->map_el[1],		      (ctype->plane_size * ctype->plane_cnt + 128)		      * sizeof (u32_t));	  CTYPE_DATA (_NL_CTYPE_CLASS32,		      ctype->ctype32_b,		      (ctype->plane_size * ctype->plane_cnt		       * sizeof (char_class32_t)));	  CTYPE_DATA (_NL_CTYPE_NAMES_EB,		      ctype->names_eb,		      ctype->plane_size * ctype->plane_cnt * sizeof (u32_t));	  CTYPE_DATA (_NL_CTYPE_NAMES_EL,		      ctype->names_el,		      ctype->plane_size * ctype->plane_cnt * sizeof (u32_t));	  CTYPE_DATA (_NL_CTYPE_HASH_SIZE,		      &ctype->plane_size, sizeof (u32_t));	  CTYPE_DATA (_NL_CTYPE_HASH_LAYERS,		      &ctype->plane_cnt, sizeof (u32_t));	  CTYPE_DATA (_NL_CTYPE_CLASS_NAMES,		      ctype->class_name_ptr,		      ctype->nr_charclass * sizeof (u32_t));	  CTYPE_DATA (_NL_CTYPE_MAP_NAMES,		      ctype->map_name_ptr,		      ctype->map_collection_nr * sizeof (u32_t));	  CTYPE_DATA (_NL_CTYPE_WIDTH,		      NULL, 0);		/* Not yet implemented.  */	  default:	    assert (! "unknown CTYPE element");	  }      else	{	  /* Handle extra maps.  */	  size_t nr = (elem - _NL_ITEM_INDEX (_NL_NUM_LC_CTYPE)) >> 1;	  if (((elem - _NL_ITEM_INDEX (_NL_NUM_LC_CTYPE)) & 1) == 0)	    iov[2 + elem].iov_base = ctype->map_eb[nr];	  else	    iov[2 + elem].iov_base = ctype->map_el[nr];	  iov[2 + elem].iov_len = ((ctype->plane_size * ctype->plane_cnt + 128)				   * sizeof (u32_t));	}      if (elem + 1 < nelems)	idx[elem + 1] = idx[elem] + iov[2 + elem].iov_len;    }  offset = idx[elem - 1] + iov[2 + elem - 1].iov_len;  /* The class name array.  */  for (cnt = 0; cnt < ctype->nr_charclass; ++cnt, ++elem)    {      iov[2 + elem].iov_base = (void *) ctype->classnames[cnt];      iov[2 + elem].iov_len = strlen (ctype->classnames[cnt]) + 1;      ctype->class_name_ptr[cnt] = offset;      offset += iov[2 + elem].iov_len;    }  iov[2 + elem].iov_base = (void *) "";  iov[2 + elem].iov_len = 1;  ++elem;  /* The map name array.  */  for (cnt = 0; cnt < ctype->map_collection_nr; ++cnt, ++elem)    {      iov[2 + elem].iov_base = (void *) ctype->mapnames[cnt];      iov[2 + elem].iov_len = strlen (ctype->mapnames[cnt]) + 1;      ctype->map_name_ptr[cnt] = offset;      offset += iov[2 + elem].iov_len;    }  iov[2 + elem].iov_base = (void *) "";  iov[2 + elem].iov_len = 1;  ++elem;  assert (elem == nelems + ctype->nr_charclass + ctype->map_collection_nr + 2);  write_locale_data (output_path, "LC_CTYPE", 2 + elem, iov);}