rpm
4.5
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
lib
rpmdpkg.c
Go to the documentation of this file.
1
4
#include "
system.h
"
5
6
#include <
rpmio.h
>
7
8
#define _RPMEVR_INTERNAL
9
#include <
rpmdpkg.h
>
10
11
#include "
debug.h
"
12
13
/*@access EVR_t @*/
14
15
/*@unchecked@*/
16
int
_rpmdpkg_debug
= 0;
17
18
/* assume ascii */
19
static
inline
int
dpkgEVRctype
(
char
x)
20
/*@*/
21
{
22
return
(
23
x ==
'~'
? -1
24
:
xisdigit
(x) ? 0
25
: !x ? 0 \
26
:
xisalpha
(x) ? x
27
: x + 256
28
);
29
}
30
31
int
dpkgEVRcmp
(
const
char
*a,
const
char
*b)
32
{
33
if
(!a) a =
""
;
34
if
(!b) b =
""
;
35
36
while
(*a || *b) {
37
int
first_diff= 0;
38
39
while
( (*a && !
xisdigit
(*a)) || (*b && !
xisdigit
(*b)) ) {
40
int
vc =
dpkgEVRctype
(*a);
41
int
rc =
dpkgEVRctype
(*b);
42
if
(vc != rc)
return
vc - rc;
43
a++; b++;
44
}
45
46
while
(*a ==
'0'
) a++;
47
while
(*b ==
'0'
) b++;
48
while
(
xisdigit
(*a) &&
xisdigit
(*b)) {
49
if
(!first_diff) first_diff = *a - *b;
50
a++; b++;
51
}
52
if
(
xisdigit
(*a))
return
1;
53
if
(
xisdigit
(*b))
return
-1;
54
if
(first_diff)
return
first_diff;
55
}
56
return
0;
57
}
58
59
int
dpkgEVRparse
(
const
char
* evrstr,
EVR_t
evr)
60
{
61
return
rpmEVRparse
(evrstr, evr);
62
}
63
64
int
dpkgEVRcompare
(
const
EVR_t
a,
const
EVR_t
b)
65
{
66
int
r;
67
68
if
(a->Elong > b->Elong)
return
1;
69
if
(a->Elong < b->Elong)
return
-1;
70
r =
dpkgEVRcmp
(a->V, b->V);
if
(r)
return
r;
71
return
dpkgEVRcmp
(a->R, b->R);
72
}
Generated on Mon Oct 27 2014 16:03:31 for rpm by
1.8.3.1