void rpmpsPrint(FILE *fp, rpmps ps)
{
- char * msg = NULL;
- rpmpsi psi = NULL;
- int i;
-
- if (ps == NULL || ps->probs == NULL || ps->numProblems <= 0)
- return;
-
- if (fp == NULL)
- fp = stderr;
-
- psi = rpmpsInitIterator(ps);
- while ((i = rpmpsNextIterator(psi)) >= 0) {
- int j;
- rpmProblem p = rpmpsGetProblem(psi);
-
- rpmpsi psif = rpmpsInitIterator(ps);
- /* Filter already displayed problems. */
- while ((j = rpmpsNextIterator(psif)) < i) {
- if (rpmProblemCompare(p, rpmpsGetProblem(psif)) == 0)
- break;
- }
- rpmpsFreeIterator(psif);
- if (j < i)
- continue;
-
- msg = rpmProblemString(p);
- fprintf(fp, "\t%s\n", msg);
- msg = _free(msg);
-
+ rpmProblem p;
+ rpmpsi psi = rpmpsInitIterator(ps);
+ FILE *f = (fp != NULL) ? fp : stderr;
+
+ while ((p = rpmpsiNext(psi))) {
+ char *msg = rpmProblemString(p);
+ fprintf(f, "\t%s\n", msg);
+ free(msg);
}
- psi = rpmpsFreeIterator(psi);
+ rpmpsFreeIterator(psi);
}
+
const char * pkgNEVR, fnpyKey key, const char * altNEVR,
const char * str, uint64_t number)
{
- if (te->probs == NULL)
- te->probs = rpmpsCreate();
-
+ rpmProblem o;
rpmProblem p = rpmProblemCreate(type, pkgNEVR, key, altNEVR, str, number);
- rpmpsAppendProblem(te->probs, p);
+ rpmpsi psi = rpmpsInitIterator(te->probs);
+
+ /* Only add new, unique problems to the set */
+ while ((o = rpmpsiNext(psi))) {
+ if (rpmProblemCompare(p, o) == 0)
+ break;
+ }
+ rpmpsFreeIterator(psi);
+
+ if (o == NULL) {
+ if (te->probs == NULL)
+ te->probs = rpmpsCreate();
+ rpmpsAppendProblem(te->probs, p);
+ }
rpmProblemFree(p);
}