[Zope-Checkins] CVS: Zope2 - TextIndex.py:1.6

andreas@serenade.digicool.com andreas@serenade.digicool.com
Tue, 5 Jun 2001 09:00:14 -0400


Update of /cvs-repository/Zope2/lib/python/Products/PluginIndexes/TextIndex
In directory serenade:/tmp/cvs-serv18636/Products/PluginIndexes/TextIndex

Modified Files:
	TextIndex.py 
Log Message:

Fixed (hopefully) a longtime outstanding problem in parens():         
- the former regex never matched any parentheses
- the parens() used old regex module API although 're' module was used




--- Updated File TextIndex.py in package Zope2 --
--- TextIndex.py	2001/06/01 18:53:39	1.5
+++ TextIndex.py	2001/06/05 13:00:14	1.6
@@ -742,13 +742,16 @@
     return q
 
 
-def parens(s, parens_re=re.compile(r'(\|)').search):
+def parens(s, parens_re=re.compile('[\(\)]').search):
 
     index = open_index = paren_count = 0
 
     while 1:
-        index = parens_re(s, index)
-        if index is None : break
+
+        mo = parens_re(s, index)
+        if mo is None : break
+
+        index = mo.start(0)
     
         if s[index] == '(':
             paren_count = paren_count + 1
@@ -765,7 +768,6 @@
         return None
     else:
         raise QueryError, "Mismatched parentheses"      
-
 
 
 def quotes(s, ws=(string.whitespace,)):