Accepted FS#6098 as the first patch from Robert Kukla and implemented using two switches.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11124 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Miika Pekkarinen 2006-10-05 09:49:18 +00:00
parent ac39354b9e
commit 3eb9e70b64
2 changed files with 50 additions and 31 deletions

View file

@ -595,19 +595,14 @@ inline static bool str_ends_with(const char *str1, const char *str2)
static bool check_against_clause(long numeric, const char *str,
const struct tagcache_search_clause *clause)
{
if (clause->numeric)
{
switch (clause->type)
{
case clause_is:
if (clause->numeric)
return numeric == clause->numeric_data;
else
return !strcasecmp(clause->str, str);
case clause_is_not:
if (clause->numeric)
return numeric != clause->numeric_data;
else
return strcasecmp(clause->str, str);
case clause_gt:
return numeric > clause->numeric_data;
case clause_gteq:
@ -616,7 +611,26 @@ static bool check_against_clause(long numeric, const char *str,
return numeric < clause->numeric_data;
case clause_lteq:
return numeric <= clause->numeric_data;
default:
logf("Incorrect numeric tag: %d", clause->type);
}
}
else
{
switch (clause->type)
{
case clause_is:
return !strcasecmp(clause->str, str);
case clause_is_not:
return strcasecmp(clause->str, str);
case clause_gt:
return 0>strcasecmp(clause->str, str);
case clause_gteq:
return 0>=strcasecmp(clause->str, str);
case clause_lt:
return 0<strcasecmp(clause->str, str);
case clause_lteq:
return 0<=strcasecmp(clause->str, str);
case clause_contains:
return (strcasestr(str, clause->str) != NULL);
case clause_not_contains:
@ -629,6 +643,10 @@ static bool check_against_clause(long numeric, const char *str,
return str_ends_with(str, clause->str);
case clause_not_ends_with:
return !str_ends_with(str, clause->str);
default:
logf("Incorrect tag: %d", clause->type);
}
}
return false;

View file

@ -239,3 +239,4 @@ Pengxuan Liu
Andrew Cupper
Thilo-Alexander Ginkel
Adam Gashlin
Robert Kukla