| 1074 | If P_MATCH_FIRST is not NULL, and the match fails, it is set to the |
| 1075 | next place where we may want to try matching. |
| 1076 | Note that the matcher assume that the matching starts from the current |
| 1077 | index of the buffer. */ |
| 1078 | |
| 1079 | static int |
| 1080 | internal_function |
| 1081 | check_matching (re_match_context_t *mctx, int fl_longest_match, |
| 1082 | int *p_match_first) |
| 1083 | { |
| 1084 | const re_dfa_t *const dfa = mctx->dfa; |
| 1085 | reg_errcode_t err; |
| 1086 | int match = 0; |
| 1087 | int match_last = -1; |
| 1088 | int cur_str_idx = re_string_cur_idx (&mctx->input); |
| 1089 | re_dfastate_t *cur_state; |
| 1090 | int at_init_state = p_match_first != NULL; |
| 1091 | int next_start_idx = cur_str_idx; |
| 1092 | |
| 1093 | err = REG_NOERROR; |
| 1094 | cur_state = acquire_init_state_context (&err, mctx, cur_str_idx); |
| 1095 | /* An initial state must not be NULL (invalid). */ |
| 1096 | if (BE (cur_state == NULL, 0)) |
| 1097 | { |
| 1098 | assert (err == REG_ESPACE); |
| 1099 | return -2; |
| 1100 | } |
| 1101 | |
| 1102 | if (mctx->state_log != NULL) |
| 1103 | { |
| 1104 | mctx->state_log[cur_str_idx] = cur_state; |
| 1105 | |
| 1106 | /* Check OP_OPEN_SUBEXP in the initial state in case that we use them |
| 1107 | later. E.g. Processing back references. */ |
| 1108 | if (BE (dfa->nbackref, 0)) |
| 1109 | { |
| 1110 | at_init_state = 0; |
| 1111 | err = check_subexp_matching_top (mctx, &cur_state->nodes, 0); |
| 1112 | if (BE (err != REG_NOERROR, 0)) |
| 1113 | return err; |
| 1114 | |
| 1115 | if (cur_state->has_backref) |
| 1116 | { |
| 1117 | err = transit_state_bkref (mctx, &cur_state->nodes); |
| 1118 | if (BE (err != REG_NOERROR, 0)) |
| 1119 | return err; |
| 1120 | } |
| 1121 | } |
| 1122 | } |
| 1123 | |
| 1124 | /* If the RE accepts NULL string. */ |
| 1125 | if (BE (cur_state->halt, 0)) |
| 1126 | { |
| 1127 | if (!cur_state->has_constraint |
| 1128 | || check_halt_state_context (mctx, cur_state, cur_str_idx)) |
| 1129 | { |
| 1130 | if (!fl_longest_match) |
| 1131 | return cur_str_idx; |
| 1132 | else |
| 1133 | { |
nothing calls this directly
no test coverage detected