|
|
@@ -32,6 +32,41 @@ int epochsdiffer(const struct versionrevision *a,
|
|
|
return a->epoch != b->epoch;
|
|
|
}
|
|
|
|
|
|
+/* assume ascii; warning: evaluates x multiple times! */
|
|
|
+#define order(x) ((x) == '~' ? -1 \
|
|
|
+ : isdigit((x)) ? 0 \
|
|
|
+ : !(x) ? 0 \
|
|
|
+ : isalpha((x)) ? (x) \
|
|
|
+ : (x) + 256)
|
|
|
+
|
|
|
+static int verrevcmp(const char *val, const char *ref) {
|
|
|
+ if (!val) val= "";
|
|
|
+ if (!ref) ref= "";
|
|
|
+
|
|
|
+ while (*val || *ref) {
|
|
|
+ int first_diff= 0;
|
|
|
+
|
|
|
+ while ( (*val && !isdigit(*val)) || (*ref && !isdigit(*ref)) ) {
|
|
|
+ int vc= order(*val), rc= order(*ref);
|
|
|
+ if (vc != rc) return vc - rc;
|
|
|
+ val++; ref++;
|
|
|
+ }
|
|
|
+
|
|
|
+ while ( *val == '0' ) val++;
|
|
|
+ while ( *ref == '0' ) ref++;
|
|
|
+ while (isdigit(*val) && isdigit(*ref)) {
|
|
|
+ if (!first_diff) first_diff= *val - *ref;
|
|
|
+ val++; ref++;
|
|
|
+ }
|
|
|
+ if (isdigit(*val)) return 1;
|
|
|
+ if (isdigit(*ref)) return -1;
|
|
|
+ if (first_diff) return first_diff;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+#if 0
|
|
|
static int verrevcmp(const char *ival, const char *iref) {
|
|
|
static char empty[] = "";
|
|
|
int vc, rc;
|
|
|
@@ -64,6 +99,7 @@ static int verrevcmp(const char *ival, const char *iref) {
|
|
|
if (!*ref) return +1;
|
|
|
}
|
|
|
}
|
|
|
+#endif
|
|
|
|
|
|
int versioncompare(const struct versionrevision *version,
|
|
|
const struct versionrevision *refversion) {
|