X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=lib%2Fvercmp.c;h=cfc7edd27519e9e1f58924ecbb5ff51e9d937a45;hb=c907b8ec08b06a4a256fd12b79b4bcf5088fbb19;hp=16cf1cdc4eab48ab1f4b89b4cac0178d23b4a858;hpb=e65e12081df227971bcf449ebcb230e1c980649b;p=zpackage diff --git a/lib/vercmp.c b/lib/vercmp.c index 16cf1cd..cfc7edd 100644 --- a/lib/vercmp.c +++ b/lib/vercmp.c @@ -13,8 +13,6 @@ struct ver { int nv; /* numeric value */ int type; /* 0 null, 1 text, 2 numeric */ - int release; - char *relstr; }; static void init_ver(struct ver *v, const char *s) { @@ -23,24 +21,8 @@ static void init_ver(struct ver *v, const char *s) { v->s = 0; v->cn = 0; v->next = v->str; - v->relstr = 0; v->keep = 0; v->sep = 0; - - /* scan for trailing release */ - int n; - n = strlen(v->str) - 1; - if (n > 0 && isdigit(v->str[n])) { - while (isdigit(v->str[n])) { - n--; - } - if (s[n] == '-') { - v->relstr = v->str + n; - v->release = atoi(v->str + n + 1); - v->str[n] = 0; - } - } - } static int ver_cmp(struct ver *a, struct ver *b) { @@ -54,7 +36,9 @@ static int ver_cmp(struct ver *a, struct ver *b) { int cmp; if (a->s && ! b->s) return 1; if (b->s && ! a->s) return -1; - if (!b->s && ! a->s) return 0; + if (!b->s && ! a->s) { + return 0; + } cmp = strcmp(a->s, b->s); if (cmp == 0) { return 0; @@ -117,6 +101,16 @@ int zpm_vercmp(const char *vsa, const char *vsb) { int an, bn; int cmp; + if (vsa && !vsb) { + return 1; + } + if (vsb && !vsa) { + return -1; + } + if (!vsa && !vsb) { + return 0; + } + init_ver(&a, vsa); init_ver(&b, vsb); do { @@ -139,10 +133,5 @@ int zpm_vercmp(const char *vsa, const char *vsb) { } } while (an && bn); - /* if we've gotten here, and both have releases, check those */ - if (a.relstr && b.relstr && a.release != b.release) { - return a.release < b.release ? -1 : 1; - } - return 0; }