Switch xbps_cmpver() to use NetBSD's dewey code.

This commit is contained in:
Juan RP
2011-06-04 15:42:50 +02:00
parent 47e3a3f39b
commit 51bee11bfa
3 changed files with 18 additions and 286 deletions

View File

@@ -254,7 +254,7 @@ vtest(arr_t *lhs, int tst, arr_t *rhs)
}
/*
* Compare two dewey decimal numbers
* Compare two dewey decimal numbers.
*/
static int
dewey_cmp(const char *lhs, int op, const char *rhs)
@@ -275,6 +275,22 @@ dewey_cmp(const char *lhs, int op, const char *rhs)
return retval;
}
/*
* Returns -1, 0 or 1 depending on if the version components of
* pkg1 is less than, equal to or greater than pkg2. No comparison
* comparison of the basenames is done.
*/
int
xbps_cmpver(const char *pkg1, const char *pkg2)
{
if (dewey_cmp(pkg1, DEWEY_LT, pkg2))
return -1;
else if (dewey_cmp(pkg1, DEWEY_GT, pkg2))
return 1;
else
return 0;
}
/*
* Perform dewey match on "pkg" against "pattern".
* Return 1 on match, 0 on non-match, -1 on error.