Index: openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-procs.tcl,v diff -u -r1.41 -r1.41.2.1 --- openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-procs.tcl 14 Sep 2018 19:33:58 -0000 1.41 +++ openacs-4/packages/tsearch2-driver/tcl/tsearch2-driver-procs.tcl 14 Mar 2019 15:23:27 -0000 1.41.2.1 @@ -255,22 +255,17 @@ regsub -all {[^-/@.\d\w\s\(\)]+} $query { } query # match parens, if they don't match just throw them away - # set p 0 - # for {set i 0} {$i < [string length $query]} {incr i} { - # if {[string index $query $i] eq "("} { - # incr p - # } - # if {[string index $query $i] eq ")"} { - # incr p -1 - # } - # } - # if {$p != 0} { - # regsub -all {\(|\)} $query {} query - # } + set p 0 + for {set i 0} {$i < [string length $query]} {incr i} { + switch [string index $query $i] { + "(" {incr p} + ")" {incr p -1} + } + } + if {$p != 0} { + regsub -all {\(|\)} $query {} query + } - # remove all parens - regsub -all {\(|\)} $query {} query - # remove empty () regsub -all {\(\s*\)} $query {} query