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 :
"");