xbps_cmpver: test for DEWEY_GT because it's most commonly used.

Also some code that handled "netbsd" pkg revisions have been removed,
we don't/won't use it.
This commit is contained in:
Juan RP 2011-06-25 12:37:10 +02:00
parent e218e710f9
commit a984c60437

View File

@ -68,7 +68,6 @@ typedef struct arr_t {
unsigned c; /* # of version numbers */ unsigned c; /* # of version numbers */
unsigned size; /* size of array */ unsigned size; /* size of array */
int *v; /* array of decimal numbers */ int *v; /* array of decimal numbers */
int netbsd; /* any "nb" suffix */
} arr_t; } arr_t;
/* this struct describes a test */ /* this struct describes a test */
@ -131,10 +130,9 @@ dewey_mktest(int *op, const char *test)
static int static int
mkcomponent(arr_t *ap, const char *num) mkcomponent(arr_t *ap, const char *num)
{ {
static const char alphas[] = "abcdefghijklmnopqrstuvwxyz"; const test_t *modp;
const test_t *modp; int n;
int n; const char *cp;
const char *cp;
if (ap->c == ap->size) { if (ap->c == ap->size) {
if (ap->size == 0) { if (ap->size == 0) {
@ -167,26 +165,6 @@ mkcomponent(arr_t *ap, const char *num)
return modp->len; return modp->len;
} }
} }
if (strncasecmp(num, "nb", 2) == 0) {
for (cp = num, num += 2, n = 0 ; isdigit((unsigned char)*num) ; num++) {
n = (n * 10) + (*num - '0');
}
ap->netbsd = n;
return (int)(num - cp);
}
if (isalpha((unsigned char)*num)) {
ap->v[ap->c++] = Dot;
cp = strchr(alphas, tolower((unsigned char)*num));
if (ap->c == ap->size) {
ap->size *= 2;
if ((ap->v = realloc(ap->v, ap->size * sizeof(int))) == NULL) {
xbps_dbg_printf("%s: ENOMEM!\n", __func__);
exit(EXIT_FAILURE);
}
}
ap->v[ap->c++] = (int)(cp - alphas) + 1;
return 1;
}
return 1; return 1;
} }
@ -197,7 +175,6 @@ mkversion(arr_t *ap, const char *num)
ap->c = 0; ap->c = 0;
ap->size = 0; ap->size = 0;
ap->v = NULL; ap->v = NULL;
ap->netbsd = 0;
while (*num) { while (*num) {
num += mkcomponent(ap, num); num += mkcomponent(ap, num);
@ -250,7 +227,7 @@ vtest(arr_t *lhs, int tst, arr_t *rhs)
return result(cmp, tst); return result(cmp, tst);
} }
} }
return result(lhs->netbsd - rhs->netbsd, tst); return 0;
} }
/* /*
@ -283,10 +260,10 @@ dewey_cmp(const char *lhs, int op, const char *rhs)
int int
xbps_cmpver(const char *pkg1, const char *pkg2) xbps_cmpver(const char *pkg1, const char *pkg2)
{ {
if (dewey_cmp(pkg1, DEWEY_LT, pkg2)) if (dewey_cmp(pkg1, DEWEY_GT, pkg2))
return -1;
else if (dewey_cmp(pkg1, DEWEY_GT, pkg2))
return 1; return 1;
else if (dewey_cmp(pkg1, DEWEY_LT, pkg2))
return -1;
else else
return 0; return 0;
} }