$NetBSD: patch-ec,v 1.2 2008/11/10 19:41:47 wiz Exp $

--- Modules/pypcre.c.orig	2005-08-31 12:55:21.000000000 +0000
+++ Modules/pypcre.c
@@ -2278,6 +2278,7 @@ int c, size;
 int bracount = 0;
 int brastack[200];
 int top_backref = 0;
+BOOL capturing;
 unsigned int brastackptr = 0;
 uschar *code;
 const uschar *ptr;
@@ -2457,6 +2458,7 @@ while ((c = *(++ptr)) != 0)
     /* Brackets may be genuine groups or special things */
 
     case '(':
+    capturing = FALSE;
 
     /* Handle special forms of bracket, which all start (? */
 
@@ -2554,10 +2556,15 @@ while ((c = *(++ptr)) != 0)
       continue;                      /* End of this bracket handling */
       }
 
+    /* Ordinary parentheses, not followed by '?', are capturing unless
+    PCRE_NO_AUTO_CAPTURE is set. */
+
+    else capturing = (options & PCRE_NO_AUTO_CAPTURE) == 0;
+    
     /* Extracting brackets must be counted so we can process escapes in a
     Perlish way. */
 
-    else bracount++;
+    if (capturing) bracount++;
 
     /* Non-special forms of bracket. Save length for computing whole length
     at end if there's a repeat that requires duplication of the group. */
