[Tkabber-dev] r1096 - in trunk/tkabber: . plugins/search

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Apr 11 20:20:54 MSD 2007


Author: sergei
Date: 2007-04-11 20:20:54 +0400 (Wed, 11 Apr 2007)
New Revision: 1096

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/plugins/search/search.tcl
Log:
	* plugins/search/search.tcl: Fixed searching substrings and glob
	  patterns.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2007-04-11 05:44:29 UTC (rev 1095)
+++ trunk/tkabber/ChangeLog	2007-04-11 16:20:54 UTC (rev 1096)
@@ -3,6 +3,9 @@
 	* jabberlib-tclxml/jabberlib.tcl: Added partial support of XEP-0203
 	  (delayed delivery).
 
+	* plugins/search/search.tcl: Fixed searching substrings and glob
+	  patterns.
+
 2007-04-10  Sergei Golovan  <sgolovan at nes.ru>
 
 	* messages.tcl, presence.tcl: Moved showing unsubscribed message

Modified: trunk/tkabber/plugins/search/search.tcl
===================================================================
--- trunk/tkabber/plugins/search/search.tcl	2007-04-11 05:44:29 UTC (rev 1095)
+++ trunk/tkabber/plugins/search/search.tcl	2007-04-11 16:20:54 UTC (rev 1096)
@@ -148,29 +148,29 @@
     variable options
 
     if {$options(mode) == "substring"} {
-	set what *$what*
+	regsub -all {([*?\[\]\\])} $what {\\\1} what
     }
 
     if {$options(case)} {
-	set args [list -- $what $where]
+	set case ""
     } else {
-	set args [list -nocase -- $what $where]
+	set case -nocase
     }
 
     switch -- $options(mode) {
 	substring -
 	glob {
-	    return [eval string match $args]
+	    return [eval string match $case [list *$what* $where]]
 	}
 	regexp {
-	    if {[catch { eval regexp $args } res]} {
+	    if {[catch {eval regexp $case -- [list $what $where]} res]} {
 		return 0
 	    } else {
 		return $res
 	    }
 	}
 	exact {
-	    return [eval string equal $args]
+	    return [eval string equal $case [list $what $where]]
 	}
     }
 



More information about the Tkabber-dev mailing list