'everything' module: fuzzy_match fixes

SVN revision: 41766
This commit is contained in:
Hannes Janetzek 2009-08-14 16:18:25 +00:00
parent d198ef5e96
commit 9ed72ffa1c
2 changed files with 29 additions and 10 deletions

View File

@ -460,6 +460,7 @@ evry_fuzzy_match(const char *str, const char *match)
unsigned int cnt = 1;
unsigned int pos = 0;
unsigned int last = 0;
unsigned char first;
if (!match || !match[0] || !str || !str[0]) return 0;
@ -467,17 +468,23 @@ evry_fuzzy_match(const char *str, const char *match)
{
mc = tolower(*m);
first = 0;
for (p = str; *p != 0 && *m != 0; p++)
{
if (tolower(*p) == mc)
{
cnt += cnt * (pos - last) * 10;
cnt += pos + (pos - last) * 10;
last = pos;
m++;
mc = tolower(*m);
first = 1;
}
else pos++;
if (!first)
last = pos;
if (cnt > MAX_FUZZ) return 0;
if (isspace(mc) && !strchr(p, ' '))

View File

@ -55,7 +55,6 @@ _fetch(Evry_Plugin *p, const char *input)
E_Zone *zone;
E_Border *bd;
Eina_List *l;
int fuzz;
int prio = 0;
_cleanup(p);
@ -68,15 +67,28 @@ _fetch(Evry_Plugin *p, const char *input)
{
if (!input)
_item_add(p, bd, 0, &prio);
else if ((bd->client.icccm.name) &&
(fuzz = evry_fuzzy_match(bd->client.icccm.name, input)))
_item_add(p, bd, fuzz, &prio);
else if ((fuzz = evry_fuzzy_match(e_border_name_get(bd), input)))
_item_add(p, bd, fuzz, &prio);
else if (bd->desktop)
else
{
if ((fuzz = evry_fuzzy_match(bd->desktop->name, input)))
_item_add(p, bd, fuzz, &prio);
int fuzz, min;
min = evry_fuzzy_match(e_border_name_get(bd), input);
if (bd->client.icccm.name)
{
fuzz = evry_fuzzy_match(bd->client.icccm.name, input);
if (!min || fuzz < min)
min = fuzz;
}
if (bd->desktop)
{
fuzz = evry_fuzzy_match(bd->desktop->name, input);
if (!min || fuzz < min)
min = fuzz;
}
if (min)
_item_add(p, bd, min, &prio);
}
}
}