According to Geoff Hutchison:
> On Fri, 18 Jan 2002, Gilles Detillieux wrote:
> > +           else if (strcmp(word.get(), prefix_suffix) == 0)
> > +           {
> > +               tempWords.Add(new WeightWord(prefix_suffix, 1.0));
> > +           }
> 
> This won't work in the case where people set prefix_suffix to '' to run
> prefix matching on everything. We probably want a test something like:
> 
> ((strnlen(prefix_suffix) != 0 && strcmp(word.get(), prefix_suffix) == 0) ||
> (strnlen(prefix_suffix) == 0 && strcmp(word.get(), "*") == 0))
> 
> Maybe that can be simplified.
> 
> > +    if (strcmp(temp.get(), prefix_suffix) == 0) {
> 
> Same problem here.

There was also a little wrinkle in the word separation code if you force
a new wildcard character when prefix_match_character is empty.  Here's the
new patch...

--- htsearch/htsearch.cc.orig   Thu Nov  1 14:45:07 2001
+++ htsearch/htsearch.cc        Fri Jan 18 15:43:24 2002
@@ -444,6 +444,9 @@ setupWords(char *allWords, List &searchW
     String             word;
     // Why use a char type if String is the new char type!!!
     char               *prefix_suffix = config["prefix_match_character"];
+    char               *wildcard = prefix_suffix;
+    if (*wildcard == '\0')
+       wildcard = "*";
     while (*pos)
     {
        while (1)
@@ -461,12 +464,12 @@ setupWords(char *allWords, List &searchW
                tempWords.Add(new WeightWord(s, -1.0));
                break;
            }
-           else if (HtIsWordChar(t) || t == ':' ||
+           else if (HtIsWordChar(t) || t == ':' || t == *wildcard ||
                         (strchr(prefix_suffix, t) != NULL) || (t >= 161 && t <= 255))
            {
                word = 0;
-               while (t && (HtIsWordChar(t) ||
-                            t == ':' || (strchr(prefix_suffix, t) != NULL) || (t >= 
161 && t <= 255)))
+               while (t && (HtIsWordChar(t) || t == ':' || t == *wildcard ||
+                            (strchr(prefix_suffix, t) != NULL) || (t >= 161 && t <= 
+255)))
                {
                    word << (char) t;
                    t = *pos++;
@@ -485,6 +488,10 @@ setupWords(char *allWords, List &searchW
                else if (boolean && mystrcasecmp(word.get(), boolean_keywords[2]) == 0)
                {
                    tempWords.Add(new WeightWord("!", -1.0));
+               }
+               else if (strcmp(word.get(), wildcard) == 0)
+               {
+                   tempWords.Add(new WeightWord(wildcard, 1.0));
                }
                else
                {
--- htsearch/parser.cc.orig     Thu Jul 26 15:08:52 2001
+++ htsearch/parser.cc  Fri Jan 18 15:24:18 2002
@@ -240,6 +240,24 @@ Parser::perform_push()
        list->isIgnore = 1;
        return;
     }
+    static char        *wildcard = config["prefix_match_character"];
+    if (*wildcard == '\0')
+       wildcard = "*";
+    if (strcmp(temp.get(), wildcard) == 0) {
+       Database        *docIndex = Database::getDatabaseInstance();
+       docIndex->OpenRead(config["doc_index"]);
+       docIndex->Start_Get();
+       while ((p = docIndex->Get_Next()))
+       {
+           dm = new DocMatch;
+           dm->score = current->weight;
+           dm->id = atoi(p);
+           dm->anchor = 0;
+           list->add(dm);
+       }
+       delete docIndex;
+       return;
+    }
     temp.lowercase();
     p = temp.get();
     if (temp.length() > maximum_word_length)

-- 
Gilles R. Detillieux              E-mail: <[EMAIL PROTECTED]>
Spinal Cord Research Centre       WWW:    http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba  Phone:  (204)789-3766
Winnipeg, MB  R3E 3J7  (Canada)   Fax:    (204)789-3930

_______________________________________________
htdig-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/htdig-dev

Reply via email to