int mlen;
int mlen = raw + pstr->len - p; unsigned char buf[6];
re_string_reconstruct (pstr, idx, eflags, newline)     re_string_t *pstr;     int idx, eflags, newline;{  int offset = idx - pstr->raw_mbs_idx;  if (offset < 0)    {      /* Reset buffer.  */#ifdef RE_ENABLE_I18N      if (pstr->mb_cur_max > 1)	memset (&pstr->cur_state, '\0', sizeof (mbstate_t));#endif /* RE_ENABLE_I18N */      pstr->len += pstr->raw_mbs_idx;      pstr->stop += pstr->raw_mbs_idx;      pstr->valid_len = pstr->raw_mbs_idx = 0;      pstr->tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF			   : CONTEXT_NEWLINE | CONTEXT_BEGBUF);      if (!MBS_CASE_ALLOCATED (pstr))	pstr->mbs_case = (unsigned char *) pstr->raw_mbs;      if (!MBS_ALLOCATED (pstr) && !MBS_CASE_ALLOCATED (pstr))	pstr->mbs = (unsigned char *) pstr->raw_mbs;      offset = idx;    }  if (offset != 0)    {      /* Are the characters which are already checked remain?  */      if (offset < pstr->valid_len)	{	  /* Yes, move them to the front of the buffer.  */	  pstr->tip_context = re_string_context_at (pstr, offset - 1, eflags,						    newline);#ifdef RE_ENABLE_I18N	  if (pstr->mb_cur_max > 1)	    memmove (pstr->wcs, pstr->wcs + offset,		     (pstr->valid_len - offset) * sizeof (wint_t));#endif /* RE_ENABLE_I18N */	  if (MBS_ALLOCATED (pstr))	    memmove (pstr->mbs, pstr->mbs + offset,		     pstr->valid_len - offset);	  if (MBS_CASE_ALLOCATED (pstr))	    memmove (pstr->mbs_case, pstr->mbs_case + offset,		     pstr->valid_len - offset);	  pstr->valid_len -= offset;#if DEBUG	  assert (pstr->valid_len > 0);#endif	}      else	{	  /* No, skip all characters until IDX.  */	  pstr->valid_len = 0;#ifdef RE_ENABLE_I18N	  if (pstr->mb_cur_max > 1)	    {	      int wcs_idx;	      wint_t wc = WEOF;	      if (pstr->is_utf8)		{		  const unsigned char *raw, *p, *end;		  /* Special case UTF-8.  Multi-byte chars start with any		     byte other than 0x80 - 0xbf.  */		  raw = pstr->raw_mbs + pstr->raw_mbs_idx;		  end = raw + (offset - pstr->mb_cur_max);		  for (p = raw + offset - 1; p >= end; --p)		    if ((*p & 0xc0) != 0x80)		      {			mbstate_t cur_state;			wchar_t wc2;			int mlen;			/* XXX Don't use mbrtowc, we know which conversion			   to use (UTF-8 -> UCS4).  */			memset (&cur_state, 0, sizeof (cur_state));			mlen = mbrtowc (&wc2, p, raw + pstr->len - p,					&cur_state) - (raw + offset - p);			if (mlen >= 0)			  {			    memset (&pstr->cur_state, '\0',				    sizeof (mbstate_t));			    pstr->valid_len = mlen;			    wc = wc2;			  }			break;		      }		}	      if (wc == WEOF)		pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx;	      for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)		pstr->wcs[wcs_idx] = WEOF;	      if (pstr->trans && wc <= 0xff)		wc = pstr->trans[wc];	      pstr->tip_context = (IS_WIDE_WORD_CHAR (wc) ? CONTEXT_WORD				   : ((newline && IS_WIDE_NEWLINE (wc))				      ? CONTEXT_NEWLINE : 0));	    }	  else#endif /* RE_ENABLE_I18N */	    {	      int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];	      if (pstr->trans)		c = pstr->trans[c];	      pstr->tip_context = (IS_WORD_CHAR (c) ? CONTEXT_WORD				   : ((newline && IS_NEWLINE (c))				      ? CONTEXT_NEWLINE : 0));	    }	}      if (!MBS_CASE_ALLOCATED (pstr))	{	  pstr->mbs_case += offset;	  /* In case of !MBS_ALLOCATED && !MBS_CASE_ALLOCATED.  */	  if (!MBS_ALLOCATED (pstr))	    pstr->mbs += offset;	}    }  pstr->raw_mbs_idx = idx;  pstr->len -= offset;  pstr->stop -= offset;  /* Then build the buffers.  */#ifdef RE_ENABLE_I18N  if (pstr->mb_cur_max > 1)    {      if (pstr->icase)	build_wcs_upper_buffer (pstr);      else	build_wcs_buffer (pstr);    }  else#endif /* RE_ENABLE_I18N */    {      if (pstr->icase)	build_upper_buffer (pstr);      else if (pstr->trans != NULL)	re_string_translate_buffer (pstr);      else	pstr->valid_len = pstr->len;    }  pstr->cur_idx = 0;  return REG_NOERROR;}