This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Put regexec.c's re_string_t into re_match_context_t


Hi!

This patch on top of
http://sources.redhat.com/ml/libc-alpha/2004-01/msg00019.html
(though it should apply on top of
http://sources.redhat.com/ml/libc-alpha/2004-01/msg00011.html
as well) moves re_search_internal's input into mctx object.
Both objects live for the same time (till re_search_internal
exits) and there is no need to jump between them using pointers.

2004-01-02  Jakub Jelinek  <jakub@redhat.com>

	* posix/regex_internal.h (re_match_context_t): Make input
	re_string_t instead of a pointer to it.
	* posix/regex_internal.c (re_string_construct_common): Don't clear
	pstr here...
	(re_string_construct): ... but only here.
	* posix/regexec.c (match_ctx_init): Remove input argument.  Don't
	initialize fields to zero.
	(re_search_internal): Move input into mctx.input.
	(acquire_init_state_context, check_matching,
	check_halt_state_context, proceed_next_node,
	clean_state_log_if_needed, sift_states_bkref, sift_states_iter_mb,
	transit_state, transit_state_sb, transit_state_mb,
	transit_state_bkref, get_subexp, check_arrival,
	check_arrival_add_next_nodes, check_node_accept, extend_buffers):
	Change mctx->input into &mctx->input and mctx->input->field into
	mctx->input.field.

--- libc/posix/regex_internal.h.jj	2004-01-02 15:42:54.000000000 +0100
+++ libc/posix/regex_internal.h	2004-01-02 15:44:09.000000000 +0100
@@ -547,13 +547,13 @@ struct re_backref_cache_entry
 
 typedef struct
 {
+  /* The string object corresponding to the input string.  */
+  re_string_t input;
   /* EFLAGS of the argument of regexec.  */
   int eflags;
   /* Where the matching ends.  */
   int match_last;
   int last_node;
-  /* The string object corresponding to the input string.  */
-  re_string_t *input;
   /* The state log used by the matcher.  */
   re_dfastate_t **state_log;
   int state_log_top;
--- libc/posix/regex_internal.c.jj	2004-01-02 16:07:25.000000000 +0100
+++ libc/posix/regex_internal.c	2004-01-02 15:55:34.000000000 +0100
@@ -86,6 +86,7 @@ re_string_construct (pstr, str, len, tra
      const re_dfa_t *dfa;
 {
   reg_errcode_t ret;
+  memset (pstr, '\0', sizeof (re_string_t));
   re_string_construct_common (str, len, pstr, trans, icase, dfa);
 
   if (len > 0)
@@ -185,7 +186,6 @@ re_string_construct_common (str, len, ps
      int icase;
      const re_dfa_t *dfa;
 {
-  memset (pstr, '\0', sizeof (re_string_t));
   pstr->raw_mbs = (const unsigned char *) str;
   pstr->len = len;
   pstr->raw_len = len;
--- libc/posix/regexec.c.jj	2004-01-02 15:42:48.000000000 +0100
+++ libc/posix/regexec.c	2004-01-02 15:54:08.000000000 +0100
@@ -19,7 +19,7 @@
    02111-1307 USA.  */
 
 static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
-				     re_string_t *input, int n) internal_function;
+				     int n) internal_function;
 static void match_ctx_clean (re_match_context_t *mctx) internal_function;
 static void match_ctx_free (re_match_context_t *cache) internal_function;
 static void match_ctx_free_subtops (re_match_context_t *mctx) internal_function;
@@ -572,7 +572,6 @@ re_search_internal (preg, string, length
 {
   reg_errcode_t err;
   re_dfa_t *dfa = (re_dfa_t *)preg->buffer;
-  re_string_t input;
   int left_lim, right_lim, incr;
   int fl_longest_match, match_first, match_last = -1;
   int fast_translate, sb;
@@ -610,15 +609,15 @@ re_search_internal (preg, string, length
   /* We must check the longest matching, if nmatch > 0.  */
   fl_longest_match = (nmatch != 0 || dfa->nbackref);
 
-  err = re_string_allocate (&input, string, length, dfa->nodes_len + 1,
+  err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
 			    preg->translate, preg->syntax & RE_ICASE, dfa);
   if (BE (err != REG_NOERROR, 0))
     goto free_return;
-  input.stop = stop;
-  input.raw_stop = stop;
-  input.newline_anchor = preg->newline_anchor;
+  mctx.input.stop = stop;
+  mctx.input.raw_stop = stop;
+  mctx.input.newline_anchor = preg->newline_anchor;
 
-  err = match_ctx_init (&mctx, eflags, &input, dfa->nbackref * 2);
+  err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2);
   if (BE (err != REG_NOERROR, 0))
     goto free_return;
 
@@ -628,7 +627,7 @@ re_search_internal (preg, string, length
      multi character collating element.  */
   if (nmatch > 1 || dfa->has_mb_node)
     {
-      mctx.state_log = re_malloc (re_dfastate_t *, input.bufs_len + 1);
+      mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1);
       if (BE (mctx.state_log == NULL, 0))
 	{
 	  err = REG_ESPACE;
@@ -639,8 +638,8 @@ re_search_internal (preg, string, length
     mctx.state_log = NULL;
 
   match_first = start;
-  input.tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
-		       : CONTEXT_NEWLINE | CONTEXT_BEGBUF);
+  mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
+			   : CONTEXT_NEWLINE | CONTEXT_BEGBUF;
 
   /* Check incrementally whether of not the input string match.  */
   incr = (range < 0) ? -1 : 1;
@@ -706,18 +705,18 @@ re_search_internal (preg, string, length
 		     instead.  */
 		  /* If MATCH_FIRST is out of the valid range, reconstruct the
 		     buffers.  */
-		  if (input.raw_mbs_idx + input.valid_raw_len <= match_first
-		      || match_first < input.raw_mbs_idx)
+		  if (mctx.input.raw_mbs_idx + mctx.input.valid_raw_len <= match_first
+		      || match_first < mctx.input.raw_mbs_idx)
 		    {
-		      err = re_string_reconstruct (&input, match_first, eflags);
+		      err = re_string_reconstruct (&mctx.input, match_first, eflags);
 		      if (BE (err != REG_NOERROR, 0))
 			goto free_return;
 		    }
 		  /* If MATCH_FIRST is out of the buffer, leave it as '\0'.
 		     Note that MATCH_FIRST must not be smaller than 0.  */
 		  ch = ((match_first >= length) ? 0
-		       : re_string_byte_at (&input,
-					    match_first - input.raw_mbs_idx));
+		       : re_string_byte_at (&mctx.input,
+					    match_first - mctx.input.raw_mbs_idx));
 		  if (fastmap[ch])
 		    break;
 		  match_first += incr;
@@ -730,13 +729,13 @@ re_search_internal (preg, string, length
 
       /* Reconstruct the buffers so that the matcher can assume that
 	 the matching starts from the beginning of the buffer.  */
-      err = re_string_reconstruct (&input, match_first, eflags);
+      err = re_string_reconstruct (&mctx.input, match_first, eflags);
       if (BE (err != REG_NOERROR, 0))
 	goto free_return;
 #ifdef RE_ENABLE_I18N
      /* Eliminate it when it is a component of a multibyte character
 	 and isn't the head of a multibyte character.  */
-      if (sb || re_string_first_byte (&input, 0))
+      if (sb || re_string_first_byte (&mctx.input, 0))
 #endif
 	{
 	  /* It seems to be appropriate one, then use the matcher.  */
@@ -809,19 +808,19 @@ re_search_internal (preg, string, length
 	if (pmatch[reg_idx].rm_so != -1)
 	  {
 #ifdef RE_ENABLE_I18N
-	    if (BE (input.offsets_needed != 0, 0))
+	    if (BE (mctx.input.offsets_needed != 0, 0))
 	      {
-		if (pmatch[reg_idx].rm_so == input.valid_len)
-		  pmatch[reg_idx].rm_so += input.valid_raw_len - input.valid_len;
+		if (pmatch[reg_idx].rm_so == mctx.input.valid_len)
+		  pmatch[reg_idx].rm_so += mctx.input.valid_raw_len - mctx.input.valid_len;
 		else
-		  pmatch[reg_idx].rm_so = input.offsets[pmatch[reg_idx].rm_so];
-		if (pmatch[reg_idx].rm_eo == input.valid_len)
-		  pmatch[reg_idx].rm_eo += input.valid_raw_len - input.valid_len;
+		  pmatch[reg_idx].rm_so = mctx.input.offsets[pmatch[reg_idx].rm_so];
+		if (pmatch[reg_idx].rm_eo == mctx.input.valid_len)
+		  pmatch[reg_idx].rm_eo += mctx.input.valid_raw_len - mctx.input.valid_len;
 		else
-		  pmatch[reg_idx].rm_eo = input.offsets[pmatch[reg_idx].rm_eo];
+		  pmatch[reg_idx].rm_eo = mctx.input.offsets[pmatch[reg_idx].rm_eo];
 	      }
 #else
-	    assert (input.offsets_needed == 0);
+	    assert (mctx.input.offsets_needed == 0);
 #endif
 	    pmatch[reg_idx].rm_so += match_first;
 	    pmatch[reg_idx].rm_eo += match_first;
@@ -832,7 +831,7 @@ re_search_internal (preg, string, length
   re_free (mctx.state_log);
   if (dfa->nbackref)
     match_ctx_free (&mctx);
-  re_string_destruct (&input);
+  re_string_destruct (&mctx.input);
   return err;
 }
 
@@ -938,7 +937,7 @@ acquire_init_state_context (err, preg, m
   if (dfa->init_state->has_constraint)
     {
       unsigned int context;
-      context = re_string_context_at (mctx->input, idx - 1, mctx->eflags);
+      context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags);
       if (IS_WORD_CONTEXT (context))
 	return dfa->init_state_word;
       else if (IS_ORDINARY_CONTEXT (context))
@@ -979,7 +978,7 @@ check_matching (preg, mctx, fl_longest_m
   reg_errcode_t err;
   int match = 0;
   int match_last = -1;
-  int cur_str_idx = re_string_cur_idx (mctx->input);
+  int cur_str_idx = re_string_cur_idx (&mctx->input);
   re_dfastate_t *cur_state;
 
   cur_state = acquire_init_state_context (&err, preg, mctx, cur_str_idx);
@@ -1021,12 +1020,12 @@ check_matching (preg, mctx, fl_longest_m
 	}
     }
 
-  while (!re_string_eoi (mctx->input))
+  while (!re_string_eoi (&mctx->input))
     {
       cur_state = transit_state (&err, preg, mctx, cur_state);
       if (cur_state == NULL) /* Reached at the invalid state or an error.  */
 	{
-	  cur_str_idx = re_string_cur_idx (mctx->input);
+	  cur_str_idx = re_string_cur_idx (&mctx->input);
 	  if (BE (err != REG_NOERROR, 0))
 	    return -2;
 	  if (!fl_longest_match && match)
@@ -1053,10 +1052,10 @@ check_matching (preg, mctx, fl_longest_m
 	     Check the halt state can satisfy the current context.  */
 	  if (!cur_state->has_constraint
 	      || check_halt_state_context (preg, cur_state, mctx,
-					   re_string_cur_idx (mctx->input)))
+					   re_string_cur_idx (&mctx->input)))
 	    {
 	      /* We found an appropriate halt state.  */
-	      match_last = re_string_cur_idx (mctx->input);
+	      match_last = re_string_cur_idx (&mctx->input);
 	      match = 1;
 	      if (!fl_longest_match)
 		break;
@@ -1101,7 +1100,7 @@ check_halt_state_context (preg, state, m
 #ifdef DEBUG
   assert (state->halt);
 #endif
-  context = re_string_context_at (mctx->input, idx, mctx->eflags);
+  context = re_string_context_at (&mctx->input, idx, mctx->eflags);
   for (i = 0; i < state->nodes.nelem; ++i)
     if (check_halt_node_context (dfa, state->nodes.elems[i], context))
       return state->nodes.elems[i];
@@ -1160,7 +1159,7 @@ proceed_next_node (preg, nregs, regs, mc
 
 #ifdef RE_ENABLE_I18N
       if (ACCEPT_MB_NODE (type))
-	naccepted = check_node_accept_bytes (preg, node, mctx->input, *pidx);
+	naccepted = check_node_accept_bytes (preg, node, &mctx->input, *pidx);
       else
 #endif /* RE_ENABLE_I18N */
       if (type == OP_BACK_REF)
@@ -1173,7 +1172,7 @@ proceed_next_node (preg, nregs, regs, mc
 		return -1;
 	      else if (naccepted)
 		{
-		  char *buf = (char *) re_string_get_buffer (mctx->input);
+		  char *buf = (char *) re_string_get_buffer (&mctx->input);
 		  if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
 			      naccepted) != 0)
 		    return -1;
@@ -1556,9 +1555,9 @@ clean_state_log_if_needed (mctx, next_st
 {
   int top = mctx->state_log_top;
 
-  if (next_state_log_idx >= mctx->input->bufs_len
-      || (next_state_log_idx >= mctx->input->valid_len
-	  && mctx->input->valid_len < mctx->input->len))
+  if (next_state_log_idx >= mctx->input.bufs_len
+      || (next_state_log_idx >= mctx->input.valid_len
+	  && mctx->input.valid_len < mctx->input.len))
     {
       reg_errcode_t err;
       err = extend_buffers (mctx);
@@ -1977,7 +1976,7 @@ sift_states_bkref (preg, mctx, sctx, str
 
   for (node_idx = 0; node_idx < candidates->nelem; ++node_idx)
     {
-      int cur_bkref_idx = re_string_cur_idx (mctx->input);
+      int cur_bkref_idx = re_string_cur_idx (&mctx->input);
       re_token_type_t type;
       node = candidates->elems[node_idx];
       type = dfa->nodes[node].type;
@@ -2092,7 +2091,7 @@ sift_states_iter_mb (preg, mctx, sctx, n
   re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
   int naccepted;
   /* Check the node can accept `multi byte'.  */
-  naccepted = check_node_accept_bytes (preg, node_idx, mctx->input, str_idx);
+  naccepted = check_node_accept_bytes (preg, node_idx, &mctx->input, str_idx);
   if (naccepted > 0 && str_idx + naccepted <= max_str_idx &&
       !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted],
 			    dfa->nexts[node_idx]))
@@ -2126,9 +2125,9 @@ transit_state (err, preg, mctx, state)
   unsigned char ch;
   int cur_idx;
 
-  if (re_string_cur_idx (mctx->input) + 1 >= mctx->input->bufs_len
-      || (re_string_cur_idx (mctx->input) + 1 >= mctx->input->valid_len
-	  && mctx->input->valid_len < mctx->input->len))
+  if (re_string_cur_idx (&mctx->input) + 1 >= mctx->input.bufs_len
+      || (re_string_cur_idx (&mctx->input) + 1 >= mctx->input.valid_len
+	  && mctx->input.valid_len < mctx->input.len))
     {
       *err = extend_buffers (mctx);
       if (BE (*err != REG_NOERROR, 0))
@@ -2139,7 +2138,7 @@ transit_state (err, preg, mctx, state)
   if (state == NULL)
     {
       next_state = state;
-      re_string_skip_bytes (mctx->input, 1);
+      re_string_skip_bytes (&mctx->input, 1);
     }
   else
     {
@@ -2157,7 +2156,7 @@ transit_state (err, preg, mctx, state)
       if (1)
 	{
 	  /* Use transition table  */
-	  ch = re_string_fetch_byte (mctx->input);
+	  ch = re_string_fetch_byte (&mctx->input);
 	  trtable = state->trtable;
 	  if (trtable == NULL)
 	    {
@@ -2172,8 +2171,8 @@ transit_state (err, preg, mctx, state)
 	    {
 	      unsigned int context;
 	      context
-		= re_string_context_at (mctx->input,
-					re_string_cur_idx (mctx->input) - 1,
+		= re_string_context_at (&mctx->input,
+					re_string_cur_idx (&mctx->input) - 1,
 					mctx->eflags);
 	      if (IS_WORD_CONTEXT (context))
 		next_state = trtable[ch + SBC_MAX];
@@ -2194,7 +2193,7 @@ transit_state (err, preg, mctx, state)
 #endif
     }
 
-  cur_idx = re_string_cur_idx (mctx->input);
+  cur_idx = re_string_cur_idx (&mctx->input);
   /* Update the state_log if we need.  */
   if (mctx->state_log != NULL)
     {
@@ -2231,8 +2230,8 @@ transit_state (err, preg, mctx, state)
 	  /* Note: We already add the nodes of the initial state,
 		   then we don't need to add them here.  */
 
-	  context = re_string_context_at (mctx->input,
-					  re_string_cur_idx (mctx->input) - 1,
+	  context = re_string_context_at (&mctx->input,
+					  re_string_cur_idx (&mctx->input) - 1,
 					  mctx->eflags);
 	  next_state = mctx->state_log[cur_idx]
 	    = re_acquire_state_context (err, dfa, &next_nodes, context);
@@ -2317,7 +2316,7 @@ transit_state_sb (err, preg, state, mctx
   re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
   re_node_set next_nodes;
   re_dfastate_t *next_state;
-  int node_cnt, cur_str_idx = re_string_cur_idx (mctx->input);
+  int node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input);
   unsigned int context;
 
   *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1);
@@ -2337,13 +2336,13 @@ transit_state_sb (err, preg, state, mctx
 	    }
 	}
     }
-  context = re_string_context_at (mctx->input, cur_str_idx, mctx->eflags);
+  context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags);
   next_state = re_acquire_state_context (err, dfa, &next_nodes, context);
   /* We don't need to check errors here, since the return value of
      this function is next_state and ERR is already set.  */
 
   re_node_set_free (&next_nodes);
-  re_string_skip_bytes (mctx->input, 1);
+  re_string_skip_bytes (&mctx->input, 1);
   return next_state;
 }
 #endif
@@ -2369,8 +2368,8 @@ transit_state_mb (preg, pstate, mctx)
 
       if (dfa->nodes[cur_node_idx].constraint)
 	{
-	  context = re_string_context_at (mctx->input,
-					  re_string_cur_idx (mctx->input),
+	  context = re_string_context_at (&mctx->input,
+					  re_string_cur_idx (&mctx->input),
 					  mctx->eflags);
 	  if (NOT_SATISFY_NEXT_CONSTRAINT (dfa->nodes[cur_node_idx].constraint,
 					   context))
@@ -2379,13 +2378,13 @@ transit_state_mb (preg, pstate, mctx)
 
       /* How many bytes the node can accept?  */
       if (ACCEPT_MB_NODE (dfa->nodes[cur_node_idx].type))
-	naccepted = check_node_accept_bytes (preg, cur_node_idx, mctx->input,
-					     re_string_cur_idx (mctx->input));
+	naccepted = check_node_accept_bytes (preg, cur_node_idx, &mctx->input,
+					     re_string_cur_idx (&mctx->input));
       if (naccepted == 0)
 	continue;
 
       /* The node can accepts `naccepted' bytes.  */
-      dest_idx = re_string_cur_idx (mctx->input) + naccepted;
+      dest_idx = re_string_cur_idx (&mctx->input) + naccepted;
       mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted
 			       : mctx->max_mb_elem_len);
       err = clean_state_log_if_needed (mctx, dest_idx);
@@ -2408,7 +2407,7 @@ transit_state_mb (preg, pstate, mctx)
 	  if (BE (err != REG_NOERROR, 0))
 	    return err;
 	}
-      context = re_string_context_at (mctx->input, dest_idx - 1, mctx->eflags);
+      context = re_string_context_at (&mctx->input, dest_idx - 1, mctx->eflags);
       mctx->state_log[dest_idx]
 	= re_acquire_state_context (&err, dfa, &dest_nodes, context);
       if (dest_state != NULL)
@@ -2429,7 +2428,7 @@ transit_state_bkref (preg, nodes, mctx)
   reg_errcode_t err;
   re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
   int i;
-  int cur_str_idx = re_string_cur_idx (mctx->input);
+  int cur_str_idx = re_string_cur_idx (&mctx->input);
 
   for (i = 0; i < nodes->nelem; ++i)
     {
@@ -2445,7 +2444,7 @@ transit_state_bkref (preg, nodes, mctx)
 
       if (node->constraint)
 	{
-	  context = re_string_context_at (mctx->input, cur_str_idx,
+	  context = re_string_context_at (&mctx->input, cur_str_idx,
 					  mctx->eflags);
 	  if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context))
 	    continue;
@@ -2477,7 +2476,7 @@ transit_state_bkref (preg, nodes, mctx)
 			    : dfa->eclosures + dfa->nexts[node_idx]);
 	  dest_str_idx = (cur_str_idx + bkref_ent->subexp_to
 			  - bkref_ent->subexp_from);
-	  context = re_string_context_at (mctx->input, dest_str_idx - 1,
+	  context = re_string_context_at (&mctx->input, dest_str_idx - 1,
 					  mctx->eflags);
 	  dest_state = mctx->state_log[dest_str_idx];
 	  prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0
@@ -2544,7 +2543,7 @@ get_subexp (preg, mctx, bkref_node, bkre
 {
   int subexp_num, sub_top_idx;
   re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
-  const char *buf = (const char *) re_string_get_buffer (mctx->input);
+  const char *buf = (const 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)
@@ -2591,7 +2590,7 @@ get_subexp (preg, mctx, bkref_node, bkre
 
 	  /* Reload buf, since the preceding call might have reallocated
 	     the buffer.  */
-	  buf = (const char *) re_string_get_buffer (mctx->input);
+	  buf = (const char *) re_string_get_buffer (&mctx->input);
 
 	  if (err == REG_NOMATCH)
 	    continue;
@@ -2747,12 +2746,12 @@ check_arrival (preg, mctx, path, top_nod
 
   /* Temporary modify MCTX.  */
   backup_state_log = mctx->state_log;
-  backup_cur_idx = mctx->input->cur_idx;
+  backup_cur_idx = mctx->input.cur_idx;
   mctx->state_log = path->array;
-  mctx->input->cur_idx = str_idx;
+  mctx->input.cur_idx = str_idx;
 
   /* Setup initial node set.  */
-  context = re_string_context_at (mctx->input, str_idx - 1, mctx->eflags);
+  context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
   if (str_idx == top_str)
     {
       err = re_node_set_init_1 (&next_nodes, top_node);
@@ -2838,7 +2837,7 @@ check_arrival (preg, mctx, path, top_nod
 	      return err;
 	    }
 	}
-      context = re_string_context_at (mctx->input, str_idx - 1, mctx->eflags);
+      context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
       cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
       if (BE (cur_state == NULL && err != REG_NOERROR, 0))
 	{
@@ -2855,7 +2854,7 @@ check_arrival (preg, mctx, path, top_nod
 
   /* Fix MCTX.  */
   mctx->state_log = backup_state_log;
-  mctx->input->cur_idx = backup_cur_idx;
+  mctx->input.cur_idx = backup_cur_idx;
 
   /* Then check the current node set has the node LAST_NODE.  */
   if (cur_nodes != NULL && re_node_set_contains (cur_nodes, last_node))
@@ -2895,7 +2894,7 @@ check_arrival_add_next_nodes (preg, dfa,
       /* If the node may accept `multi byte'.  */
       if (ACCEPT_MB_NODE (type))
 	{
-	  naccepted = check_node_accept_bytes (preg, cur_node, mctx->input,
+	  naccepted = check_node_accept_bytes (preg, cur_node, &mctx->input,
 					       str_idx);
 	  if (naccepted > 1)
 	    {
@@ -3872,12 +3871,12 @@ check_node_accept (preg, node, mctx, idx
     {
       /* The node has constraints.  Check whether the current context
 	 satisfies the constraints.  */
-      unsigned int context = re_string_context_at (mctx->input, idx,
+      unsigned int context = re_string_context_at (&mctx->input, idx,
 						   mctx->eflags);
       if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context))
 	return 0;
     }
-  ch = re_string_byte_at (mctx->input, idx);
+  ch = re_string_byte_at (&mctx->input, idx);
   switch (node->type)
     {
     case CHARACTER:
@@ -3905,7 +3904,7 @@ extend_buffers (mctx)
      re_match_context_t *mctx;
 {
   reg_errcode_t ret;
-  re_string_t *pstr = mctx->input;
+  re_string_t *pstr = &mctx->input;
 
   /* Double the lengthes of the buffers.  */
   ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
@@ -3960,13 +3959,11 @@ extend_buffers (mctx)
 /* Initialize MCTX.  */
 
 static reg_errcode_t
-match_ctx_init (mctx, eflags, input, n)
+match_ctx_init (mctx, eflags, n)
     re_match_context_t *mctx;
     int eflags, n;
-    re_string_t *input;
 {
   mctx->eflags = eflags;
-  mctx->input = input;
   mctx->match_last = -1;
   if (n > 0)
     {
@@ -3975,12 +3972,13 @@ match_ctx_init (mctx, eflags, input, n)
       if (BE (mctx->bkref_ents == NULL || mctx->sub_tops == NULL, 0))
 	return REG_ESPACE;
     }
-  else
-    mctx->bkref_ents = NULL;
-  mctx->nbkref_ents = 0;
+  /* Already zero-ed by the caller.
+     else
+       mctx->bkref_ents = NULL;
+     mctx->nbkref_ents = 0;
+     mctx->nsub_tops = 0;  */
   mctx->abkref_ents = n;
   mctx->max_mb_elem_len = 1;
-  mctx->nsub_tops = 0;
   mctx->asub_tops = n;
   return REG_NOERROR;
 }

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]