diff options
-rw-r--r-- | bindings/solv.i | 7 | ||||
-rw-r--r-- | src/libsolv.ver | 1 | ||||
-rw-r--r-- | src/problems.c | 12 | ||||
-rw-r--r-- | src/problems.h | 1 |
4 files changed, 15 insertions, 6 deletions
diff --git a/bindings/solv.i b/bindings/solv.i index 77d744a..1f9259b 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -2400,12 +2400,7 @@ rb_eval_string( %rename("str") __str__; #endif const char *__str__() { - Id type, source, target, dep; - Id r = solver_findproblemrule($self->solv, $self->id); - if (!r) - return ""; - type = solver_ruleinfo($self->solv, r, &source, &target, &dep); - return solver_problemruleinfo2str($self->solv, type, source, target, dep); + return solver_problem2str($self->solv, $self->id); } } diff --git a/src/libsolv.ver b/src/libsolv.ver index a902591..4be79f9 100644 --- a/src/libsolv.ver +++ b/src/libsolv.ver @@ -353,6 +353,7 @@ SOLV_1.0 { solver_printsolution; solver_printtrivial; solver_printwatches; + solver_problem2str; solver_problem_count; solver_problemruleinfo2str; solver_rule2job; diff --git a/src/problems.c b/src/problems.c index fa2c31b..44d0c21 100644 --- a/src/problems.c +++ b/src/problems.c @@ -1103,6 +1103,18 @@ solver_problemruleinfo2str(Solver *solv, SolverRuleinfo type, Id source, Id targ } } +/* convenience function */ +const char * +solver_problem2str(Solver *solv, Id problem) +{ + Id type, source, target, dep; + Id r = solver_findproblemrule(solv, problem); + if (!r) + return "no problem rule?"; + type = solver_ruleinfo(solv, r, &source, &target, &dep); + return solver_problemruleinfo2str(solv, type, source, target, dep); +} + const char * solver_solutionelement2str(Solver *solv, Id p, Id rp) { diff --git a/src/problems.h b/src/problems.h index b2b7053..e5b2279 100644 --- a/src/problems.h +++ b/src/problems.h @@ -48,6 +48,7 @@ Id solver_findproblemrule(struct _Solver *solv, Id problem); void solver_findallproblemrules(struct _Solver *solv, Id problem, Queue *rules); extern const char *solver_problemruleinfo2str(struct _Solver *solv, SolverRuleinfo type, Id source, Id target, Id dep); +extern const char *solver_problem2str(struct _Solver *solv, Id problem); extern const char *solver_solutionelement2str(struct _Solver *solv, Id p, Id rp); #ifdef __cplusplus |