Subject: [6585b21ca8] [regexp {(\w).*?\1} abb] failed to match. Thanks to Tom Lane for passing on the discovery in Postgres.

From: dgp <[email-masked]>
Date: Fri, 26 Jul 2013 13:21:30 +0000

---
 generic/regexec.c | 7 +------
 tests/regexp.test | 4 ++++
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/generic/regexec.c b/generic/regexec.c
index c902209..205fcc2 100644
--- a/generic/regexec.c
+++ b/generic/regexec.c
@@ -512,12 +512,7 @@ cfindloop(
 		    return er;
 		}
 		if ((shorter) ? end == estop : end == begin) {
-		    /*
-		     * No point in trying again.
-		     */
-
-		    *coldp = cold;
-		    return REG_NOMATCH;
+		    break;
 		}
 
 		/*
diff --git a/tests/regexp.test b/tests/regexp.test
index 8138054..362f425 100644
--- a/tests/regexp.test
+++ b/tests/regexp.test
@@ -728,6 +728,10 @@ test regexp-22.5 {Bug 3610026} -setup {
 } -cleanup {
     unset -nocomplain e cp
 } -returnCodes error  -match glob -result {*too many colors*}
+test regexp-22.6 {Bug 6585b21ca8} {
+    expr {[regexp {(\w).*?\1} Programmer m] ? $m : "<NONE>"}
+} rogr
+
 
 test regexp-23.1 {regexp -all and -line} {
     set string ""
-- 
cgit v0.12