From: Michael Matz Date: Wed, 6 Feb 2008 19:37:45 +0000 (+0000) Subject: Make repo_lookup_num work. X-Git-Tag: BASE-SuSE-Code-12_1-Branch~308^2~663 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fac5ed4e990ddb851ec72eacc37b2d1225c8e1d;p=thirdparty%2Flibsolv.git Make repo_lookup_num work. --- diff --git a/src/repo.c b/src/repo.c index 9a78a3f3..9e44e121 100644 --- a/src/repo.c +++ b/src/repo.c @@ -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; diff --git a/src/repodata.c b/src/repodata.c index 3a974700..69a99ca9 100644 --- a/src/repodata.c +++ b/src/repodata.c @@ -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; } diff --git a/src/repodata.h b/src/repodata.h index ec1d081d..c695d789 100644 --- a/src/repodata.h +++ b/src/repodata.h @@ -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);