From d06e0785a59f9933060207be27bc8d7fb5505a01 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Thu, 20 Mar 2008 16:04:26 +0000 Subject: [PATCH] - rename str_lang to str_poollang - add str_lang lookup --- src/pool.h | 3 ++- src/repodata.c | 7 +++++++ src/repodata.h | 2 ++ src/solvable.c | 26 +++++++++++++++++++++++++- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/pool.h b/src/pool.h index c149e39..374ad81 100644 --- a/src/pool.h +++ b/src/pool.h @@ -168,7 +168,8 @@ void pool_set_languages(Pool *pool, const char **languages, int nlanguages); unsigned int solvable_lookup_num(Solvable *s, Id keyname, unsigned int notfound); const char *solvable_lookup_str(Solvable *s, Id keyname); -const char *solvable_lookup_str_lang(Solvable *s, Id keyname); +const char *solvable_lookup_str_poollang(Solvable *s, Id keyname); +const char *solvable_lookup_str_lang(Solvable *s, Id keyname, const char *lang); int solvable_lookup_bool(Solvable *s, Id keyname); char * solvable_get_location(Solvable *s, unsigned int *medianrp); const unsigned char *solvable_lookup_bin_checksum(Solvable *s, Id keyname, Id *typep); diff --git a/src/repodata.c b/src/repodata.c index d248ade..e4b0794 100644 --- a/src/repodata.c +++ b/src/repodata.c @@ -1202,6 +1202,13 @@ repodata_chk2str(Repodata *data, Id type, const unsigned char *buf) return str; } +Id repodata_globalize_id(Repodata *data, Id id) +{ + if (!data || !data->localpool) + return id; + return str2id(data->repo->pool, stringpool_id2str(&data->spool, id), 1); +} + void repodata_add_dirnumnum(Repodata *data, Id entry, Id keyname, Id dir, Id num, Id num2) { diff --git a/src/repodata.h b/src/repodata.h index d3fa84b..715a28a 100644 --- a/src/repodata.h +++ b/src/repodata.h @@ -159,4 +159,6 @@ const char *repodata_chk2str(Repodata *data, Id type, const unsigned char *buf); unsigned int repodata_compress_page(unsigned char *, unsigned int, unsigned char *, unsigned int); void repodata_read_or_setup_pages(Repodata *data, unsigned int pagesz, unsigned int blobsz); +Id repodata_globalize_id(Repodata *data, Id id); + #endif /* SATSOLVER_REPODATA_H */ diff --git a/src/solvable.c b/src/solvable.c index f346ea1..cef1eba 100644 --- a/src/solvable.c +++ b/src/solvable.c @@ -76,7 +76,7 @@ solvable_lookup_str(Solvable *s, Id keyname) } const char * -solvable_lookup_str_lang(Solvable *s, Id keyname) +solvable_lookup_str_poollang(Solvable *s, Id keyname) { Pool *pool; int i, cols; @@ -130,6 +130,30 @@ solvable_lookup_str_lang(Solvable *s, Id keyname) return repo_lookup_str(s, keyname); } +const char * +solvable_lookup_str_lang(Solvable *s, Id keyname, const char *lang) +{ + Pool *pool; + Id id; + char *p; + const char *kn, *str; + + if (!s->repo) + return repo_lookup_str(s, keyname); + pool = s->repo->pool; + kn = id2str(pool, keyname); + p = sat_malloc(strlen(kn) + strlen(lang) + 2); + sprintf(p, "%s:%s", kn, lang); + id = str2id(pool, p, 0); + if (id) + { + str = repo_lookup_str(s, id); + if (str) + return str; + } + return repo_lookup_str(s, keyname); +} + unsigned int solvable_lookup_num(Solvable *s, Id keyname, unsigned int notfound) { -- 2.7.4