Parcourir la source

use new checkserach and matchsearch functions to do the real search/matching

Wichert Akkerman il y a 25 ans
Parent
commit
ce8fa516f3
1 fichiers modifiés avec 14 ajouts et 17 suppressions
  1. 14 17
      dselect/baselist.cc

+ 14 - 17
dselect/baselist.cc

@@ -3,6 +3,7 @@
  * baselist.cc - list of somethings
  *
  * Copyright (C) 1994,1995 Ian Jackson <iwj10@cus.cam.ac.uk>
+ * Copyright (C) 2001 Wichert Akkerman <wakkerma@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as
@@ -274,27 +275,20 @@ void baselist::itd_keys() {
 }
 
 void baselist::dosearch() {
-  int offset, index, searchlen;
-  searchlen= strlen(searchstring);
-  if (debug) fprintf(debug,"packagelist[%p]::dosearch(); searchstring=`%s' len=%d\n",
-                     this,searchstring,searchlen);
+  int offset, index;
+  if (debug) fprintf(debug,"baselist[%p]::dosearch(); searchstring=`%s'\n",
+                     this,searchstring);
   for (offset=1, index=greaterint(topofscreen,cursorline+1);
        offset<nitems;
        offset++, index++) {
     if (index >= nitems) index -= nitems;
-    int lendiff, i;
-    const char *thisname;
-    thisname= itemname(index);
-    if (!thisname) continue;
-    lendiff= strlen(thisname) - searchlen;
-    for (i=0; i<=lendiff; i++)
-      if (!strncasecmp(thisname + i, searchstring, searchlen)) {
-        topofscreen= index-1;
-        if (topofscreen > nitems - list_height) topofscreen= nitems-list_height;
-        if (topofscreen < 0) topofscreen= 0;
-        setcursor(index);
-        return;
-      }
+    if (matchsearch(index)) {
+      topofscreen= index-1;
+      if (topofscreen > nitems - list_height) topofscreen= nitems-list_height;
+      if (topofscreen < 0) topofscreen= 0;
+      setcursor(index);
+      return;
+    }
   }
   beep();
 }
@@ -374,3 +368,6 @@ void baselist::wordwrapinfo(int offset, const char *m) {
 }
 
 baselist::~baselist() { }
+
+/* vi: sw=2 ts=8
+ */