diff options
author | Duncan Mac-Vicar P <dmacvicar@suse.de> | 2008-05-19 12:55:03 +0000 |
---|---|---|
committer | Duncan Mac-Vicar P <dmacvicar@suse.de> | 2008-05-19 12:55:03 +0000 |
commit | 641ca0eefe869638caf633b807443cad667ed9a5 (patch) | |
tree | 571d9b0eb2372fc707a76046e10fe4a3a95629a1 /src | |
parent | 81677d3a0df97cc8b90008d567e316b16bddceb7 (diff) | |
download | libsolv-641ca0eefe869638caf633b807443cad667ed9a5.tar.gz libsolv-641ca0eefe869638caf633b807443cad667ed9a5.tar.bz2 libsolv-641ca0eefe869638caf633b807443cad667ed9a5.zip |
make solvable_look_bool more robust by allowing both
the void or the num == 1 strategy.
Diffstat (limited to 'src')
-rw-r--r-- | src/solvable.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/solvable.c b/src/solvable.c index 5f64ce3..5f79c70 100644 --- a/src/solvable.c +++ b/src/solvable.c @@ -257,7 +257,43 @@ solvable_lookup_void(Solvable *s, Id keyname) int solvable_lookup_bool(Solvable *s, Id keyname) { - return solvable_lookup_void(s, keyname); + Repo *repo = s->repo; + Pool *pool; + Repodata *data; + int i, j, n; + + if (!repo) + return 0; + pool = repo->pool; + n = s - pool->solvables; + for (i = 0, data = repo->repodata; i < repo->nrepodata; i++, data++) + { + if (n < data->start || n >= data->end) + continue; + /* there are two ways of storing a bool */ + for (j = 1; j < data->nkeys; j++) + { + /* as a num == 1 */ + if (data->keys[j].name == keyname + && (data->keys[j].type == REPOKEY_TYPE_U32 + || data->keys[j].type == REPOKEY_TYPE_NUM + || data->keys[j].type == REPOKEY_TYPE_CONSTANT)) + { + unsigned int value; + if (repodata_lookup_num(data, n - data->start, j, &value)) + return value == 1; + } + + /* as a void attribute, if it is there, then true */ + if (data->keys[j].name == keyname + && (data->keys[j].type == REPOKEY_TYPE_VOID)) + { + if (repodata_lookup_void(data, n - data->start, j)) + return 1; + } + } + } + return 0; } const unsigned char * |