Mailinglist Archive: zypp-commit (171 mails)

< Previous Next >
[zypp-commit] <sat-solver> master : - add FOR_REPOS macro to iterate over repos
  • From: Michael Schroeder <mls@xxxxxxx>
  • Date: Mon, 15 Jun 2009 18:29:53 +0200
  • Message-id: <E1MGF4V-0001hb-TX@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit 17eb50eed1e1eb5064d1873f1ffa886001b0f4a2
Author: Michael Schroeder <mls@xxxxxxx>
Date: Mon Jun 15 18:29:53 2009 +0200

- add FOR_REPOS macro to iterate over repos
---
bindings/pool.i | 17 +++++++++++------
src/pool.h | 6 ++++++
tools/dumpsolv.c | 14 ++++----------
3 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/bindings/pool.i b/bindings/pool.i
index 85a8caf..7dc103c 100644
--- a/bindings/pool.i
+++ b/bindings/pool.i
@@ -506,9 +506,12 @@ typedef struct _Pool {} Pool;
*/
void each_repo()
{
+ Pool *pool = $self;
+ Repo *r;
int i;
- for (i = 0; i < $self->nrepos; ++i )
- rb_yield(SWIG_NewPointerObj((void*) $self->repos[i], SWIGTYPE_p__Repo,
0));
+
+ FOR_REPOS(i, r)
+ rb_yield(SWIG_NewPointerObj((void*)r, SWIGTYPE_p__Repo, 0));
}
#endif
#if defined(SWIGPYTHON)
@@ -530,11 +533,13 @@ typedef struct _Pool {} Pool;
*/
Repo *find_repo( const char *name )
{
+ Pool *pool = $self;
+ Repo *r;
int i;
- for (i = 0; i < $self->nrepos; ++i ) {
- if (!strcmp( $self->repos[i]->name, name ))
- return $self->repos[i];
- }
+
+ FOR_REPOS(i, r)
+ if (!strcmp(r->name, name))
+ return r;
return NULL;
}

diff --git a/src/pool.h b/src/pool.h
index 1c54264..5dc813b 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -318,6 +318,12 @@ const char *pool_lookup_checksum(Pool *pool, Id entry, Id
keyname, Id *typep);
#define FOR_PROVIDES(v, vp, d)
\
for (vp = pool_whatprovides(pool, d) ; (v = pool->whatprovidesdata[vp++]) !=
0; )

+/* loop over all repositories */
+#define FOR_REPOS(rid, r) \
+ for (rid = 0; rid < pool->nrepos; rid++) \
+ if ((r = pool->repos[rid]) != 0)
+
+
#define POOL_DEBUG(type, ...) do {if ((pool->debugmask & (type)) != 0)
pool_debug(pool, (type), __VA_ARGS__);} while (0)
#define IF_POOLDEBUG(type) if ((pool->debugmask & (type)) != 0)

diff --git a/tools/dumpsolv.c b/tools/dumpsolv.c
index aad1d24..cc6ce94 100644
--- a/tools/dumpsolv.c
+++ b/tools/dumpsolv.c
@@ -287,18 +287,16 @@ int main(int argc, char **argv)
}
#endif

- for (j = 0; 1 && j < pool->nrepos; j++)
+ n = 0;
+ FOR_REPOS(j, repo)
{
- repo = pool->repos[j];
dump_repodata(repo);

printf("repo %d contains %d solvables\n", j, repo->nsolvables);
printf("repo start: %d end: %d\n", repo->start, repo->end);
- for (i = repo->start, n = 1; i < repo->end; i++)
+ FOR_REPO_SOLVABLES(repo, i, s)
{
- s = pool->solvables + i;
- if (s->repo != repo)
- continue;
+ n++;
printf("\n");
printf("solvable %d (%d):\n", n, i);
#if 0
@@ -316,15 +314,11 @@ int main(int argc, char **argv)
printids(repo, "enhances", s->enhances);
if (repo->rpmdbid)
printf("rpmdbid: %u\n", repo->rpmdbid[i - repo->start]);
-#if 0
- dump_attrs (repo, n - 1);
-#endif
#endif
dump_repoattrs(repo, i);
#if 0
dump_some_attrs(repo, s);
#endif
- n++;
}
#if 0
tryme(repo, 0, SOLVABLE_MEDIANR, 0, 0);
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages