aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <peroyvind@mandriva.org>2010-10-13 19:40:19 +0000
committerPer Øyvind Karlsen <peroyvind@mandriva.org>2010-10-13 19:40:19 +0000
commite67e1dbad30dadf14effc3ae6e83c73504d23f17 (patch)
tree77beaf4455bd59f634ad2ad75961f1030a0e6148
parent1437062907a4c5b5a3da162f6b8575abe6083b6a (diff)
downloadperl-URPM-e67e1dbad30dadf14effc3ae6e83c73504d23f17.tar
perl-URPM-e67e1dbad30dadf14effc3ae6e83c73504d23f17.tar.gz
perl-URPM-e67e1dbad30dadf14effc3ae6e83c73504d23f17.tar.bz2
perl-URPM-e67e1dbad30dadf14effc3ae6e83c73504d23f17.tar.xz
perl-URPM-e67e1dbad30dadf14effc3ae6e83c73504d23f17.zip
use rpmEVRoverlap() in ranges_overlap()
-rw-r--r--URPM.xs69
1 files changed, 13 insertions, 56 deletions
diff --git a/URPM.xs b/URPM.xs
index ea6631f..5ba8da3 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -347,64 +347,21 @@ ranges_overlap(uint32_t aflags, char *sa, uint32_t bflags, char *sb) {
if (!aflags || !bflags)
return 1; /* really faster to test it there instead of later */
else {
- int sense = 0;
char *eosa = strchr(sa, ']');
char *eosb = strchr(sb, ']');
- char *ea, *va, *ra, *eb, *vb, *rb;
-
- 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] = ':';
- 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;
+ EVR_t lEVR = rpmEVRnew(aflags, 0),
+ rEVR = rpmEVRnew(bflags, 0);
+
+ backup_char(eosa);
+ backup_char(eosb);
+ rpmEVRparse(sa, lEVR);
+ rpmEVRparse(sb, rEVR);
+ /* TODO: upstream bug? should rpmEVRparse really reset Flags? */
+ lEVR->Flags = aflags;
+ rEVR->Flags = bflags;
+ restore_chars();
+
+ return rpmEVRoverlap(lEVR,rEVR);
}
}