]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Allow to lookup a single id with repodata_lookup_idarray
authorMichael Schroeder <mls@suse.de>
Tue, 9 Apr 2019 09:13:17 +0000 (11:13 +0200)
committerMichael Schroeder <mls@suse.de>
Tue, 9 Apr 2019 09:34:22 +0000 (11:34 +0200)
I don't see any harm in allowing this and it makes dealing with
things like SOLVABLE_LICENSE easier which can be either an id
(the old way) or an id array (the new way).

src/repodata.c

index ad5aaea31e13bbc4d9cc13462c19caf844cb13f0..54d5bb2391d347b477d40824bab6bb9445b920cf 100644 (file)
@@ -791,14 +791,28 @@ repodata_lookup_idarray(Repodata *data, Id solvid, Id keyname, Queue *q)
 
   queue_empty(q);
   dp = find_key_data(data, solvid, keyname, &key);
-  if (!dp || key->type != REPOKEY_TYPE_IDARRAY)
+  if (!dp)
     return 0;
-  for (;;)
+  switch (key->type)
     {
-      dp = data_read_ideof(dp, &id, &eof);
+    case REPOKEY_TYPE_CONSTANTID:
+      queue_push(q, key->size);
+      break;
+    case REPOKEY_TYPE_ID:
+      dp = data_read_id(dp, &id);
       queue_push(q, id);
-      if (eof)
-       break;
+      break;
+    case REPOKEY_TYPE_IDARRAY:
+      for (;;)
+       {
+         dp = data_read_ideof(dp, &id, &eof);
+         queue_push(q, id);
+         if (eof)
+           break;
+       }
+      break;
+    default:
+      return 0;
     }
   return 1;
 }