mesa-7.9: bump PR after talloc changes
[openembedded.git] / recipes / ipkg / files / update_version_comparision.patch
blobb0d0df525bebb1038a89e775ad79b9169679a539
1 Update the version comparision to a more recent one from dpkg. This
2 means it now recognises 0.0-foo > 0.0+foo as it should.
4 RP - 19/02/2008
6 Index: ipkg-0.99.163/pkg.c
7 ===================================================================
8 --- ipkg-0.99.163.orig/pkg.c 2008-02-18 11:24:45.000000000 +0000
9 +++ ipkg-0.99.163/pkg.c 2008-02-19 00:24:50.000000000 +0000
10 @@ -1128,43 +1130,37 @@
11 return r;
14 -int verrevcmp(const char *val, const char *ref)
16 - int vc, rc;
17 - long vl, rl;
18 - const char *vp, *rp;
19 - const char *vsep, *rsep;
21 - if (!val) val= "";
22 - if (!ref) ref= "";
23 - for (;;) {
24 - vp= val; while (*vp && !isdigit(*vp)) vp++;
25 - rp= ref; while (*rp && !isdigit(*rp)) rp++;
26 - for (;;) {
27 - vc= (val == vp) ? 0 : *val++;
28 - rc= (ref == rp) ? 0 : *ref++;
29 - if (!rc && !vc) break;
30 - if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
31 - if (rc && !isalpha(rc)) rc += 256;
32 - if (vc != rc) return vc - rc;
33 - }
34 - val= vp;
35 - ref= rp;
36 - vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10);
37 - rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10);
38 - if (vl != rl) return vl - rl;
40 - vc = *val;
41 - rc = *ref;
42 - vsep = strchr(".-", vc);
43 - rsep = strchr(".-", rc);
44 - if (vsep && !rsep) return -1;
45 - if (!vsep && rsep) return +1;
47 - if (!*val && !*ref) return 0;
48 - if (!*val) return -1;
49 - if (!*ref) return +1;
50 - }
51 +/* assume ascii; warning: evaluates x multiple times! */
52 +#define order(x) ((x) == '~' ? -1 \
53 + : isdigit((x)) ? 0 \
54 + : !(x) ? 0 \
55 + : isalpha((x)) ? (x) \
56 + : (x) + 256)
58 +static int verrevcmp(const char *val, const char *ref) {
59 + if (!val) val= "";
60 + if (!ref) ref= "";
62 + while (*val || *ref) {
63 + int first_diff= 0;
65 + while ( (*val && !isdigit(*val)) || (*ref && !isdigit(*ref)) ) {
66 + int vc= order(*val), rc= order(*ref);
67 + if (vc != rc) return vc - rc;
68 + val++; ref++;
69 + }
71 + while ( *val == '0' ) val++;
72 + while ( *ref == '0' ) ref++;
73 + while (isdigit(*val) && isdigit(*ref)) {
74 + if (!first_diff) first_diff= *val - *ref;
75 + val++; ref++;
76 + }
77 + if (isdigit(*val)) return 1;
78 + if (isdigit(*ref)) return -1;
79 + if (first_diff) return first_diff;
80 + }
81 + return 0;
84 int pkg_version_satisfied(pkg_t *it, pkg_t *ref, const char *op)