From 641ca0eefe869638caf633b807443cad667ed9a5 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Mon, 19 May 2008 12:55:03 +0000 Subject: [PATCH] make solvable_look_bool more robust by allowing both the void or the num == 1 strategy. --- package/libsatsolver.changes | 6 ++++++ src/solvable.c | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/package/libsatsolver.changes b/package/libsatsolver.changes index cd41a1f..eb583be 100644 --- a/package/libsatsolver.changes +++ b/package/libsatsolver.changes @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Mon May 19 14:53:01 CEST 2008 - dmacvicar@suse.de + +- make solvable_look_bool more robust by allowing both + the void or the num == 1 strategy. + +------------------------------------------------------------------- Thu May 15 16:05:50 CEST 2008 - coolo@suse.de - fix susetags parser 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 * -- 2.7.4