buf = (char *) re_string_get_buffer (mctx->input);
buf = (const char *) re_string_get_buffer (mctx->input);
get_subexp (preg, mctx, bkref_node, bkref_str_idx)     const regex_t *preg;     re_match_context_t *mctx;     int bkref_node, bkref_str_idx;{  int subexp_num, sub_top_idx;  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;  char *buf = (char *) re_string_get_buffer (mctx->input);  /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX.  */  int cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx);  for (; cache_idx < mctx->nbkref_ents; ++cache_idx)    {      struct re_backref_cache_entry *entry = mctx->bkref_ents + cache_idx;      if (entry->str_idx > bkref_str_idx)	break;      if (entry->node == bkref_node)	return REG_NOERROR; /* We already checked it.  */    }  subexp_num = dfa->nodes[bkref_node].opr.idx - 1;  /* For each sub expression  */  for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx)    {      reg_errcode_t err;      re_sub_match_top_t *sub_top = mctx->sub_tops[sub_top_idx];      re_sub_match_last_t *sub_last;      int sub_last_idx, sl_str;      char *bkref_str;      if (dfa->nodes[sub_top->node].opr.idx != subexp_num)	continue; /* It isn't related.  */      sl_str = sub_top->str_idx;      bkref_str = buf + bkref_str_idx;      /* At first, check the last node of sub expressions we already	 evaluated.  */      for (sub_last_idx = 0; sub_last_idx < sub_top->nlasts; ++sub_last_idx)	{	  int sl_str_diff;	  sub_last = sub_top->lasts[sub_last_idx];	  sl_str_diff = sub_last->str_idx - sl_str;	  /* The matched string by the sub expression match with the substring	     at the back reference?  */	  if (sl_str_diff > 0	      && memcmp (bkref_str, buf + sl_str, sl_str_diff) != 0)	    break; /* We don't need to search this sub expression any more.  */	  bkref_str += sl_str_diff;	  sl_str += sl_str_diff;	  err = get_subexp_sub (preg, mctx, sub_top, sub_last, bkref_node,				bkref_str_idx);	  /* Reload buf and bkref_str, since the preceding call might	     have reallocated the buffer.  */	  buf = (char *) re_string_get_buffer (mctx->input);	  bkref_str = buf + bkref_str_idx;	  if (err == REG_NOMATCH)	    continue;	  if (BE (err != REG_NOERROR, 0))	    return err;	}      if (sub_last_idx < sub_top->nlasts)	continue;      if (sub_last_idx > 0)	++sl_str;      /* Then, search for the other last nodes of the sub expression.  */      for (; sl_str <= bkref_str_idx; ++sl_str)	{	  int cls_node, sl_str_off;	  re_node_set *nodes;	  sl_str_off = sl_str - sub_top->str_idx;	  /* The matched string by the sub expression match with the substring	     at the back reference?  */	  if (sl_str_off > 0 && *bkref_str++ != buf[sl_str - 1])	    break; /* We don't need to search this sub expression any more.  */	  if (mctx->state_log[sl_str] == NULL)	    continue;	  /* Does this state have a ')' of the sub expression?  */	  nodes = &mctx->state_log[sl_str]->nodes;	  cls_node = find_subexp_node (dfa, nodes, subexp_num, 0);	  if (cls_node == -1)	    continue; /* No.  */	  if (sub_top->path == NULL)	    {	      sub_top->path = calloc (sizeof (state_array_t),				      sl_str - sub_top->str_idx + 1);	      if (sub_top->path == NULL)		return REG_ESPACE;	    }	  /* Can the OP_OPEN_SUBEXP node arrive the OP_CLOSE_SUBEXP node	     in the current context?  */	  err = check_arrival (preg, mctx, sub_top->path, sub_top->node,			       sub_top->str_idx, cls_node, sl_str, 0);	  if (err == REG_NOMATCH)	      continue;	  if (BE (err != REG_NOERROR, 0))	      return err;	  sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str);	  if (BE (sub_last == NULL, 0))	    return REG_ESPACE;	  err = get_subexp_sub (preg, mctx, sub_top, sub_last, bkref_node,				bkref_str_idx);	  if (err == REG_NOMATCH)	    continue;	}    }  return REG_NOERROR;}