| 1032 | |
| 1033 | /* Acquire an initial state and return it. |
| 1034 | We must select appropriate initial state depending on the context, |
| 1035 | since initial states may have constraints like "\<", "^", etc.. */ |
| 1036 | |
| 1037 | static inline re_dfastate_t * |
| 1038 | __attribute ((always_inline)) internal_function |
| 1039 | acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx, |
| 1040 | int idx) |
| 1041 | { |
| 1042 | const re_dfa_t *const dfa = mctx->dfa; |
| 1043 | if (dfa->init_state->has_constraint) |
| 1044 | { |
| 1045 | unsigned int context; |
| 1046 | context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags); |
| 1047 | if (IS_WORD_CONTEXT (context)) |
| 1048 | return dfa->init_state_word; |
| 1049 | else if (IS_ORDINARY_CONTEXT (context)) |
| 1050 | return dfa->init_state; |
| 1051 | else if (IS_BEGBUF_CONTEXT (context) && IS_NEWLINE_CONTEXT (context)) |
| 1052 | return dfa->init_state_begbuf; |
| 1053 | else if (IS_NEWLINE_CONTEXT (context)) |
| 1054 | return dfa->init_state_nl; |
| 1055 | else if (IS_BEGBUF_CONTEXT (context)) |
| 1056 | { |
| 1057 | /* It is relatively rare case, then calculate on demand. */ |
| 1058 | return re_acquire_state_context (err, dfa, |
| 1059 | dfa->init_state->entrance_nodes, |
| 1060 | context); |
| 1061 | } |
| 1062 | else |
| 1063 | /* Must not happen? */ |
| 1064 | return dfa->init_state; |
| 1065 | } |
| 1066 | else |
| 1067 | return dfa->init_state; |
| 1068 | } |
nothing calls this directly
no test coverage detected