Mercurial > hg > aboriginal
view sources/patches/musl-regex.patch @ 1711:60043af4120e draft
Make binutils install the extra things elf2flt needs in a less silly place.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 24 Nov 2014 14:45:21 -0600 |
parents | 5a7071eb01bb |
children | 9b4251fda364 |
line wrap: on
line source
Make \| work in normal regexes. (Toybox grep uses this.) diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c index d907627..3a89305 100644 --- a/src/regex/regcomp.c +++ b/src/regex/regcomp.c @@ -1008,9 +1008,11 @@ tre_parse(tre_parse_ctx_t *ctx) tre_char_t c; if (!*ctx->re) break; - c = *ctx->re; + c = *ctx->re; if (ctx->cflags & REG_EXTENDED && c == CHAR_PIPE) break; + else if (c == CHAR_BACKSLASH && ctx->re[1] == CHAR_PIPE) + break; if ((ctx->cflags & REG_EXTENDED && c == CHAR_RPAREN && depth > 0) || (!(ctx->cflags & REG_EXTENDED) @@ -1047,23 +1049,16 @@ tre_parse(tre_parse_ctx_t *ctx) } case PARSE_UNION: - switch (*ctx->re) - { - case CHAR_PIPE: + if (*ctx->re == CHAR_RPAREN) ctx->re++; + else if (*ctx->re == CHAR_PIPE || + (*ctx->re == CHAR_BACKSLASH && ctx->re[1] == CHAR_PIPE)) + { STACK_PUSHX(stack, int, PARSE_UNION); STACK_PUSHX(stack, voidptr, result); STACK_PUSHX(stack, int, PARSE_POST_UNION); STACK_PUSHX(stack, int, PARSE_BRANCH); - ctx->re++; - break; - - case CHAR_RPAREN: - ctx->re++; - break; - - default: - break; - } + ctx->re += 1+(*ctx->re == CHAR_BACKSLASH); + } break; case PARSE_POST_UNION: @@ -1181,6 +1176,8 @@ tre_parse(tre_parse_ctx_t *ctx) { goto empty_atom; } + if (!(ctx->cflags & REG_EXTENDED) && ctx->re[1] == CHAR_PIPE) + goto empty_atom; /* If a macro is used, parse the expanded macro recursively. */ {