summaryrefslogtreecommitdiffstats
path: root/apps/tagtree.c
diff options
context:
space:
mode:
authorMichael Hohmuth <sideral@rockbox.org>2011-05-10 10:25:41 +0000
committerMichael Hohmuth <sideral@rockbox.org>2011-05-10 10:25:41 +0000
commit6a24a7a90363bfbf4c5a0be0585da425506adfab (patch)
treef03b057c7e83f4924e084c2843d42ccedb0939ea /apps/tagtree.c
parent8cb4b36ee3513e9c26e16e3d9cf8a788e1809602 (diff)
downloadrockbox-6a24a7a90363bfbf4c5a0be0585da425506adfab.tar.gz
rockbox-6a24a7a90363bfbf4c5a0be0585da425506adfab.tar.bz2
rockbox-6a24a7a90363bfbf4c5a0be0585da425506adfab.zip
tagnavi.config: Add a logical-OR operator ("|") for tagnavi conditionals.
Logical-AND ("&") always takes precedence over logical-OR. (Parentheses are not supported.) Fight binsize increase by storing some common expressions in local variables. This avoids repeated reevaluations involving memory accesses. check_clauses: Fail clause (return false) in case of errors (tag too long, DB entry deleted). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29851 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tagtree.c')
-rw-r--r--apps/tagtree.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 2a2e2b805b..e7f703154c 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -461,16 +461,18 @@ static int add_format(const char *buf)
while (1)
{
+ struct tagcache_search_clause *newclause;
+
if (clause_count >= TAGCACHE_MAX_CLAUSES)
{
logf("too many clauses");
break;
}
- formats[format_count]->clause[clause_count] =
- buffer_alloc(sizeof(struct tagcache_search_clause));
+ newclause = buffer_alloc(sizeof(struct tagcache_search_clause));
- if (!read_clause(formats[format_count]->clause[clause_count]))
+ formats[format_count]->clause[clause_count] = newclause;
+ if (!read_clause(newclause))
break;
clause_count++;
@@ -486,6 +488,7 @@ static int add_format(const char *buf)
static int get_condition(struct search_instruction *inst)
{
+ struct tagcache_search_clause *new_clause;
int clause_count;
char buf[128];
@@ -530,10 +533,15 @@ static int get_condition(struct search_instruction *inst)
return false;
}
- inst->clause[inst->tagorder_count][clause_count] =
- buffer_alloc(sizeof(struct tagcache_search_clause));
+ new_clause = buffer_alloc(sizeof(struct tagcache_search_clause));
+ inst->clause[inst->tagorder_count][clause_count] = new_clause;
- if (!read_clause(inst->clause[inst->tagorder_count][clause_count]))
+ if (*strp == '|')
+ {
+ strp++;
+ new_clause->type = clause_logical_or;
+ }
+ else if (!read_clause(new_clause))
return -1;
inst->clause_count[inst->tagorder_count]++;
@@ -1502,6 +1510,10 @@ int tagtree_enter(struct tree_context* c)
for (j = 0; j < csi->clause_count[i]; j++)
{
char* searchstring;
+
+ if (csi->clause[i][j]->type == clause_logical_or)
+ continue;
+
source = csi->clause[i][j]->source;
if (source == source_constant)