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

Function parse_bracket_element

compat/regex/regcomp.c:3346–3380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3344 *err = REG_ESPACE;
3345 parse_bracket_exp_free_return:
3346 re_free (sbcset);
3347#ifdef RE_ENABLE_I18N
3348 free_charset (mbcset);
3349#endif /* RE_ENABLE_I18N */
3350 return NULL;
3351}
3352
3353/* Parse an element in the bracket expression. */
3354
3355static reg_errcode_t
3356parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
3357 re_token_t *token, int token_len, re_dfa_t *dfa,
3358 reg_syntax_t syntax, int accept_hyphen)
3359{
3360#ifdef RE_ENABLE_I18N
3361 int cur_char_size;
3362 cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp));
3363 if (cur_char_size > 1)
3364 {
3365 elem->type = MB_CHAR;
3366 elem->opr.wch = re_string_wchar_at (regexp, re_string_cur_idx (regexp));
3367 re_string_skip_bytes (regexp, cur_char_size);
3368 return REG_NOERROR;
3369 }
3370#endif /* RE_ENABLE_I18N */
3371 re_string_skip_bytes (regexp, token_len); /* Skip a token. */
3372 if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS
3373 || token->type == OP_OPEN_EQUIV_CLASS)
3374 return parse_bracket_symbol (elem, regexp, token);
3375 if (BE (token->type == OP_CHARSET_RANGE, 0) && !accept_hyphen)
3376 {
3377 /* A '-' must only appear as anything but a range indicator before
3378 the closing bracket. Everything else is an error. */
3379 re_token_t token2;
3380 (void) peek_token_bracket (&token2, regexp, syntax);
3381 if (token2.type != OP_CLOSE_BRACKET)
3382 /* The actual error value is not standardized since this whole
3383 case is undefined. But ERANGE makes good sense. */

Callers 1

parse_bracket_expFunction · 0.85

Calls 4

re_string_char_size_atFunction · 0.85
re_string_wchar_atFunction · 0.85
parse_bracket_symbolFunction · 0.85
peek_token_bracketFunction · 0.85

Tested by

no test coverage detected