MCPcopy Create free account
hub / github.com/git/git / check_node_accept

Function check_node_accept

compat/regex/regexec.c:4043–4089  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4041# endif /* _LIBC */
4042#endif /* RE_ENABLE_I18N */
4043
4044/* Check whether the node accepts the byte which is IDX-th
4045 byte of the INPUT. */
4046
4047static int
4048internal_function
4049check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
4050 int idx)
4051{
4052 unsigned char ch;
4053 ch = re_string_byte_at (&mctx->input, idx);
4054 switch (node->type)
4055 {
4056 case CHARACTER:
4057 if (node->opr.c != ch)
4058 return 0;
4059 break;
4060
4061 case SIMPLE_BRACKET:
4062 if (!bitset_contain (node->opr.sbcset, ch))
4063 return 0;
4064 break;
4065
4066#ifdef RE_ENABLE_I18N
4067 case OP_UTF8_PERIOD:
4068 if (ch >= 0x80)
4069 return 0;
4070 /* FALLTHROUGH */
4071#endif
4072 case OP_PERIOD:
4073 if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE))
4074 || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL)))
4075 return 0;
4076 break;
4077
4078 default:
4079 return 0;
4080 }
4081
4082 if (node->constraint)
4083 {
4084 /* The node has constraints. Check whether the current context
4085 satisfies the constraints. */
4086 unsigned int context = re_string_context_at (&mctx->input, idx,
4087 mctx->eflags);
4088 if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context))
4089 return 0;
4090 }
4091
4092 return 1;

Callers 4

proceed_next_nodeFunction · 0.85
build_sifted_statesFunction · 0.85
transit_state_sbFunction · 0.85

Calls 1

re_string_context_atFunction · 0.85

Tested by

no test coverage detected