int nv; /* numeric value */
int type; /* 0 null, 1 text, 2 numeric */
- int release;
- char *relstr;
};
-static void init_ver(struct ver *v, char *s) {
+static void init_ver(struct ver *v, const char *s) {
strncpy(v->str, s, 1023);
v->str[1023] = 0;
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) {
}
if (a->type == 1) {
int cmp;
+ if (a->s && ! b->s) return 1;
+ if (b->s && ! a->s) return -1;
+ if (!b->s && ! a->s) {
+ return 0;
+ }
cmp = strcmp(a->s, b->s);
if (cmp == 0) {
return 0;
/*
* alphabetic less than numeric
*/
-int zpm_vercmp(char *vsa, char *vsb) {
+int zpm_vercmp(const char *vsa, const char *vsb) {
struct ver a, b;
int an, bn;
int cmp;
}
return an < bn ? -1 : 1;
}
+ if (an == 0 && bn == 0) {
+ return 0;
+ }
cmp = ver_cmp(&a, &b);
if (cmp != 0) {
return cmp;
}
} 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;
}