suppress backref processing in ERE regcomp
authorRich Felker <dalias@aerifal.cx>
Fri, 20 Mar 2015 22:25:01 +0000 (18:25 -0400)
committerRich Felker <dalias@aerifal.cx>
Fri, 20 Mar 2015 22:28:37 +0000 (18:28 -0400)
one of the features of ERE is that it's actually a regular language
and does not admit expressions which cannot be matched in linear time.
introduction of \n backref support into regcomp's ERE parsing was
unintentional.

src/regex/regcomp.c

index bce6bc1593e0fb291e4d2a6811d311d611139640..4d80cb1c602ca5d53848c4535db0f1cb88d85aee 100644 (file)
@@ -839,7 +839,7 @@ static reg_errcode_t parse_atom(tre_parse_ctx_t *ctx, const char *s)
                        s--;
                        break;
                default:
-                       if (isdigit(*s)) {
+                       if (!ere && isdigit(*s)) {
                                /* back reference */
                                int val = *s - '0';
                                node = tre_ast_new_literal(ctx->mem, BACKREF, val, ctx->position);