ctype->wcoutdigits[cnt] = repertoire_find_value (repertoire, digits + cnt, 1);  if (ctype->wcoutdigits[cnt] == ILLEGAL_CHAR_VALUE) { ctype->wcoutdigits[cnt] = repertoire_find_value (repertoire, longnames[cnt], strlen (longnames[cnt]));  if (ctype->wcoutdigits[cnt] == ILLEGAL_CHAR_VALUE) {  error (0, 0, _("\ no output digits defined and none of the standard names in the repertoire"));   ctype->wcoutdigits[cnt] = (uint32_t) digits[cnt]; } }
set_class_defaults (struct locale_ctype_t *ctype, struct charmap_t *charmap,		    struct repertoire_t *repertoire){  size_t cnt;  /* These function defines the default values for the classes and conversions     according to POSIX.2 2.5.2.1.     It may seem that the order of these if-blocks is arbitrary but it is NOT.     Don't move them unless you know what you do!  */  void set_default (int bitpos, int from, int to)    {      char tmp[2];      int ch;      int bit = _ISbit (bitpos);      int bitw = _ISwbit (bitpos);      /* Define string.  */      strcpy (tmp, "?");      for (ch = from; ch <= to; ++ch)	{	  uint32_t value;	  struct charseq *seq;	  tmp[0] = ch;	  value = repertoire_find_value (repertoire, tmp, 1);	  if (value == ILLEGAL_CHAR_VALUE)	    {	      if (!be_quiet)		error (0, 0, _("\%s: character `%s' not defined in repertoire while needed as default value"),		       "LC_CTYPE", tmp);	    }	  else	    ELEM (ctype, class_collection, , value) |= bitw;	  seq = charmap_find_value (charmap, tmp, 1);	  if (seq == NULL)	    {	      if (!be_quiet)		error (0, 0, _("\%s: character `%s' not defined in charmap while needed as default value"),		       "LC_CTYPE", tmp);	    }	  else if (seq->nbytes != 1)	    error (0, 0, _("\%s: character `%s' in charmap not representable with one byte"),		   "LC_CTYPE", tmp);	  else	    ctype->class256_collection[seq->bytes[0]] |= bit;	}    }  /* Set default values if keyword was not present.  */  if ((ctype->class_done & BITw (tok_upper)) == 0)    /* "If this keyword [lower] is not specified, the lowercase letters        `A' through `Z', ..., shall automatically belong to this class,	with implementation defined character values."  [P1003.2, 2.5.2.1]  */    set_default (BITPOS (tok_upper), 'A', 'Z');  if ((ctype->class_done & BITw (tok_lower)) == 0)    /* "If this keyword [lower] is not specified, the lowercase letters        `a' through `z', ..., shall automatically belong to this class,	with implementation defined character values."  [P1003.2, 2.5.2.1]  */    set_default (BITPOS (tok_lower), 'a', 'z');  if ((ctype->class_done & BITw (tok_alpha)) == 0)    {      /* Table 2-6 in P1003.2 says that characters in class `upper' or	 class `lower' *must* be in class `alpha'.  */      unsigned long int mask = BIT (tok_upper) | BIT (tok_lower);      for (cnt = 0; cnt < ctype->class_collection_act; ++cnt)	if ((ctype->class_collection[cnt] & mask) != 0)	  ctype->class_collection[cnt] |= BIT (tok_alpha);    }  if ((ctype->class_done & BITw (tok_digit)) == 0)    /* "If this keyword [digit] is not specified, the digits `0' through        `9', ..., shall automatically belong to this class, with	implementation-defined character values."  [P1003.2, 2.5.2.1]  */    set_default (BITPOS (tok_digit), '0', '9');  /* "Only characters specified for the `alpha' and `digit' keyword     shall be specified.  Characters specified for the keyword `alpha'     and `digit' are automatically included in this class.  */  {    unsigned long int mask = BIT (tok_alpha) | BIT (tok_digit);    for (cnt = 0; cnt < ctype->class_collection_act; ++cnt)      if ((ctype->class_collection[cnt] & mask) != 0)	ctype->class_collection[cnt] |= BIT (tok_alnum);  }  if ((ctype->class_done & BITw (tok_space)) == 0)    /* "If this keyword [space] is not specified, the characters <space>,        <form-feed>, <newline>, <carriage-return>, <tab>, and	<vertical-tab>, ..., shall automatically belong to this class,	with implementation-defined character values."  [P1003.2, 2.5.2.1]  */    {      uint32_t value;      struct charseq *seq;      value = repertoire_find_value (repertoire, "space", 5);      if (value == ILLEGAL_CHAR_VALUE)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<space>");	}      else	ELEM (ctype, class_collection, , value) |= BIT (tok_space);      seq = charmap_find_value (charmap, "space", 5);      if (seq == NULL)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<space>");	}      else if (seq->nbytes != 1)	error (0, 0, _("\%s: character `%s' in charmap not representable with one byte"),	       "LC_CTYPE", "<space>");      else	ctype->class256_collection[seq->bytes[0]] |= BIT (tok_space);      value = repertoire_find_value (repertoire, "form-feed", 9);      if (value == ILLEGAL_CHAR_VALUE)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<form-feed>");	}      else	ELEM (ctype, class_collection, , value) |= BIT (tok_space);      seq = charmap_find_value (charmap, "form-feed", 9);      if (seq == NULL)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<form-feed>");	}      else if (seq->nbytes != 1)	error (0, 0, _("\%s: character `%s' in charmap not representable with one byte"),	       "LC_CTYPE", "<form-feed>");      else	ctype->class256_collection[seq->bytes[0]] |= BIT (tok_space);      value = repertoire_find_value (repertoire, "newline", 7);      if (value == ILLEGAL_CHAR_VALUE)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<newline>");	}      else	ELEM (ctype, class_collection, , value) |= BIT (tok_space);      seq = charmap_find_value (charmap, "newline", 7);      if (seq == NULL)	{	  if (!be_quiet)	    error (0, 0, _("\character `%s' not defined while needed as default value"),		   "<newline>");	}      else if (seq->nbytes != 1)	error (0, 0, _("\%s: character `%s' in charmap not representable with one byte"),	       "LC_CTYPE", "<newline>");      else	ctype->class256_collection[seq->bytes[0]] |= BIT (tok_space);      value = repertoire_find_value (repertoire, "carriage-return", 15);      if (value == ILLEGAL_CHAR_VALUE)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<carriage-return>");	}      else	ELEM (ctype, class_collection, , value) |= BIT (tok_space);      seq = charmap_find_value (charmap, "carriage-return", 15);      if (seq == NULL)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<carriage-return>");	}      else if (seq->nbytes != 1)	error (0, 0, _("\%s: character `%s' in charmap not representable with one byte"),	       "LC_CTYPE", "<carriage-return>");      else	ctype->class256_collection[seq->bytes[0]] |= BIT (tok_space);      value = repertoire_find_value (repertoire, "tab", 3);      if (value == ILLEGAL_CHAR_VALUE)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<tab>");	}      else	ELEM (ctype, class_collection, , value) |= BIT (tok_space);      seq = charmap_find_value (charmap, "tab", 3);      if (seq == NULL)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<tab>");	}      else if (seq->nbytes != 1)	error (0, 0, _("\%s: character `%s' in charmap not representable with one byte"),	       "LC_CTYPE", "<tab>");      else	ctype->class256_collection[seq->bytes[0]] |= BIT (tok_space);      value = repertoire_find_value (repertoire, "vertical-tab", 12);      if (value == ILLEGAL_CHAR_VALUE)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<vertical-tab>");	}      else	ELEM (ctype, class_collection, , value) |= BIT (tok_space);      seq = charmap_find_value (charmap, "vertical-tab", 12);      if (seq == NULL)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<vertical-tab>");	}      else if (seq->nbytes != 1)	error (0, 0, _("\%s: character `%s' in charmap not representable with one byte"),	       "LC_CTYPE", "<vertical-tab>");      else	ctype->class256_collection[seq->bytes[0]] |= BIT (tok_space);    }  if ((ctype->class_done & BITw (tok_xdigit)) == 0)    /* "If this keyword is not specified, the digits `0' to `9', the        uppercase letters `A' through `F', and the lowercase letters `a'	through `f', ..., shell automatically belong to this class, with	implementation defined character values."  [P1003.2, 2.5.2.1]  */    {      set_default (BITPOS (tok_xdigit), '0', '9');      set_default (BITPOS (tok_xdigit), 'A', 'F');      set_default (BITPOS (tok_xdigit), 'a', 'f');    }  if ((ctype->class_done & BITw (tok_blank)) == 0)    /* "If this keyword [blank] is unspecified, the characters <space> and       <tab> shall belong to this character class."  [P1003.2, 2.5.2.1]  */   {      uint32_t value;      struct charseq *seq;      value = repertoire_find_value (repertoire, "space", 5);      if (value == ILLEGAL_CHAR_VALUE)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<space>");	}      else	ELEM (ctype, class_collection, , value) |= BIT (tok_blank);      seq = charmap_find_value (charmap, "space", 5);      if (seq == NULL)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<space>");	}      else if (seq->nbytes != 1)	error (0, 0, _("\%s: character `%s' in charmap not representable with one byte"),	       "LC_CTYPE", "<space>");      else	ctype->class256_collection[seq->bytes[0]] |= BIT (tok_blank);      value = repertoire_find_value (repertoire, "tab", 3);      if (value == ILLEGAL_CHAR_VALUE)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<tab>");	}      else	ELEM (ctype, class_collection, , value) |= BIT (tok_blank);      seq = charmap_find_value (charmap, "tab", 3);      if (seq == NULL)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<tab>");	}      else if (seq->nbytes != 1)	error (0, 0, _("\%s: character `%s' in charmap not representable with one byte"),	       "LC_CTYPE", "<tab>");      else	ctype->class256_collection[seq->bytes[0]] |= BIT (tok_blank);    }  if ((ctype->class_done & BITw (tok_graph)) == 0)    /* "If this keyword [graph] is not specified, characters specified for        the keywords `upper', `lower', `alpha', `digit', `xdigit' and `punct',	shall belong to this character class."  [P1003.2, 2.5.2.1]  */    {      unsigned long int mask = BIT (tok_upper) | BIT (tok_lower) |	BIT (tok_alpha) | BIT (tok_digit) | BIT (tok_xdigit) | BIT (tok_punct);      size_t cnt;      for (cnt = 0; cnt < ctype->class_collection_act; ++cnt)	if ((ctype->class_collection[cnt] & mask) != 0)	  ctype->class_collection[cnt] |= BIT (tok_graph);      for (cnt = 0; cnt < 256; ++cnt)	if ((ctype->class256_collection[cnt] & mask) != 0)	  ctype->class256_collection[cnt] |= BIT (tok_graph);    }  if ((ctype->class_done & BITw (tok_print)) == 0)    /* "If this keyword [print] is not provided, characters specified for        the keywords `upper', `lower', `alpha', `digit', `xdigit', `punct',	and the <space> character shall belong to this character class."	[P1003.2, 2.5.2.1]  */    {      unsigned long int mask = BIT (tok_upper) | BIT (tok_lower) |	BIT (tok_alpha) | BIT (tok_digit) | BIT (tok_xdigit) | BIT (tok_punct);      size_t cnt;      uint32_t space;      struct charseq *seq;      for (cnt = 0; cnt < ctype->class_collection_act; ++cnt)	if ((ctype->class_collection[cnt] & mask) != 0)	  ctype->class_collection[cnt] |= BIT (tok_print);      for (cnt = 0; cnt < 256; ++cnt)	if ((ctype->class256_collection[cnt] & mask) != 0)	  ctype->class256_collection[cnt] |= BIT (tok_print);      space = repertoire_find_value (repertoire, "space", 5);      if (space == ILLEGAL_CHAR_VALUE)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<space>");	}      else	ELEM (ctype, class_collection, , space) |= BIT (tok_print);      seq = charmap_find_value (charmap, "space", 5);      if (seq == NULL)	{	  if (!be_quiet)	    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		   "LC_CTYPE", "<space>");	}      else if (seq->nbytes != 1)	error (0, 0, _("\%s: character `%s' in charmap not representable with one byte"),	       "LC_CTYPE", "<space>");      else	ctype->class256_collection[seq->bytes[0]] |= BIT (tok_print);    }  if (ctype->tomap_done[0] == 0)    /* "If this keyword [toupper] is not specified, the lowercase letters        `a' through `z', and their corresponding uppercase letters `A' to	`Z', ..., shall automatically be included, with implementation-	defined character values."  [P1003.2, 2.5.2.1]  */    {      char tmp[4];      int ch;      strcpy (tmp, "<?>");      for (ch = 'a'; ch <= 'z'; ++ch)	{	  uint32_t value_from, value_to;	  struct charseq *seq_from, *seq_to;	  tmp[1] = (char) ch;	  value_from = repertoire_find_value (repertoire, &tmp[1], 1);	  if (value_from == ILLEGAL_CHAR_VALUE)	    {	      if (!be_quiet)		error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		       "LC_CTYPE", tmp);	    }	  else	    {	      /* This conversion is implementation defined.  */	      tmp[1] = (char) (ch + ('A' - 'a'));	      value_to = repertoire_find_value (repertoire, &tmp[1], 1);	      if (value_to == ILLEGAL_CHAR_VALUE)		{		  if (!be_quiet)		    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),			   "LC_CTYPE", tmp);		}	      else		/* The index [0] is determined by the order of the		   `ctype_map_newP' calls in `ctype_startup'.  */		ELEM (ctype, map_collection, [0], value_from) = value_to;	    }	  seq_from = charmap_find_value (charmap, &tmp[1], 1);	  if (seq_from == NULL)	    {	      if (!be_quiet)		error (0, 0, _("\%s: character `%s' not defined while needed as default value"),		       "LC_CTYPE", tmp);	    }	  else if (seq_from->nbytes != 1)	    {	      if (!be_quiet)		error (0, 0, _("\%s: character `%s' needed as default value not representable with one byte"),		       "LC_CTYPE", tmp);	    }	  else	    {	      /* This conversion is implementation defined.  */	      tmp[1] = (char) (ch + ('A' - 'a'));	      seq_to = charmap_find_value (charmap, &tmp[1], 1);	      if (seq_to == NULL)		{		  if (!be_quiet)		    error (0, 0, _("\%s: character `%s' not defined while needed as default value"),			   "LC_CTYPE", tmp);		}	      else if (seq_to->nbytes != 1)		{		  if (!be_quiet)		    error (0, 0, _("\%s: character `%s' needed as default value not representable with one byte"),			   "LC_CTYPE", tmp);		}	      else		/* The index [0] is determined by the order of the		   `ctype_map_newP' calls in `ctype_startup'.  */		ctype->map256_collection[0][seq_from->bytes[0]]		  = seq_to->bytes[0];	    }	}    }  if (ctype->tomap_done[1] == 0)    /* "If this keyword [tolower] is not specified, the mapping shall be       the reverse mapping of the one specified to `toupper'."  [P1003.2]  */    {      for (cnt = 0; cnt < ctype->map_collection_act[0]; ++cnt)	if (ctype->map_collection[0][cnt] != 0)	  ELEM (ctype, map_collection, [1],		ctype->map_collection[0][cnt])	    = ctype->charnames[cnt];      for (cnt = 0; cnt < 256; ++cnt)	if (ctype->map256_collection[0][cnt] != 0)	  ctype->map_collection[1][ctype->map_collection[0][cnt]]	    = ctype->charnames[cnt];    }  if (ctype->outdigits_act == 0)    {      for (cnt = 0; cnt < 10; ++cnt)	{	  ctype->mboutdigits[cnt] = charmap_find_symbol (charmap,							 digits + cnt, 1);	  if (ctype->mboutdigits[cnt] == NULL)	    {	      ctype->mboutdigits[cnt] = charmap_find_symbol (charmap,							     longnames[cnt],							     strlen (longnames[cnt]));	      if (ctype->mboutdigits[cnt] == NULL)		{		  /* Provide a replacement.  */		  error (0, 0, _("\no output digits defined and none of the standard names in the charmap"));		  ctype->mboutdigits[cnt] = obstack_alloc (&charmap->mem_pool,							   sizeof (struct charseq) + 1);		  /* This is better than nothing.  */		  ctype->mboutdigits[cnt]->bytes[0] = digits[cnt];		  ctype->mboutdigits[cnt]->nbytes = 1;		}	    }	}      ctype->outdigits_act = 10;    }}