From 28dacbd66b5fb07add399e2ee9e46d85258e078d Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 4 Jun 2019 23:53:31 -0600 Subject: Allow unmatched right paren in regexes. Fixes Issue #40. --- b.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'b.c') diff --git a/b.c b/b.c index 37ea0a5..2eeba2a 100644 --- a/b.c +++ b/b.c @@ -912,6 +912,7 @@ int relex(void) /* lexical analyzer for reparse */ int i; int num, m, commafound, digitfound; const uschar *startreptok; + static int parens = 0; rescan: starttok = prestr; @@ -925,9 +926,18 @@ rescan: case '\0': prestr--; return '\0'; case '^': case '$': + return c; case '(': - case ')': + parens++; return c; + case ')': + if (parens) { + parens--; + return c; + } + /* unmatched close parenthesis; per POSIX, treat as literal */ + rlxval = c; + return CHAR; case '\\': rlxval = quoted(&prestr); return CHAR; -- cgit v1.2.3