if (insert_entry (&collate->result, name, sizeof (wchar_t), (void *) pelem->next) < 0) error (4, 0, _("cannot insert into result table"));
{ pelem->next = NULL; if (insert_entry (&collate->result, name, sizeof (wchar_t), (void *) pelem) < 0) error (4, 0, _("cannot insert into result table")); }
collate_order_elem (struct linereader *lr, struct localedef_t *locale,		    struct token *code, struct charset_t *charset){  const wchar_t zero = L'\0';  struct locale_collate_t *collate = locale->categories[LC_COLLATE].collate;  int result = 0;  wchar_t value;  void *tmp;  unsigned int i;  switch (code->tok)    {    case tok_bsymbol:      /* We have a string to find in one of the three hashing tables.  */      value = charset_find_value (charset, code->val.str.start,				  code->val.str.len);      if (value != ILLEGAL_CHAR_VALUE)	{	  element_t *lastp, *firstp;	  collate->kind = character;	  if (find_entry (&collate->result, &value, sizeof (wchar_t),			  (void *) &firstp) < 0)	    firstp = lastp = NULL;	  else	    {	      /* The entry for the simple character is always found at		 the end.  */	      lastp = firstp;	      while (lastp->next != NULL)		lastp = lastp->next;	      if (lastp->name[0] == value && lastp->name[1] == L'\0')		{		  lr_error (lr, _("duplicate definition for character `%.*s'"),			    (int) code->val.str.len, code->val.str.start);		  lr_ignore_rest (lr, 0);		  result = -1;		  break;		}	    }	  collate->current_element	    = (element_t *) obstack_alloc (&collate->element_mem,					   sizeof (element_t));	  obstack_grow (&collate->element_mem, &value, sizeof (value));	  obstack_grow (&collate->element_mem, &zero, sizeof (zero));	  collate->current_element->name =	    (const wchar_t *) obstack_finish (&collate->element_mem);	  collate->current_element->this_weight = ++collate->order_cnt;	  collate->current_element->next = NULL;	  if (firstp == NULL)	    {	      if (insert_entry (&collate->result, &value, sizeof (wchar_t),				(void *) collate->current_element) < 0)		{		  lr_error (lr, _("cannot insert collation element `%.*s'"),			    (int) code->val.str.len, code->val.str.start);		  exit (4);		}	    }	  else	    lastp->next = collate->current_element;	}      else if (find_entry (&collate->elements, code->val.str.start,			   code->val.str.len, &tmp) >= 0)	{	  collate->current_element = (element_t *) tmp;	  if (collate->current_element->this_weight != 0)	    {	      lr_error (lr, _("\collation element `%.*s' appears more than once: ignore line"),			(int) code->val.str.len, code->val.str.start);	      lr_ignore_rest (lr, 0);	      result = -1;	      break;	    }	  collate->kind = element;	  collate->current_element->this_weight = ++collate->order_cnt;	}      else if (find_entry (&collate->symbols, code->val.str.start,			   code->val.str.len, &tmp) >= 0)	{	  unsigned int order = ++collate->order_cnt;	  if ((unsigned long int) tmp != 0ul)	    {	      lr_error (lr, _("\collation symbol `%.*s' appears more than once: ignore line"),			(int) code->val.str.len, code->val.str.start);	      lr_ignore_rest (lr, 0);	      result = -1;	      break;	    }	  collate->kind = symbol;	  if (set_entry (&collate->symbols, code->val.str.start,			 code->val.str.len, (void *) order) < 0)	    {	      lr_error (lr, _("cannot process order specification"));	      exit (4);	    }	}      else	{	  if (verbose)	    lr_error (lr, _("unknown symbol `%.*s': line ignored"),		      (int) code->val.str.len, code->val.str.start);          lr_ignore_rest (lr, 0);          result = -1;	}      break;    case tok_undefined:      collate->kind = undefined;      collate->current_element = &collate->undefined;      break;    case tok_ellipsis:      if (collate->was_ellipsis)	{	  lr_error (lr, _("\two lines in a row containing `...' are not allowed"));	  result = -1;	}      else if (collate->kind != character)	{	  /* An ellipsis requires the previous line to be an	     character definition.  */	  lr_error (lr, _("\line before ellipsis does not contain definition for character constant"));	  lr_ignore_rest (lr, 0);	  result = -1;	}      else	collate->kind = ellipsis;      break;    default:      assert (! "illegal token in `collate_order_elem'");    }  /* Now it's time to handle the ellipsis in the previous line.  We do     this only when the last line contained an definition for a     character, the current line also defines an character, the     character code for the later is bigger than the former.  */  if (collate->was_ellipsis)    {      if (collate->kind != character)	{	  lr_error (lr, _("\line after ellipsis must contain character definition"));	  lr_ignore_rest (lr, 0);	  result = -1;	}      else if (collate->last_char > value)	{	  lr_error (lr, _("end point of ellipsis range is bigger then start"));	  lr_ignore_rest (lr, 0);	  result = -1;	}      else	{	  /* We can fill the arrays with the information we need.  */	  wchar_t name[2];	  unsigned int *data;	  size_t *ptr;	  size_t cnt;	  name[0] = collate->last_char + 1;	  name[1] = L'\0';	  data = (unsigned int *) alloca ((collate->nrules + collate->nweight)					  * sizeof (unsigned int));	  ptr = (size_t *) alloca (collate->nrules * sizeof (size_t));	  if (data == NULL || ptr == NULL)	    error (4, 0, _("memory exhausted"));	  /* Prepare data.  Because the characters covered by an	     ellipsis all have equal values we prepare the data once	     and only change the variable number (if there are any).	     PTR[...] will point to the entries which will have to be	     fixed during the output loop.  */	  for (cnt = 0; cnt < collate->nrules; ++cnt)	    {	      data[cnt] = collate->weight_cnt[cnt];	      ptr[cnt] = (cnt == 0			  ? collate->nweight			  : ptr[cnt - 1] + collate->weight_cnt[cnt - 1]);	    }	  for (cnt = 0; cnt < collate->nweight; ++cnt)	    data[collate->nrules + cnt] = collate->weight[cnt];	  for (cnt = 0; cnt < collate->nrules; ++cnt)	    if ((wchar_t) data[ptr[cnt]] != ELLIPSIS_CHAR)	      ptr[cnt] = 0;	  while (name[0] <= value)	    {	      element_t *pelem;	      pelem = (element_t *) obstack_alloc (&collate->element_mem,						   sizeof (element_t));	      if (pelem == NULL)		error (4, 0, _("memory exhausted"));	      pelem->name		= (const wchar_t *) obstack_copy (&collate->element_mem,						  name, 2 * sizeof (wchar_t));	      pelem->this_weight = ++collate->order_cnt;	      pelem->ordering_len = collate->nweight;	      pelem->ordering		= (unsigned int *) obstack_copy (&collate->element_mem, data,						 (collate->nrules						  * pelem->ordering_len)						 * sizeof (unsigned int));	      /* `...' weights need to be adjusted.  */	      for (cnt = 0; cnt < collate->nrules; ++cnt)		if (ptr[cnt] != 0)		  pelem->ordering[ptr[cnt]] = pelem->this_weight;	      /* Insert new entry into result table.  */	      if (find_entry (&collate->result, name, sizeof (wchar_t),			      (void *) &pelem->next) >= 0)		{		  if (set_entry (&collate->result, name, sizeof (wchar_t),				 (void *) pelem->next) < 0)		    error (4, 0, _("cannot insert into result table"));		}	      else		if (insert_entry (&collate->result, name, sizeof (wchar_t),				  (void *) pelem->next) < 0)		  error (4, 0, _("cannot insert into result table"));	      /* Increment counter.  */	      ++name[0];	    }	}    }  /* Reset counters for weights.  */  collate->weight_idx = 0;  collate->nweight = 0;  for (i = 0; i < collate->nrules; ++i)    collate->weight_cnt[i] = 0;  collate->current_patch = NULL;  return result;}