Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-08-23 01:49:29 -0500
committerDan McGee <dan@archlinux.org>2011-08-23 01:49:29 -0500
commit30d978a966c1d2a619acc49f204e4da1e0010c83 (patch)
tree213655259e062d4603b4f665ddc4f9941280c92c /lib/libalpm
parentcc03d6366a12cd1926e46265c63fba98f41faaae (diff)
vercmp: ensure 2.0a and 2.0.a do not compare equal
We had this interesting set of facts conundrum, according to vercmp return values: 2.0a < 2.0 2.0 < 2.0.a 2.0a == 2.0.a This introduces a code change that ensures '2.0a < 2.0.a' as would be expected by the first two comparisons. Unfortunately this stays us a bit further from upstream RPM code, but those are the breaks (in RPM, the versions involving 'a' do in fact compare the same, but they are both greater than the bare '2.0'). Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/version.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libalpm/version.c b/lib/libalpm/version.c
index 73d6a660..6b65a413 100644
--- a/lib/libalpm/version.c
+++ b/lib/libalpm/version.c
@@ -98,8 +98,8 @@ static int rpmvercmp(const char *a, const char *b)
str1 = strdup(a);
str2 = strdup(b);
- one = str1;
- two = str2;
+ one = ptr1 = str1;
+ two = ptr2 = str2;
/* loop through each version segment of str1 and str2 and compare them */
while (*one && *two) {
@@ -109,6 +109,11 @@ static int rpmvercmp(const char *a, const char *b)
/* If we ran to the end of either, we are finished with the loop */
if (!(*one && *two)) break;
+ /* If the separator lengths were different, we are also finished */
+ if ((one - ptr1) != (two - ptr2)) {
+ return (one - ptr1) < (two - ptr2) ? -1 : 1;
+ }
+
ptr1 = one;
ptr2 = two;