From 6861611dc8a8dcce70578d4494d9fbb7352ff019 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Wed, 21 Aug 2013 14:34:46 +0200 Subject: make solver_describe_decision always return a rule, add solver_rule2solvable() that way users of describe_decision have the correct rule, they can use solver_rule2solvable to get the id of the solvable. --- src/libsolv.ver | 1 + src/rules.c | 10 ++++++++++ src/rules.h | 1 + src/solver.c | 20 +++----------------- 4 files changed, 15 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/libsolv.ver b/src/libsolv.ver index 7982dbb..eec2018 100644 --- a/src/libsolv.ver +++ b/src/libsolv.ver @@ -350,6 +350,7 @@ SOLV_1.0 { solver_problemruleinfo2str; solver_rule2job; solver_rule2jobidx; + solver_rule2solvable; solver_ruleclass; solver_ruleinfo; solver_ruleliterals; diff --git a/src/rules.c b/src/rules.c index ae14eba..677807c 100644 --- a/src/rules.c +++ b/src/rules.c @@ -2307,6 +2307,16 @@ solver_rule2job(Solver *solv, Id rid, Id *whatp) return solv->job.elements[idx]; } +Id +solver_rule2solvable(Solver *solv, Id rid) +{ + if (rid >= solv->updaterules && rid < solv->updaterules_end) + return rid - solv->updaterules; + if (rid >= solv->featurerules && rid < solv->featurerules_end) + return rid - solv->featurerules; + return 0; +} + /* check if the newest versions of pi still provides the dependency we're looking for */ static int solver_choicerulecheck(Solver *solv, Id pi, Rule *r, Map *m) diff --git a/src/rules.h b/src/rules.h index 9205b86..42e8285 100644 --- a/src/rules.h +++ b/src/rules.h @@ -138,6 +138,7 @@ extern SolverRuleinfo solver_ruleclass(struct _Solver *solv, Id rid); extern void solver_ruleliterals(struct _Solver *solv, Id rid, Queue *q); extern int solver_rule2jobidx(struct _Solver *solv, Id rid); extern Id solver_rule2job(struct _Solver *solv, Id rid, Id *whatp); +extern Id solver_rule2solvable(struct _Solver *solv, Id rid); #ifdef __cplusplus diff --git a/src/solver.c b/src/solver.c index a846477..eb4afde 100644 --- a/src/solver.c +++ b/src/solver.c @@ -4025,11 +4025,7 @@ solver_describe_decision(Solver *solv, Id p, Id *infop) if (i < solv->decisioncnt_update) { if (i == 0) - { - if (infop) - *infop = SYSTEMSOLVABLE; - return SOLVER_REASON_KEEP_INSTALLED; - } + return SOLVER_REASON_KEEP_INSTALLED; if (infop) *infop = why; return SOLVER_REASON_RESOLVE_JOB; @@ -4039,12 +4035,7 @@ solver_describe_decision(Solver *solv, Id p, Id *infop) if (why == 0 && pp < 0) return SOLVER_REASON_CLEANDEPS_ERASE; if (infop) - { - if (why >= solv->updaterules && why < solv->updaterules_end) - *infop = why - solv->updaterules; - else if (why >= solv->featurerules && why < solv->featurerules_end) - *infop = why - solv->featurerules; - } + *infop = why; return SOLVER_REASON_UPDATE_INSTALLED; } if (i < solv->decisioncnt_resolve) @@ -4052,12 +4043,7 @@ solver_describe_decision(Solver *solv, Id p, Id *infop) if (why == 0 && pp < 0) return SOLVER_REASON_CLEANDEPS_ERASE; if (infop) - { - if (why >= solv->updaterules && why < solv->updaterules_end) - *infop = why - solv->updaterules; - else if (why >= solv->featurerules && why < solv->featurerules_end) - *infop = why - solv->featurerules; - } + *infop = why; return SOLVER_REASON_KEEP_INSTALLED; } if (i < solv->decisioncnt_weak) -- cgit v1.2.3