From d9d59c89301de242a008a55d3ee93b0c710937eb Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 26 Mar 2010 09:20:05 +0200 Subject: [PATCH] Add a simple and dumb rpmpsMerge() function to merge two problem sets --- lib/rpmps.c | 16 ++++++++++++++++ lib/rpmps.h | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/rpmps.c b/lib/rpmps.c index 980add8..6089e38 100644 --- a/lib/rpmps.c +++ b/lib/rpmps.c @@ -189,6 +189,22 @@ int rpmpsTrim(rpmps ps, rpmps filter) return gotProblems; } +/* + * TODO: filter out duplicates while merging. Also horribly inefficient... */ +int rpmpsMerge(rpmps dest, rpmps src) +{ + int rc = 0; + if (dest != NULL) { + rpmProblem p; + rpmpsi spi = rpmpsInitIterator(src); + while ((p = rpmpsiNext(spi)) != NULL) { + rpmpsAppendProblem(dest, p); + rc++; + } + } + return rc; +} + void rpmpsPrint(FILE *fp, rpmps ps) { char * msg = NULL; diff --git a/lib/rpmps.h b/lib/rpmps.h index 4fc8875..9414d2d 100644 --- a/lib/rpmps.h +++ b/lib/rpmps.h @@ -137,6 +137,14 @@ void rpmpsAppend(rpmps ps, rpmProblemType type, */ int rpmpsTrim(rpmps ps, rpmps filter); +/** \ingroup rpmps + * Merge problem set into another. + * @param dest destination problem set + * @param src source problem set + * @return number of problems merged + */ +int rpmpsMerge(rpmps dest, rpmps src); + #ifdef __cplusplus } #endif -- 2.7.4