sks-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Sks-devel] Re: full-text v. regular expression userid searches (was: Re


From: Jason Harris
Subject: [Sks-devel] Re: full-text v. regular expression userid searches (was: Re: [svn] GnuPG - r3867 - trunk/keyserver)
Date: Sat, 20 Aug 2005 08:13:32 -0400
User-agent: Mutt/1.4.2.1i

On Fri, Aug 19, 2005 at 10:55:06AM -0400, David Shaw wrote:
> On Fri, Aug 19, 2005 at 09:49:19AM -0400, Jason Harris wrote:

> > > Not that I'm suggesting regex searches.  I think they're overkill for
> > > the problem at hand.  Even LDAP doesn't do full regex.
> > 
> > Well, allowing "anchoring" of the (full-word) searches with ^ and $
> > sounds like it would be a good start,
> 
> Hard to do in a backwards compatible way, but at least it's not likely
> that people use ^ and $ at the beginning and end of their real user
> IDs.  Anyway, I can't say I think it's really necessary, but if SKS
> starts to support it, I'll add support for it in gpgkeys_hkp.

This applies after address@hidden/sks--mainline--1.0--patch-44,
Enjoy: 

--- orig/utils.ml
+++ mod/utils.ml
@@ -327,16 +327,13 @@
 
 let substring_find ~sub string = 
   try
-    for i = 0 to String.length string - String.length sub  do
-      try
-       for j = 0 to String.length sub - 1 do
-         if string.[i+j] <> sub.[j] then raise Exit
-       done;
-       raise (Found i)
-      with
-       Exit -> ()
-    done;
-    -1
+    let string = String.lowercase string in
+    let sub = String.lowercase sub in
+    let re = Str.regexp sub in
+    try
+      let pos = Str.search_forward re string 0 in
+      raise (Found pos)
+    with Not_found -> raise (Found (-1))
+  -1
   with
-    Found i -> i
-      
+    Found pos -> pos

-- 
Jason Harris           |  NIC:  JH329, PGP:  This _is_ PGP-signed, isn't it?
address@hidden _|_ web:  http://keyserver.kjsl.com/~jharris/
          Got photons?   (TM), (C) 2004

Attachment: pgpO44_TfW3Ir.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]