pike.git / lib / modules / Search.pmod / Grammar.pmod / DefaultParser.pike

version» Context lines:

pike.git/lib/modules/Search.pmod/Grammar.pmod/DefaultParser.pike:328:    array(string) words = Unicode.split_words_and_normalize(text);    for(int i=0; i<sizeof(words); i++)    words[i]=replace(words[i], ({star, questionmark}), ({"*","?"}));    // End of abominable kludge    if (words) {    // If search phrase, remove empty globs. This might promote to    // ordinary search word that do support remining globs.    if (sizeof(words) > 1)    words = filter(words, lambda(string w) { return (w - "*" - "?") == "" ? 0 : 1; });    -  if (sizeof(words) == 1) +  if (sizeof(words) == 1) { +  // If auto-globbing has been requested we take a word not using any +  // glob characters and wrap it in "*" + word + "*". +  if (options["auto-glob"] && +  !has_value(words[0], "*") && +  !has_value(words[0], "?")) { +  words[0] = "*" + words[0] + "*"; +  } +     switch (prefix) {    case '+': node->plusWords += words; break;    case '-': node->minusWords += words; break;    default: node->words += words; break;    } -  else if (sizeof(words) > 1) { -  // No use of globs at this point so remove them +  } else if (sizeof(words) > 1) { +  // No use of globs at this point so remove them. Auto-globbing isn't +  // used in this case either.    words = map(words, lambda(string w) { return w - "*" - "?"; } );    switch (prefix) {    case '+': node->plusPhrases += ({ words }); break;    case '-': node->minusPhrases += ({ words }); break;    default: node->phrases += ({ words }); break;    }    }    }    }   }