Re: full-text v. regular expression userid searches (was: Re: [svn] GnuPG - r3867 - trunk/keyserver)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: full-text v. regular expression userid searches (was: Re: [svn] GnuPG - r3867 - trunk/keyserver)

Jason Harris
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 [hidden email]--2004/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?
[hidden email] _|_ web:  http://keyserver.kjsl.com/~jharris/
          Got photons?   (TM), (C) 2004

_______________________________________________
Sks-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/sks-devel

attachment0 (322 bytes) Download Attachment