diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2006-10-09 10:23:35 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2006-10-09 10:23:35 +0000 |
commit | be2eb02d7a9bba97aeb022174e4abe2cc132d6a3 (patch) | |
tree | 76e1716b7f17d3879247ac447228d1366e8ba8b9 | |
parent | 56f50615c0b609654cce3a6faa4a14faf5d715ab (diff) | |
download | rockbox-be2eb02d7a9bba97aeb022174e4abe2cc132d6a3.tar.gz rockbox-be2eb02d7a9bba97aeb022174e4abe2cc132d6a3.zip |
FS#6137: add "oneof" operator to tagnavi.conf syntax.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11157 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/tagcache.c | 19 | ||||
-rw-r--r-- | apps/tagcache.h | 2 | ||||
-rw-r--r-- | apps/tagtree.c | 1 |
3 files changed, 21 insertions, 1 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index 1c180b7f43..ca2421171b 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -592,6 +592,23 @@ inline static bool str_ends_with(const char *str1, const char *str2) | |||
592 | return !strcasecmp(&str1[str_len - clause_len], str2); | 592 | return !strcasecmp(&str1[str_len - clause_len], str2); |
593 | } | 593 | } |
594 | 594 | ||
595 | inline static bool str_oneof(const char *str, const char *list) | ||
596 | { | ||
597 | const char *sep; | ||
598 | int l, len = strlen(str); | ||
599 | |||
600 | while (*list) | ||
601 | { | ||
602 | sep = strchr(list, '|'); | ||
603 | l = sep ? (long)sep - (long)list : (int)strlen(list); | ||
604 | if ((l==len) && !strncasecmp(str, list, len)) | ||
605 | return true; | ||
606 | list += sep ? l + 1 : l; | ||
607 | } | ||
608 | |||
609 | return false; | ||
610 | } | ||
611 | |||
595 | static bool check_against_clause(long numeric, const char *str, | 612 | static bool check_against_clause(long numeric, const char *str, |
596 | const struct tagcache_search_clause *clause) | 613 | const struct tagcache_search_clause *clause) |
597 | { | 614 | { |
@@ -643,6 +660,8 @@ static bool check_against_clause(long numeric, const char *str, | |||
643 | return str_ends_with(str, clause->str); | 660 | return str_ends_with(str, clause->str); |
644 | case clause_not_ends_with: | 661 | case clause_not_ends_with: |
645 | return !str_ends_with(str, clause->str); | 662 | return !str_ends_with(str, clause->str); |
663 | case clause_oneof: | ||
664 | return str_oneof(str, clause->str); | ||
646 | 665 | ||
647 | default: | 666 | default: |
648 | logf("Incorrect tag: %d", clause->type); | 667 | logf("Incorrect tag: %d", clause->type); |
diff --git a/apps/tagcache.h b/apps/tagcache.h index 23525f8ea8..1a3afcac16 100644 --- a/apps/tagcache.h +++ b/apps/tagcache.h | |||
@@ -77,7 +77,7 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title, | |||
77 | enum clause { clause_none, clause_is, clause_is_not, clause_gt, clause_gteq, | 77 | enum clause { clause_none, clause_is, clause_is_not, clause_gt, clause_gteq, |
78 | clause_lt, clause_lteq, clause_contains, clause_not_contains, | 78 | clause_lt, clause_lteq, clause_contains, clause_not_contains, |
79 | clause_begins_with, clause_not_begins_with, clause_ends_with, | 79 | clause_begins_with, clause_not_begins_with, clause_ends_with, |
80 | clause_not_ends_with }; | 80 | clause_not_ends_with, clause_oneof }; |
81 | 81 | ||
82 | struct tagcache_stat { | 82 | struct tagcache_stat { |
83 | bool initialized; /* Is tagcache currently busy? */ | 83 | bool initialized; /* Is tagcache currently busy? */ |
diff --git a/apps/tagtree.c b/apps/tagtree.c index f9542821d8..90fa617aad 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c | |||
@@ -244,6 +244,7 @@ static int get_clause(int *condition) | |||
244 | MATCH(condition, buf, "!^", clause_not_begins_with); | 244 | MATCH(condition, buf, "!^", clause_not_begins_with); |
245 | MATCH(condition, buf, "$", clause_ends_with); | 245 | MATCH(condition, buf, "$", clause_ends_with); |
246 | MATCH(condition, buf, "!$", clause_not_ends_with); | 246 | MATCH(condition, buf, "!$", clause_not_ends_with); |
247 | MATCH(condition, buf, "@", clause_oneof); | ||
247 | 248 | ||
248 | return 0; | 249 | return 0; |
249 | } | 250 | } |