Make repo_lookup_num work.
authorMichael Matz <matz@suse.de>
Wed, 6 Feb 2008 19:37:45 +0000 (19:37 +0000)
committerMichael Matz <matz@suse.de>
Wed, 6 Feb 2008 19:37:45 +0000 (19:37 +0000)
src/repo.c
src/repodata.c
src/repodata.h

index 9a78a3f..9e44e12 100644 (file)
@@ -781,8 +781,15 @@ repo_lookup_num(Solvable *s, Id key)
        continue;
       for (j = 1; j < data->nkeys; j++)
        {
-         if (data->keys[j].name == key && (data->keys[j].type == TYPE_U32 || data->keys[j].type == TYPE_NUM))
-           return repodata_lookup_num(data, n - data->start, j);
+         if (data->keys[j].name == key
+             && (data->keys[j].type == TYPE_U32
+                 || data->keys[j].type == TYPE_NUM
+                 || data->keys[j].type == TYPE_CONSTANT))
+           {
+             unsigned value;
+             if (repodata_lookup_num(data, n - data->start, j, &value))
+               return value;
+           }
        }
     }
   return 0;
index 3a97470..69a99ca 100644 (file)
@@ -423,7 +423,7 @@ repodata_lookup_str(Repodata *data, Id entry, Id keyid)
     return (const char *)dp;
   if (key->type != TYPE_ID)
     return 0;
-  /* id type, must either use global or local string strore*/
+  /* id type, must either use global or local string store*/
   dp = data_read_id(dp, &id);
   if (data->localpool)
     return data->spool.stringspace + data->spool.strings[id];
@@ -431,7 +431,7 @@ repodata_lookup_str(Repodata *data, Id entry, Id keyid)
 }
 
 int
-repodata_lookup_num(Repodata *data, Id entry, Id keyid)
+repodata_lookup_num(Repodata *data, Id entry, Id keyid, unsigned *value)
 {
   Id schema;
   Repokey *key;
@@ -439,6 +439,7 @@ repodata_lookup_num(Repodata *data, Id entry, Id keyid)
   KeyValue kv;
   unsigned char *dp;
 
+  *value = 0;
   dp = data->incoredata + data->incoreoffset[entry];
   dp = data_read_id(dp, &schema);
   /* make sure the schema of this solvable contains the key */
@@ -450,11 +451,14 @@ repodata_lookup_num(Repodata *data, Id entry, Id keyid)
   dp = get_data(data, key, &dp);
   if (!dp)
     return 0;
-  if (key->type == TYPE_NUM || key->type == TYPE_U32)
-  {
-    dp = data_fetch(dp, &kv, key);
-    return kv.num;
-  }
+  if (key->type == TYPE_NUM
+      || key->type == TYPE_U32
+      || key->type == TYPE_CONSTANT)
+    {
+      dp = data_fetch(dp, &kv, key);
+      *value = kv.num;
+      return 1;
+    }
   return 0;
 }
 
index ec1d081..c695d78 100644 (file)
@@ -101,7 +101,7 @@ typedef struct _Repodata {
 
 void repodata_search(Repodata *data, Id entry, Id keyname, int (*callback)(void *cbdata, Solvable *s, Repodata *data, struct _Repokey *key, struct _KeyValue *kv), void *cbdata);
 const char *repodata_lookup_str(Repodata *data, Id entry, Id keyid);
-int repodata_lookup_num(Repodata *data, Id entry, Id keyid);
+int repodata_lookup_num(Repodata *data, Id entry, Id keyid, unsigned *value);
 
 void repodata_extend(Repodata *data, Id p);