From 33d91040785d679c40a44f3127eee54d6adb2ad3 Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Sun, 13 Aug 2006 12:33:34 +0000 Subject: FS#5805 NOT operator for tagnavi.config by Jochen Kemnade. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10558 a1c6a512-1295-4272-9138-f99709370657 --- apps/tagcache.c | 13 ++++++++++++- apps/tagcache.h | 7 ++++--- apps/tagtree.c | 4 ++++ 3 files changed, 20 insertions(+), 4 deletions(-) (limited to 'apps') diff --git a/apps/tagcache.c b/apps/tagcache.c index 4c324c8da3..87810da93b 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -588,7 +588,12 @@ static bool check_against_clause(long numeric, const char *str, 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: @@ -600,10 +605,16 @@ static bool check_against_clause(long numeric, const char *str, case clause_contains: return (strcasestr(str, clause->str) != NULL); + case clause_not_contains: + return (strcasestr(str, clause->str) == NULL); case clause_begins_with: return (strcasestr(str, clause->str) == str); + case clause_not_begins_with: + return (strcasestr(str, clause->str) != str); case clause_ends_with: /* Not supported yet */ return false; + case clause_not_ends_with: /* Not supported yet */ + return false; } return false; diff --git a/apps/tagcache.h b/apps/tagcache.h index b27d804792..e43414cba5 100644 --- a/apps/tagcache.h +++ b/apps/tagcache.h @@ -71,9 +71,10 @@ enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title, #define FLAG_DIRCACHE 0x0002 /* Filename is a dircache pointer */ #define FLAG_DIRTYNUM 0x0004 /* Numeric data has been modified */ -enum clause { clause_none, clause_is, clause_gt, clause_gteq, clause_lt, - clause_lteq, clause_contains, clause_begins_with, clause_ends_with }; -enum modifiers { clause_mod_none, clause_mod_not }; +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 }; struct tagcache_stat { bool initialized; /* Is tagcache currently busy? */ diff --git a/apps/tagtree.c b/apps/tagtree.c index daa52646fa..0565b62981 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c @@ -176,13 +176,17 @@ static int get_clause(int *condition) MATCH(condition, buf, "=", clause_is); MATCH(condition, buf, "==", clause_is); + MATCH(condition, buf, "!=", clause_is_not); MATCH(condition, buf, ">", clause_gt); MATCH(condition, buf, ">=", clause_gteq); MATCH(condition, buf, "<", clause_lt); MATCH(condition, buf, "<=", clause_lteq); MATCH(condition, buf, "~", clause_contains); + MATCH(condition, buf, "!~", clause_not_contains); MATCH(condition, buf, "^", clause_begins_with); + MATCH(condition, buf, "!^", clause_not_begins_with); MATCH(condition, buf, "$", clause_ends_with); + MATCH(condition, buf, "!$", clause_not_ends_with); return 0; } -- cgit v1.2.3