forked from len0rd/rockbox
FS#6137: add "oneof" operator to tagnavi.conf syntax.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11157 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
56f50615c0
commit
be2eb02d7a
3 changed files with 21 additions and 1 deletions
|
|
@ -592,6 +592,23 @@ inline static bool str_ends_with(const char *str1, const char *str2)
|
|||
return !strcasecmp(&str1[str_len - clause_len], str2);
|
||||
}
|
||||
|
||||
inline static bool str_oneof(const char *str, const char *list)
|
||||
{
|
||||
const char *sep;
|
||||
int l, len = strlen(str);
|
||||
|
||||
while (*list)
|
||||
{
|
||||
sep = strchr(list, '|');
|
||||
l = sep ? (long)sep - (long)list : (int)strlen(list);
|
||||
if ((l==len) && !strncasecmp(str, list, len))
|
||||
return true;
|
||||
list += sep ? l + 1 : l;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool check_against_clause(long numeric, const char *str,
|
||||
const struct tagcache_search_clause *clause)
|
||||
{
|
||||
|
|
@ -643,6 +660,8 @@ 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);
|
||||
case clause_oneof:
|
||||
return str_oneof(str, clause->str);
|
||||
|
||||
default:
|
||||
logf("Incorrect tag: %d", clause->type);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title,
|
|||
enum clause { clause_none, clause_is, clause_is_not, clause_gt, clause_gteq,
|
||||
clause_lt, clause_lteq, clause_contains, clause_not_contains,
|
||||
clause_begins_with, clause_not_begins_with, clause_ends_with,
|
||||
clause_not_ends_with };
|
||||
clause_not_ends_with, clause_oneof };
|
||||
|
||||
struct tagcache_stat {
|
||||
bool initialized; /* Is tagcache currently busy? */
|
||||
|
|
|
|||
|
|
@ -244,6 +244,7 @@ static int get_clause(int *condition)
|
|||
MATCH(condition, buf, "!^", clause_not_begins_with);
|
||||
MATCH(condition, buf, "$", clause_ends_with);
|
||||
MATCH(condition, buf, "!$", clause_not_ends_with);
|
||||
MATCH(condition, buf, "@", clause_oneof);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue