pkg: implement dpkg-style version comparison rules

feature/tap-sh
William Pitcock 2012-07-23 21:07:57 -05:00
parent da7e3de991
commit 3388277b9b
1 changed files with 15 additions and 3 deletions

18
pkg.c
View File

@ -394,13 +394,25 @@ pkg_compare_version(const char *a, const char *b)
one = str1 = buf1; one = str1 = buf1;
two = str2 = buf2; two = str2 = buf2;
while (*one && *two) while (*one || *two)
{ {
while (*one && !isalnum(*one)) while (*one && !isalnum(*one) && *one != '~')
one++; one++;
while (*two && !isalnum(*two)) while (*two && !isalnum(*two) && *two != '~')
two++; two++;
if (*one == '~' || *two == '~')
{
if (*one != '~')
return 1;
if (*two != '~')
return -1;
one++;
two++;
continue;
}
if (!(*one && *two)) if (!(*one && *two))
break; break;