diff options
author | Thierry Vignaud <tv@mageia.org> | 2012-06-22 16:02:35 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mageia.org> | 2012-06-22 16:02:35 +0000 |
commit | 8edbe99ac1d9c15203ef5c2c566a7507e81c080b (patch) | |
tree | ed3856f3de0de66aee37e972650e034c2ba61556 | |
parent | f4194e1a6109b908b64bd8794000b31d52d56b8b (diff) | |
download | perl-URPM-8edbe99ac1d9c15203ef5c2c566a7507e81c080b.tar perl-URPM-8edbe99ac1d9c15203ef5c2c566a7507e81c080b.tar.gz perl-URPM-8edbe99ac1d9c15203ef5c2c566a7507e81c080b.tar.bz2 perl-URPM-8edbe99ac1d9c15203ef5c2c566a7507e81c080b.tar.xz perl-URPM-8edbe99ac1d9c15203ef5c2c566a7507e81c080b.zip |
(ranges_overlap) switch to use rpmds
should have been done right away 9 years ago instead of reimplementing
older rpmRangesOverlap() in commit r11141 by fpons on Tue Apr 29 2003:
"first try of 4.2 compatible perl-URPM,
missing verify_signature,
new version 0.83"
francois I hate you!
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | URPM.xs | 62 |
2 files changed, 13 insertions, 51 deletions
@@ -1,3 +1,5 @@ +- ranges_overlap(): use rpm to compute whether it overlaps or not + Version 4.7 - 19 June 2012 - workaround changes in rpm-4.10.0 leaving us to leak fds (mga#6453) @@ -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; } } |