From 32dee9b9b1e557a73cc4427455cd00cb2571436c Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sun, 22 Mar 2015 18:32:55 +0000 Subject: do not treat \0 as a backref in BRE The valid BRE backref tokens are \1 .. \9, and 0 is not a special character either so \0 is undefined by the standard. Such undefined escaped characters are treated as literal characters currently, following existing practice, so \0 is the same as 0. --- src/regex/regcomp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c index 4d80cb1c..dfa9727c 100644 --- a/src/regex/regcomp.c +++ b/src/regex/regcomp.c @@ -839,7 +839,7 @@ static reg_errcode_t parse_atom(tre_parse_ctx_t *ctx, const char *s) s--; break; default: - if (!ere && isdigit(*s)) { + if (!ere && (unsigned)*s-'1' < 9) { /* back reference */ int val = *s - '0'; node = tre_ast_new_literal(ctx->mem, BACKREF, val, ctx->position); -- cgit v1.2.1