View | Details | Raw Unified | Return to bug 8
Collapse All | Expand All

(-)regexec.c (-3 / +23 lines)
Lines 60-66 static inline re_dfastate_t *acquire_ini Link Here
60
     __attribute ((always_inline)) internal_function;
60
     __attribute ((always_inline)) internal_function;
61
static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx)
61
static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx)
62
     internal_function;
62
     internal_function;
63
static int check_matching (re_match_context_t *mctx, int fl_longest_match)
63
static int check_matching (re_match_context_t *mctx, int fl_longest_match,
64
			   int *p_match_first)
64
     internal_function;
65
     internal_function;
65
static int check_halt_node_context (const re_dfa_t *dfa, int node,
66
static int check_halt_node_context (const re_dfa_t *dfa, int node,
66
				    unsigned int context) internal_function;
67
				    unsigned int context) internal_function;
Lines 745-751 re_search_internal (preg, string, length Link Here
745
	  /* It seems to be appropriate one, then use the matcher.  */
746
	  /* It seems to be appropriate one, then use the matcher.  */
746
	  /* We assume that the matching starts from 0.  */
747
	  /* We assume that the matching starts from 0.  */
747
	  mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0;
748
	  mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0;
748
	  match_last = check_matching (&mctx, fl_longest_match);
749
	  match_last = check_matching (&mctx, fl_longest_match,
750
				       range >= 0 ? &match_first : NULL);
749
	  if (match_last != -1)
751
	  if (match_last != -1)
750
	    {
752
	    {
751
	      if (BE (match_last == -2, 0))
753
	      if (BE (match_last == -2, 0))
Lines 966-978 acquire_init_state_context (err, mctx, i Link Here
966
   and return the index where the matching end, return -1 if not match,
968
   and return the index where the matching end, return -1 if not match,
967
   or return -2 in case of an error.
969
   or return -2 in case of an error.
968
   FL_LONGEST_MATCH means we want the POSIX longest matching.
970
   FL_LONGEST_MATCH means we want the POSIX longest matching.
971
   If P_MATCH_FIRST is not NULL, and the match fails, it is set to the
972
   next place where we may want to try matching.
969
   Note that the matcher assume that the maching starts from the current
973
   Note that the matcher assume that the maching starts from the current
970
   index of the buffer.  */
974
   index of the buffer.  */
971
975
972
static int
976
static int
973
check_matching (mctx, fl_longest_match)
977
check_matching (mctx, fl_longest_match, p_match_first)
974
    re_match_context_t *mctx;
978
    re_match_context_t *mctx;
975
    int fl_longest_match;
979
    int fl_longest_match;
980
    int *p_match_first;
976
{
981
{
977
  re_dfa_t *const dfa = mctx->dfa;
982
  re_dfa_t *const dfa = mctx->dfa;
978
  reg_errcode_t err;
983
  reg_errcode_t err;
Lines 980-985 check_matching (mctx, fl_longest_match) Link Here
980
  int match_last = -1;
985
  int match_last = -1;
981
  int cur_str_idx = re_string_cur_idx (&mctx->input);
986
  int cur_str_idx = re_string_cur_idx (&mctx->input);
982
  re_dfastate_t *cur_state;
987
  re_dfastate_t *cur_state;
988
  int at_init_state = p_match_first != NULL, skipped = 0;
983
989
984
  cur_state = acquire_init_state_context (&err, mctx, cur_str_idx);
990
  cur_state = acquire_init_state_context (&err, mctx, cur_str_idx);
985
  /* An initial state must not be NULL(invalid state).  */
991
  /* An initial state must not be NULL(invalid state).  */
Lines 992-997 check_matching (mctx, fl_longest_match) Link Here
992
     later.  E.g. Processing back references.  */
998
     later.  E.g. Processing back references.  */
993
  if (BE (dfa->nbackref, 0))
999
  if (BE (dfa->nbackref, 0))
994
    {
1000
    {
1001
      at_init_state = 0;
995
      err = check_subexp_matching_top (mctx, &cur_state->nodes, 0);
1002
      err = check_subexp_matching_top (mctx, &cur_state->nodes, 0);
996
      if (BE (err != REG_NOERROR, 0))
1003
      if (BE (err != REG_NOERROR, 0))
997
	return err;
1004
	return err;
Lines 1022-1028 check_matching (mctx, fl_longest_match) Link Here
1022
1029
1023
  while (!re_string_eoi (&mctx->input))
1030
  while (!re_string_eoi (&mctx->input))
1024
    {
1031
    {
1032
      re_dfastate_t *old_state = cur_state;
1025
      cur_state = transit_state (&err, mctx, cur_state);
1033
      cur_state = transit_state (&err, mctx, cur_state);
1034
      if (at_init_state)
1035
	{
1036
	  if (old_state == cur_state)
1037
	    skipped++;
1038
	  else
1039
	    at_init_state = 0;
1040
	}
1041
1026
      if (cur_state == NULL) /* Reached at the invalid state or an error.  */
1042
      if (cur_state == NULL) /* Reached at the invalid state or an error.  */
1027
	{
1043
	{
1028
	  cur_str_idx = re_string_cur_idx (&mctx->input);
1044
	  cur_str_idx = re_string_cur_idx (&mctx->input);
Lines 1062-1067 check_matching (mctx, fl_longest_match) Link Here
1062
	    }
1078
	    }
1063
	}
1079
	}
1064
   }
1080
   }
1081
1082
  if (match_last == -1 && skipped)
1083
    *p_match_first += skipped;
1084
1065
  return match_last;
1085
  return match_last;
1066
}
1086
}
1067
1087

Return to bug 8