mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-16 06:15:08 -05:00
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>
This commit is contained in:
parent
cc03d6366a
commit
30d978a966
@ -86,7 +86,7 @@ You can also use `pacman -Su` to upgrade all packages that are out of date. See
|
|||||||
to determine which packages need upgrading. This behavior operates as follows:
|
to determine which packages need upgrading. This behavior operates as follows:
|
||||||
|
|
||||||
Alphanumeric:
|
Alphanumeric:
|
||||||
1.0a < 1.0alpha < 1.0b < 1.0beta < 1.0p < 1.0pre < 1.0rc < 1.0
|
1.0a < 1.0b < 1.0beta < 1.0p < 1.0pre < 1.0rc < 1.0 < 1.0.a < 1.0.1
|
||||||
Numeric:
|
Numeric:
|
||||||
1 < 1.0 < 1.1 < 1.1.1 < 1.2 < 2.0 < 3.0.0
|
1 < 1.0 < 1.1 < 1.1.1 < 1.2 < 2.0 < 3.0.0
|
||||||
+
|
+
|
||||||
|
@ -26,7 +26,7 @@ numbers. It outputs values as follows:
|
|||||||
Version comparsion operates as follows:
|
Version comparsion operates as follows:
|
||||||
|
|
||||||
Alphanumeric:
|
Alphanumeric:
|
||||||
1.0a < 1.0alpha < 1.0b < 1.0beta < 1.0p < 1.0pre < 1.0rc < 1.0
|
1.0a < 1.0b < 1.0beta < 1.0p < 1.0pre < 1.0rc < 1.0 < 1.0.a < 1.0.1
|
||||||
Numeric:
|
Numeric:
|
||||||
1 < 1.0 < 1.1 < 1.1.1 < 1.2 < 2.0 < 3.0.0
|
1 < 1.0 < 1.1 < 1.1.1 < 1.2 < 2.0 < 3.0.0
|
||||||
|
|
||||||
|
@ -98,8 +98,8 @@ static int rpmvercmp(const char *a, const char *b)
|
|||||||
str1 = strdup(a);
|
str1 = strdup(a);
|
||||||
str2 = strdup(b);
|
str2 = strdup(b);
|
||||||
|
|
||||||
one = str1;
|
one = ptr1 = str1;
|
||||||
two = str2;
|
two = ptr2 = str2;
|
||||||
|
|
||||||
/* loop through each version segment of str1 and str2 and compare them */
|
/* loop through each version segment of str1 and str2 and compare them */
|
||||||
while (*one && *two) {
|
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 we ran to the end of either, we are finished with the loop */
|
||||||
if (!(*one && *two)) break;
|
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;
|
ptr1 = one;
|
||||||
ptr2 = two;
|
ptr2 = two;
|
||||||
|
|
||||||
|
@ -118,6 +118,12 @@ runtest 1.5.1 1.5.b 1
|
|||||||
runtest 1.5.b-1 1.5.b 0
|
runtest 1.5.b-1 1.5.b 0
|
||||||
runtest 1.5-1 1.5.b -1
|
runtest 1.5-1 1.5.b -1
|
||||||
|
|
||||||
|
# same/similar content, differing separators
|
||||||
|
runtest 2.0 2_0 0
|
||||||
|
runtest 2.0_a 2_0.a 0
|
||||||
|
runtest 2.0a 2.0.a -1
|
||||||
|
runtest 2___a 2_a 1
|
||||||
|
|
||||||
# epoch included version comparisons
|
# epoch included version comparisons
|
||||||
runtest 0:1.0 0:1.0 0
|
runtest 0:1.0 0:1.0 0
|
||||||
runtest 0:1.0 0:1.1 -1
|
runtest 0:1.0 0:1.1 -1
|
||||||
|
Loading…
Reference in New Issue
Block a user