X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fregex%2Fregcomp.c;h=399989e7905b8a23ce53ad74cef49bc4c94710d6;hp=fa79e2e5f47491dc39066a75364e159d68dbd7f6;hb=c87584a3e962dabd7b97733bfc3700e003d87d28;hpb=d7a90b35b9b5336a3e730e09d56f1c53f4e946ee diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c index fa79e2e5..399989e7 100644 --- a/src/regex/regcomp.c +++ b/src/regex/regcomp.c @@ -1052,8 +1052,6 @@ tre_parse(tre_parse_ctx_t *ctx) } case PARSE_UNION: - if (!*ctx->re) - break; switch (*ctx->re) { case CHAR_PIPE: @@ -1086,8 +1084,6 @@ tre_parse(tre_parse_ctx_t *ctx) case PARSE_POSTFIX: /* Parse postfix operators. */ - if (!*ctx->re) - break; switch (*ctx->re) { case CHAR_PLUS: @@ -1149,10 +1145,6 @@ tre_parse(tre_parse_ctx_t *ctx) an empty set of `()', a bracket expression, `.', `^', `$', a `\' followed by a character, or a single character. */ - /* End of regexp? (empty string). */ - if (!*ctx->re) - goto parse_literal; - switch (*ctx->re) { case CHAR_LPAREN: /* parenthesized subexpression */ @@ -1190,7 +1182,7 @@ tre_parse(tre_parse_ctx_t *ctx) ctx->re++; goto lparen; } - if (!(ctx->cflags & REG_EXTENDED) && *(ctx->re + 1) == CHAR_LPAREN) + if (!(ctx->cflags & REG_EXTENDED) && *(ctx->re + 1) == CHAR_RPAREN) { goto empty_atom; } @@ -1214,7 +1206,7 @@ tre_parse(tre_parse_ctx_t *ctx) } } - if (!*ctx->re) + if (!ctx->re[1]) /* Trailing backslash. */ return REG_EESCAPE; @@ -1357,6 +1349,8 @@ tre_parse(tre_parse_ctx_t *ctx) if (ctx->cflags & REG_EXTENDED || ctx->re == ctx->re_start) { + if (!(ctx->cflags & REG_EXTENDED)) + STACK_PUSHX(stack, int, PARSE_CATENATION); result = tre_ast_new_literal(ctx->mem, ASSERTION, ASSERT_AT_BOL, -1); if (result == NULL) @@ -1394,6 +1388,7 @@ tre_parse(tre_parse_ctx_t *ctx) if (!(ctx->cflags & REG_EXTENDED)) goto parse_literal; + case 0: empty_atom: result = tre_ast_new_literal(ctx->mem, EMPTY, -1, -1); if (!result) @@ -3096,7 +3091,7 @@ tre_ast_to_tnfa(tre_ast_node_t *node, tre_tnfa_transition_t *transitions, int -regcomp(regex_t *preg, const char *regex, int cflags) +regcomp(regex_t *restrict preg, const char *restrict regex, int cflags) { tre_stack_t *stack; tre_ast_node_t *tree, *tmp_ast_l, *tmp_ast_r;