summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrjray <devnull@localhost>2002-04-12 00:16:33 +0000
committerrjray <devnull@localhost>2002-04-12 00:16:33 +0000
commitaaca0fed295459215eb41e40bedbc3fa25fefc5c (patch)
tree9670b94d9949fee110ab9699fb403ef79f8f48af
parent2f1222755ba4574ef358779b53a950bc5bdff1d0 (diff)
downloadrpm-aaca0fed295459215eb41e40bedbc3fa25fefc5c.tar.gz
rpm-aaca0fed295459215eb41e40bedbc3fa25fefc5c.tar.bz2
rpm-aaca0fed295459215eb41e40bedbc3fa25fefc5c.zip
First of two efforts at redefining how multiple packages for one name are
handled. This applies the patch from Gerald Teschl <gt@esi.ac.at> that makes a multiple match yield the newest, rather than the first one encountered. After this, I'll try to handle list-context. CVS patchset: 5398 CVS date: 2002/04/12 00:16:33
-rw-r--r--Perl-RPM/RPM/Database.xs20
1 files changed, 17 insertions, 3 deletions
diff --git a/Perl-RPM/RPM/Database.xs b/Perl-RPM/RPM/Database.xs
index 96cac53bb..c768fb250 100644
--- a/Perl-RPM/RPM/Database.xs
+++ b/Perl-RPM/RPM/Database.xs
@@ -5,7 +5,7 @@
#include <fcntl.h>
#include "RPM.h"
-static char * const rcsid = "$Id: Database.xs,v 1.16 2002/04/11 22:41:15 rjray Exp $";
+static char * const rcsid = "$Id: Database.xs,v 1.17 2002/04/12 00:16:33 rjray Exp $";
/*
rpmdb_TIEHASH
@@ -82,6 +82,7 @@ SV* rpmdb_FETCH(pTHX_ RPM__Database self, SV* key)
int namelen; /* Arg for SvPV(..., len) */
int offset; /* In case they pass an integer offset */
Header hdr; /* For rpmdbGetRecord() calls */
+ Header lasthdr; /* For searching latest rpm */
rpmdbMatchIterator mi;
SV** svp;
SV* FETCH;
@@ -106,11 +107,24 @@ SV* rpmdb_FETCH(pTHX_ RPM__Database self, SV* key)
return newSVsv(*svp);
offset = -1;
+ lasthdr = NULL;
mi = rpmdbInitIterator(dbstruct->dbp, RPMTAG_NAME, name, 0);
while ((hdr = rpmdbNextIterator(mi)) != NULL)
{
- offset = rpmdbGetIteratorOffset(mi);
- break;
+ /* There might be more than one match. Find the newest one. */
+ if (lasthdr == NULL)
+ {
+ lasthdr = headerLink(hdr);
+ offset = rpmdbGetIteratorOffset(mi);
+ }
+ else
+ {
+ if (rpmVersionCompare(hdr, lasthdr) == 1)
+ {
+ lasthdr = headerLink(hdr);
+ offset = rpmdbGetIteratorOffset(mi);
+ }
+ }
}
rpmdbFreeIterator(mi);
if (offset == -1)