aboriginal

changeset 1692:5a7071eb01bb

Musl regex patch for \| support needed by toybox grep when more than one pattern specified.
author Rob Landley <rob@landley.net>
date Wed, 01 Oct 2014 19:55:04 -0500
parents 732ebb18699e
children aee8b52672d7
files sources/patches/musl-regex.patch
diffstat 1 files changed, 57 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/sources/patches/musl-regex.patch	Wed Oct 01 19:55:04 2014 -0500
     1.3 @@ -0,0 +1,58 @@
     1.4 +Make \| work in normal regexes. (Toybox grep uses this.)
     1.5 +
     1.6 +diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c
     1.7 +index d907627..3a89305 100644
     1.8 +--- a/src/regex/regcomp.c
     1.9 ++++ b/src/regex/regcomp.c
    1.10 +@@ -1008,9 +1008,11 @@ tre_parse(tre_parse_ctx_t *ctx)
    1.11 + 	    tre_char_t c;
    1.12 + 	    if (!*ctx->re)
    1.13 + 	      break;
    1.14 +-	    c = *ctx->re;
    1.15 ++		c = *ctx->re;
    1.16 + 		if (ctx->cflags & REG_EXTENDED && c == CHAR_PIPE)
    1.17 + 		  break;
    1.18 ++		else if (c == CHAR_BACKSLASH && ctx->re[1] == CHAR_PIPE)
    1.19 ++		  break;
    1.20 + 		if ((ctx->cflags & REG_EXTENDED
    1.21 + 		     && c == CHAR_RPAREN && depth > 0)
    1.22 + 		    || (!(ctx->cflags & REG_EXTENDED)
    1.23 +@@ -1047,23 +1049,16 @@ tre_parse(tre_parse_ctx_t *ctx)
    1.24 + 	  }
    1.25 + 
    1.26 + 	case PARSE_UNION:
    1.27 +-	  switch (*ctx->re)
    1.28 +-	    {
    1.29 +-	    case CHAR_PIPE:
    1.30 ++	  if (*ctx->re == CHAR_RPAREN)  ctx->re++;
    1.31 ++	  else if (*ctx->re == CHAR_PIPE ||
    1.32 ++		(*ctx->re == CHAR_BACKSLASH && ctx->re[1] == CHAR_PIPE))
    1.33 ++	  {
    1.34 + 	      STACK_PUSHX(stack, int, PARSE_UNION);
    1.35 + 	      STACK_PUSHX(stack, voidptr, result);
    1.36 + 	      STACK_PUSHX(stack, int, PARSE_POST_UNION);
    1.37 + 	      STACK_PUSHX(stack, int, PARSE_BRANCH);
    1.38 +-	      ctx->re++;
    1.39 +-	      break;
    1.40 +-
    1.41 +-	    case CHAR_RPAREN:
    1.42 +-	      ctx->re++;
    1.43 +-	      break;
    1.44 +-
    1.45 +-	    default:
    1.46 +-	      break;
    1.47 +-	    }
    1.48 ++	      ctx->re += 1+(*ctx->re == CHAR_BACKSLASH);
    1.49 ++	  }
    1.50 + 	  break;
    1.51 + 
    1.52 + 	case PARSE_POST_UNION:
    1.53 +@@ -1181,6 +1176,8 @@ tre_parse(tre_parse_ctx_t *ctx)
    1.54 + 		{
    1.55 + 		  goto empty_atom;
    1.56 + 		}
    1.57 ++	      if (!(ctx->cflags & REG_EXTENDED) && ctx->re[1] == CHAR_PIPE)
    1.58 ++		goto empty_atom;
    1.59 + 
    1.60 + 	      /* If a macro is used, parse the expanded macro recursively. */
    1.61 + 	      {