15 #define _RPMEVR_INTERNAL 28 #define MAX(x, y) ( ((x)>(y))?(x):(y) ) 37 evr->F[RPMEVR_E] =
"0";
38 evr->F[RPMEVR_V] =
"";
39 evr->F[RPMEVR_T] =
"";
40 evr->F[RPMEVR_R] =
"";
41 evr->F[RPMEVR_D] =
"";
50 evr->str =
_free(evr->str);
51 memset(evr, 0,
sizeof(*evr));
59 #if defined(RPM_VENDOR_MANDRIVA) || defined(RPMVERCMP_DIGITS_BEAT_ALPHA) 62 static int _invert_digits_alphas_comparison = 1;
80 if (rc && _rpmnotalpha && *_rpmnotalpha)
81 rc = (strchr(_rpmnotalpha, c) == NULL);
90 const char * ae = NULL, * be = NULL;
96 for (; *a && *b && rc == 0; a = ae, b = be) {
104 if (a[0] ==
'*' && a[1] ==
'\0') {
105 be = strchr(b,
'\0');
107 if (b[0] ==
'*' && b[1] ==
'\0') {
108 ae = strchr(a,
'\0');
113 while (a[0] ==
'0' &&
xisdigit((
int)a[1])) a++;
114 while (b[0] ==
'0' &&
xisdigit((
int)b[1])) b++;
117 ae = a;
while (
xisdigit((
int)*ae)) ae++;
118 be = b;
while (
xisdigit((
int)*be)) be++;
121 if (a == ae || b == be)
124 rc = (ae - a) - (be - b);
126 rc = strncmp(a, b, (ae - a));
134 rc = strncmp(a, b,
MAX((ae - a), (be - b)));
151 "^(?:([^:-]+):)?([^:-]+)(?:-([^:-]+))?(?::([^:-]+))?$";
161 if (evr_tuple_mire == NULL) {
163 evr_tuple_match =
rpmExpand(
"%{?evr_tuple_match}", NULL);
164 if (evr_tuple_match == NULL || evr_tuple_match[0] ==
'\0')
165 evr_tuple_match =
xstrdup(_evr_tuple_match);
173 assert(evr_tuple_match != NULL && evr_tuple_mire != NULL);
183 int noffsets = 6 * 3;
189 memset(evr, 0,
sizeof(*evr));
191 nb = strlen(evr->str);
193 memset(offsets, -1,
sizeof(offsets));
196 xx =
mireRegexec(mire, evr->str, strlen(evr->str));
198 for (i = 0; i < noffsets; i += 2) {
206 case 0:
continue;
break;
207 case 1: ix = RPMEVR_E;
break;
208 case 2: ix = RPMEVR_V;
break;
209 case 3: ix = RPMEVR_T;
break;
210 case 4: ix = RPMEVR_R;
break;
211 case 5: ix = RPMEVR_D;
break;
214 assert(offsets[i ] >= 0 && offsets[i ] <= (
int)nb);
215 assert(offsets[i+1] >= 0 && offsets[i+1] <= (
int)nb);
216 {
char * te = (
char *) evr->str;
217 evr->F[ix] = te + offsets[i];
226 if (evr->F[RPMEVR_E] == NULL) evr->F[RPMEVR_E] =
"0";
227 if (evr->F[RPMEVR_V] == NULL) evr->F[RPMEVR_V] =
"";
228 if (evr->F[RPMEVR_T] == NULL) evr->F[RPMEVR_T] =
"";
229 if (evr->F[RPMEVR_R] == NULL) evr->F[RPMEVR_R] =
"";
230 if (evr->F[RPMEVR_D] == NULL) evr->F[RPMEVR_D] =
"";
233 evr->Elong = strtoul(evr->F[RPMEVR_E], NULL, 10);
264 if (evr_tuple_order == NULL) {
265 evr_tuple_order =
rpmExpand(
"%{?evr_tuple_order}", NULL);
266 if (evr_tuple_order == NULL || evr_tuple_order[0] ==
'\0')
267 evr_tuple_order =
xstrdup(
"EVR");
270 assert(evr_tuple_order != NULL && evr_tuple_order[0] !=
'\0');
279 assert(a->F[RPMEVR_E] != NULL);
280 assert(a->F[RPMEVR_V] != NULL);
281 assert(a->F[RPMEVR_T] != NULL);
282 assert(a->F[RPMEVR_R] != NULL);
283 assert(a->F[RPMEVR_D] != NULL);
284 assert(b->F[RPMEVR_E] != NULL);
285 assert(b->F[RPMEVR_V] != NULL);
286 assert(b->F[RPMEVR_T] != NULL);
287 assert(b->F[RPMEVR_R] != NULL);
288 assert(b->F[RPMEVR_D] != NULL);
294 default:
continue;
break;
295 case 'E': ix = RPMEVR_E;
break;
296 case 'V': ix = RPMEVR_V;
break;
297 case 'T': ix = RPMEVR_T;
break;
298 case 'R': ix = RPMEVR_R;
break;
299 case 'D': ix = RPMEVR_D;
break;
301 #if defined(RPM_VENDOR_MANDRIVA) 304 && *(b->F[ix]) ==
'\0')
310 && !strncmp(a->F[ix],
"set:",
sizeof(
"set:")-1)
311 && !strncmp(b->F[ix],
"set:",
sizeof(
"set:")-1))
313 rc = rpmsetCmp(a->F[ix], b->F[ix]);
342 if (a->F[RPMEVR_E] == NULL) a->F[RPMEVR_E] =
"0";
343 if (b->F[RPMEVR_E] == NULL) b->F[RPMEVR_E] =
"0";
344 if (a->F[RPMEVR_V] == NULL) a->F[RPMEVR_V] =
"";
345 if (b->F[RPMEVR_V] == NULL) b->F[RPMEVR_V] =
"";
346 if (a->F[RPMEVR_T] == NULL) a->F[RPMEVR_T] =
"";
347 if (b->F[RPMEVR_T] == NULL) b->F[RPMEVR_T] =
"";
348 if (a->F[RPMEVR_R] == NULL) a->F[RPMEVR_R] =
"";
349 if (b->F[RPMEVR_R] == NULL) b->F[RPMEVR_R] =
"";
350 if (a->F[RPMEVR_D] == NULL) a->F[RPMEVR_D] =
"";
351 if (b->F[RPMEVR_D] == NULL) b->F[RPMEVR_D] =
"";
357 result = (sense != 0);
360 else if (sense > 0 && ((aF & RPMSENSE_LESS) || (bF & RPMSENSE_GREATER)))
362 else if (sense == 0 &&
364 ((aF & RPMSENSE_LESS) && (bF & RPMSENSE_LESS)) ||
365 ((aF & RPMSENSE_GREATER) && (bF & RPMSENSE_GREATER))))
405 if (op == NULL || *op ==
'\0')
408 for (cop =
cops; cop->
opstr != NULL; cop++) {
409 if (strncmp(op, cop->
opstr, strlen(cop->
opstr)))
413 *end = op + strlen(cop->
opstr);
423 const char * one, * two;
431 default:
continue;
break;
441 else if (Eone > Etwo)
447 one = (xx && Ahe->
p.
str ? Ahe->
p.
str :
"");
450 two = (xx && Bhe->
p.
str ? Bhe->
p.
str :
"");
456 one = (xx && Ahe->
p.
str ? Ahe->
p.
str :
"");
459 two = (xx && Bhe->
p.
str ? Bhe->
p.
str :
"");
465 one = (xx && Ahe->
p.
str ? Ahe->
p.
str :
"");
468 two = (xx && Bhe->
p.
str ? Bhe->
p.
str :
"");
static int compare_values(const char *a, const char *b)
Dressed rpmEVRcmp, handling missing values.
static const char * _evr_tuple_match
int mireSetEOptions(miRE mire, int *offsets, int noffsets)
Initialize pattern execute options (PCRE only).
miRE mireNew(rpmMireMode mode, int tag)
Create pattern container.
const char * evr_tuple_match
static const char * _rpmnotalpha
int rpmEVRcmp(const char *a, const char *b)
Segmented string compare.
char * xstrdup(const char *str)
int mireRegcomp(miRE mire, const char *pattern)
Compile pattern match.
int mireSetCOptions(miRE mire, rpmMireMode mode, int tag, int options, const unsigned char *table)
Initialize pattern compile options.
static miRE rpmEVRmire(void)
int rpmEVRparse(const char *evrstr, EVR_t evr)
Split EVR string into epoch, version, and release components.
static int xisalpha(int c)
static void rpmlog(int code, const char *fmt,...)
int rpmEVRcompare(const EVR_t a, const EVR_t b)
Compare EVR containers for equality.
rpmsenseFlags rpmEVRflags(const char *op, const char **end)
Return comparison operator sense flags.
enum evrFlags_e evrFlags
Dependency Attributes.
#define RPMSENSE_NOTEQUAL
Yet Another syslog(3) API clone.
static int xisrpmalpha(int c)
Return rpm's analogue of xisalpha.
void * xcalloc(size_t nmemb, size_t size)
enum evrFlags_e rpmsenseFlags
int mireRegexec(miRE mire, const char *val, size_t vallen)
Execute pattern match.
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
static struct EVRop_s cops[]
EVR_t rpmEVRnew(uint32_t Flags, int initialize)
Create a new EVR container.
EVR_t rpmEVRfree(EVR_t evr)
Destroy an EVR container.
static int xisdigit(int c)
int rpmEVRoverlap(EVR_t a, EVR_t b)
Compare EVR containers for overlap.
static int _invert_digits_alphas_comparison
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
int(* rpmvercmp)(const char *a, const char *b)
Segmented string compare vector.
static const char * rpmEVRorder(void)
Return precedence permutation string.
static const char * evr_tuple_order
int rpmVersionCompare(Header A, Header B)
static int xispunct(int c)