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

Function parse_reg_exp

compat/regex/regcomp.c:2151–2181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2149}
2150
2151/* This function build the following tree, from regular expression
2152 <branch1>|<branch2>:
2153 ALT
2154 / \
2155 / \
2156 <branch1> <branch2>
2157
2158 ALT means alternative, which represents the operator `|'. */
2159
2160static bin_tree_t *
2161parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2162 reg_syntax_t syntax, int nest, reg_errcode_t *err)
2163{
2164 re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
2165 bin_tree_t *tree, *branch = NULL;
2166 tree = parse_branch (regexp, preg, token, syntax, nest, err);
2167 if (BE (*err != REG_NOERROR && tree == NULL, 0))
2168 return NULL;
2169
2170 while (token->type == OP_ALT)
2171 {
2172 fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE);
2173 if (token->type != OP_ALT && token->type != END_OF_RE
2174 && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
2175 {
2176 branch = parse_branch (regexp, preg, token, syntax, nest, err);
2177 if (BE (*err != REG_NOERROR && branch == NULL, 0))
2178 return NULL;
2179 }
2180 else
2181 branch = NULL;
2182 tree = create_tree (dfa, tree, branch, OP_ALT);
2183 if (BE (tree == NULL, 0))
2184 {

Callers 2

parseFunction · 0.85
parse_sub_expFunction · 0.85

Calls 2

parse_branchFunction · 0.85
create_treeFunction · 0.85

Tested by

no test coverage detected