make solvable_look_bool more robust by allowing both
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Mon, 19 May 2008 12:55:03 +0000 (12:55 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Mon, 19 May 2008 12:55:03 +0000 (12:55 +0000)
the void or the num == 1 strategy.

package/libsatsolver.changes
src/solvable.c

index cd41a1f..eb583be 100644 (file)
@@ -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
index 5f64ce3..5f79c70 100644 (file)
@@ -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 *