diff options
author | Michael Schroeder <mls@suse.de> | 2014-04-08 11:43:06 +0200 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2014-04-08 11:43:06 +0200 |
commit | c8e2acdc6c28d39193d24c9ca0a934ee43225648 (patch) | |
tree | 73ebe1327b55da82e8d6ce690c176f4920cd0dc8 /src | |
parent | bc61a35f537078664825a35c86895eb20d847d1f (diff) | |
download | libsolv-c8e2acdc6c28d39193d24c9ca0a934ee43225648.tar.gz libsolv-c8e2acdc6c28d39193d24c9ca0a934ee43225648.tar.bz2 libsolv-c8e2acdc6c28d39193d24c9ca0a934ee43225648.zip |
make repodata_stringify return the result string
This is in preparation of stringify no longer patching
the str element in the kv.
Diffstat (limited to 'src')
-rw-r--r-- | src/repo.c | 5 | ||||
-rw-r--r-- | src/repodata.c | 28 | ||||
-rw-r--r-- | src/repodata.h | 6 |
3 files changed, 20 insertions, 19 deletions
@@ -907,12 +907,13 @@ repo_matchvalue(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValu if (md->matcher.match) { + const char *str; if (key->name == SOLVABLE_FILELIST && key->type == REPOKEY_TYPE_DIRSTRARRAY && (md->matcher.flags & SEARCH_FILES) != 0) if (!datamatcher_checkbasename(&md->matcher, kv->str)) return 0; - if (!repodata_stringify(md->pool, data, key, kv, md->flags)) + if (!(str = repodata_stringify(md->pool, data, key, kv, md->flags))) return 0; - if (!datamatcher_match(&md->matcher, kv->str)) + if (!datamatcher_match(&md->matcher, str)) return 0; } md->stop = md->callback(md->callback_data, s, data, key, kv); diff --git a/src/repodata.c b/src/repodata.c index 85e9103..62ec955 100644 --- a/src/repodata.c +++ b/src/repodata.c @@ -855,7 +855,7 @@ repodata_lookup_id_uninternalized(Repodata *data, Id solvid, Id keyname, Id void */ -int +const char * repodata_stringify(Pool *pool, Repodata *data, Repokey *key, KeyValue *kv, int flags) { switch (key->type) @@ -875,26 +875,26 @@ repodata_stringify(Pool *pool, Repodata *data, Repokey *key, KeyValue *kv, int f if (*s == ':' && s > kv->str) kv->str = s + 1; } - return 1; + return kv->str; case REPOKEY_TYPE_STR: - return 1; + return kv->str; case REPOKEY_TYPE_DIRSTRARRAY: if (!(flags & SEARCH_FILES)) - return 1; /* match just the basename */ + return kv->str; /* match just the basename */ if (kv->num) - return 1; /* already stringified */ + return kv->str; /* already stringified */ /* Put the full filename into kv->str. */ kv->str = repodata_dir2str(data, kv->id, kv->str); kv->num = 1; /* mark stringification */ - return 1; + return kv->str; case_CHKSUM_TYPES: if (!(flags & SEARCH_CHECKSUMS)) return 0; /* skip em */ if (kv->num) - return 1; /* already stringified */ + return kv->str; /* already stringified */ kv->str = repodata_chk2str(data, key->type, (const unsigned char *)kv->str); kv->num = 1; /* mark stringification */ - return 1; + return kv->str; default: return 0; } @@ -1736,17 +1736,18 @@ dataiterator_step(Dataiterator *di) if (di->matcher.match) { + const char *str; /* simple pre-check so that we don't need to stringify */ if (di->keyname == SOLVABLE_FILELIST && di->key->type == REPOKEY_TYPE_DIRSTRARRAY && (di->matcher.flags & SEARCH_FILES) != 0) if (!datamatcher_checkbasename(&di->matcher, di->kv.str)) continue; - if (!repodata_stringify(di->pool, di->data, di->key, &di->kv, di->flags)) + if (!(str = repodata_stringify(di->pool, di->data, di->key, &di->kv, di->flags))) { if (di->keyname && (di->key->type == REPOKEY_TYPE_FIXARRAY || di->key->type == REPOKEY_TYPE_FLEXARRAY)) return 1; continue; } - if (!datamatcher_match(&di->matcher, di->kv.str)) + if (!datamatcher_match(&di->matcher, str)) continue; } else @@ -1970,11 +1971,10 @@ dataiterator_jump_to_repo(Dataiterator *di, Repo *repo) int dataiterator_match(Dataiterator *di, Datamatcher *ma) { - if (!repodata_stringify(di->pool, di->data, di->key, &di->kv, di->flags)) + const char *str; + if (!(str = repodata_stringify(di->pool, di->data, di->key, &di->kv, di->flags))) return 0; - if (!ma) - return 1; - return datamatcher_match(ma, di->kv.str); + return ma ? datamatcher_match(ma, str) : 1; } void diff --git a/src/repodata.h b/src/repodata.h index 31d0158..ad05525 100644 --- a/src/repodata.h +++ b/src/repodata.h @@ -198,9 +198,9 @@ repodata_has_keyname(Repodata *data, Id keyname) * Call <callback> for each match */ void repodata_search(Repodata *data, Id solvid, Id keyname, int flags, int (*callback)(void *cbdata, Solvable *s, Repodata *data, Repokey *key, struct _KeyValue *kv), void *cbdata); -/* Make sure the found KeyValue has the "str" field set. Return false - * if not possible */ -int repodata_stringify(Pool *pool, Repodata *data, Repokey *key, struct _KeyValue *kv, int flags); +/* Make sure the found KeyValue has the "str" field set. Return "str" + * if valid, NULL if not possible */ +const char *repodata_stringify(Pool *pool, Repodata *data, Repokey *key, struct _KeyValue *kv, int flags); int repodata_filelistfilter_matches(Repodata *data, const char *str); |