remove invalid code from TRE
authorRich Felker <dalias@aerifal.cx>
Fri, 13 Apr 2012 23:50:58 +0000 (19:50 -0400)
committerRich Felker <dalias@aerifal.cx>
Fri, 13 Apr 2012 23:50:58 +0000 (19:50 -0400)
TRE wants to treat + and ? after a +, ?, or * as special; ? means
ungreedy and + is reserved for future use. however, this is
non-conformant. although redundant, these redundant characters have
well-defined (no-op) meaning for POSIX ERE, and are actually _literal_
characters (which TRE is wrongly ignoring) in POSIX BRE mode.

the simplest fix is to simply remove the unneeded nonstandard
functionality. as a plus, this shaves off a small amount of bloat.

src/regex/regcomp.c

index 8987f5a..f8ebe40 100644 (file)
@@ -1105,20 +1105,6 @@ tre_parse(tre_parse_ctx_t *ctx)
                if (*ctx->re == CHAR_QUESTIONMARK)
                  rep_max = 1;
 
                if (*ctx->re == CHAR_QUESTIONMARK)
                  rep_max = 1;
 
-                 {
-                   if (*(ctx->re + 1) == CHAR_QUESTIONMARK)
-                     {
-                       minimal = 1;
-                       ctx->re++;
-                     }
-                   else if (*(ctx->re + 1) == CHAR_STAR
-                            || *(ctx->re + 1) == CHAR_PLUS)
-                     {
-                       /* These are reserved for future extensions. */
-                       return REG_BADRPT;
-                     }
-                 }
-
                ctx->re++;
                tmp_node = tre_ast_new_iter(ctx->mem, result, rep_min, rep_max,
                                            minimal);
                ctx->re++;
                tmp_node = tre_ast_new_iter(ctx->mem, result, rep_min, rep_max,
                                            minimal);