-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetcmploop.c
57 lines (56 loc) · 930 Bytes
/
setcmploop.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "rpmsetcmp-common.h"
int setcmploop(const uint32_t *Pv, size_t Pn,
const uint32_t *Rv, size_t Rn)
{
int le = 1, ge = 1;
const uint32_t *Pend = Pv + Pn;
const uint32_t *Rend = Rv + Rn;
uint32_t Rval = *Rv;
while (1) {
if (*Pv < Rval) {
le = 0;
do {
if (Pv[2] >= Rval) goto found2;
if (Pv[4] >= Rval) goto found4;
Pv += 6;
} while (*Pv < Rval);
Pv -= 1;
goto found;
found2:
Pv += 1;
goto found;
found4:
Pv += 3;
found:
Pv = (*Pv < Rval) ? Pv + 1 : Pv;
if (Pv == Pend)
break;
}
if (*Pv == Rval) {
Pv++, Rv++;
if (Pv == Pend)
break;
if (Rv == Rend)
break;
Rval = *Rv;
}
else {
ge = 0;
Rv++;
if (Rv == Rend)
break;
Rval = *Rv;
}
}
if (Pv < Pend)
le = 0;
if (Rv < Rend)
ge = 0;
if (le && ge)
return 0;
if (ge)
return 1;
if (le)
return -1;
return -2;
}