aboutsummaryrefslogtreecommitdiffstats
path: root/URPM.xs
diff options
context:
space:
mode:
Diffstat (limited to 'URPM.xs')
-rw-r--r--URPM.xs62
1 files changed, 11 insertions, 51 deletions
diff --git a/URPM.xs b/URPM.xs
index 4ae3775..46450e6 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -241,64 +241,24 @@ ranges_overlap(rpmsenseFlags aflags, char *sa, rpmsenseFlags bflags, char *sb) {
if (!aflags || !bflags)
return 1; /* really faster to test it there instead of later */
else {
- int sense = 0;
+ int res;
char *eosa = strchr(sa, ']');
char *eosb = strchr(sb, ']');
- char *ea, *va, *ra, *eb, *vb, *rb;
+ rpmds dsa, dsb;
if (eosa) *eosa = 0;
if (eosb) *eosb = 0;
- /* parse sa as an [epoch:]version[-release] */
- for (ea = sa; *sa >= '0' && *sa <= '9'; ++sa);
- if (*sa == ':') {
- *sa++ = 0; /* ea could be an empty string (should be interpreted as 0) */
- va = sa;
- } else {
- va = ea; /* no epoch */
- ea = NULL;
- }
- if ((ra = strrchr(sa, '-'))) *ra++ = 0;
- /* parse sb as an [epoch:]version[-release] */
- for (eb = sb; *sb >= '0' && *sb <= '9'; ++sb);
- if (*sb == ':') {
- *sb++ = 0; /* ea could be an empty string (should be interpreted as 0) */
- vb = sb;
- } else {
- vb = eb; /* no epoch */
- eb = NULL;
- }
- if ((rb = strrchr(sb, '-'))) *rb++ = 0;
- /* now compare epoch */
- if (ea && eb)
- sense = rpmvercmp(*ea ? ea : "0", *eb ? eb : "0");
- else if (ea && *ea && atol(ea) > 0)
- sense = 1;
- else if (eb && *eb && atol(eb) > 0)
- sense = -1;
- /* now compare version and release if epoch has not been enough */
- if (sense == 0) {
- sense = rpmvercmp(va, vb);
- if (sense == 0 && ra && *ra && rb && *rb)
- sense = rpmvercmp(ra, rb);
- }
- /* restore all character that have been modified inline */
- if (rb) rb[-1] = '-';
- if (ra) ra[-1] = '-';
- if (eb) vb[-1] = ':';
- if (ea) va[-1] = ':';
+
+ dsa = rpmdsSingle(RPMTAG_REQUIRENAME, "", sa, aflags);
+ dsb = rpmdsSingle(RPMTAG_REQUIRENAME, "", sb, bflags);
+ res = rpmdsCompare(dsa, dsb);
+ rpmdsFree(dsa);
+ rpmdsFree(dsb);
+
if (eosb) *eosb = ']';
if (eosa) *eosa = ']';
- /* finish the overlap computation */
- if (sense < 0 && ((aflags & RPMSENSE_GREATER) || (bflags & RPMSENSE_LESS)))
- return 1;
- else if (sense > 0 && ((aflags & RPMSENSE_LESS) || (bflags & RPMSENSE_GREATER)))
- return 1;
- else if (sense == 0 && (((aflags & RPMSENSE_EQUAL) && (bflags & RPMSENSE_EQUAL)) ||
- ((aflags & RPMSENSE_LESS) && (bflags & RPMSENSE_LESS)) ||
- ((aflags & RPMSENSE_GREATER) && (bflags & RPMSENSE_GREATER))))
- return 1;
- else
- return 0;
+
+ return res;
}
}