diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2012-10-05 10:04:04 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2012-10-05 10:07:14 +0300 |
commit | 62ddd3149fd76da72dedda63d8c870ad70138125 (patch) | |
tree | 739c4f408265dd7f09be3fb3e3e7d3ba63efe3a3 /lib/rpmds.c | |
parent | d5dd3abe097ae7c4a9552cdbf225af0309fd86db (diff) | |
download | librpm-tizen-62ddd3149fd76da72dedda63d8c870ad70138125.tar.gz librpm-tizen-62ddd3149fd76da72dedda63d8c870ad70138125.tar.bz2 librpm-tizen-62ddd3149fd76da72dedda63d8c870ad70138125.zip |
Add indexed access variants for rpmdsColor() and rpmdsCompare()
- Various places in rpm need random access to the dependency sets,
save and restore on somebody elses "iterator index" just doesn't
cut it. This is merely preliminaries for further changes.
Diffstat (limited to 'lib/rpmds.c')
-rw-r--r-- | lib/rpmds.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/lib/rpmds.c b/lib/rpmds.c index 61e6c64f4..c0b43bf27 100644 --- a/lib/rpmds.c +++ b/lib/rpmds.c @@ -117,6 +117,13 @@ static rpmsenseFlags rpmdsFlagsIndex(rpmds ds, int i) return Flags; } +static rpm_color_t rpmdsColorIndex(rpmds ds, int i) +{ + rpm_color_t Color = 0; + if (i >= 0 && i < ds->Count && ds->Color != NULL) + Color = ds->Color[i]; + return Color; +} static rpmds rpmdsUnlink(rpmds ds) { if (ds) @@ -448,13 +455,7 @@ int rpmdsSetNoPromote(rpmds ds, int nopromote) rpm_color_t rpmdsColor(const rpmds ds) { - rpm_color_t Color = 0; - - if (ds != NULL && ds->i >= 0 && ds->i < ds->Count) { - if (ds->Color != NULL) - Color = ds->Color[ds->i]; - } - return Color; + return (ds != NULL) ? rpmdsColorIndex(ds, ds->i) : 0; } rpm_color_t rpmdsSetColor(const rpmds ds, rpm_color_t color) @@ -818,14 +819,15 @@ exit: return result; } -int rpmdsCompare(const rpmds A, const rpmds B) +static int rpmdsCompareIndex(rpmds A, int aix, rpmds B, int bix) { const char *AEVR, *BEVR; rpmsenseFlags AFlags, BFlags; int result; /* Different names don't overlap. */ - if (!rpmstrPoolStreq(A->pool, rpmdsNId(A), B->pool, rpmdsNId(B))) { + if (!rpmstrPoolStreq(A->pool, rpmdsNIdIndex(A, aix), + B->pool, rpmdsNIdIndex(B, bix))) { result = 0; goto exit; } @@ -837,15 +839,15 @@ int rpmdsCompare(const rpmds A, const rpmds B) } /* Same name. If either A or B is an existence test, always overlap. */ - AFlags = rpmdsFlags(A); - BFlags = rpmdsFlags(B); + AFlags = rpmdsFlagsIndex(A, aix); + BFlags = rpmdsFlagsIndex(B, bix); if (!((AFlags & RPMSENSE_SENSEMASK) && (BFlags & RPMSENSE_SENSEMASK))) { result = 1; goto exit; } - AEVR = rpmdsEVR(A); - BEVR = rpmdsEVR(B); + AEVR = rpmdsEVRIndex(A, aix); + BEVR = rpmdsEVRIndex(B, bix); if (!(AEVR && *AEVR && BEVR && *BEVR)) { /* If either EVR is non-existent or empty, always overlap. */ result = 1; @@ -858,6 +860,11 @@ exit: return result; } +int rpmdsCompare(const rpmds A, const rpmds B) +{ + return rpmdsCompareIndex(A, A->i, B, B->i); +} + int rpmdsMatches(rpmstrPool pool, Header h, int prix, rpmds req, int selfevr, int nopromote) { |