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++;
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 =
_free(evr_tuple_match);
166 evr_tuple_match =
xstrdup(_evr_tuple_match);
175 assert(evr_tuple_match != NULL && evr_tuple_mire != NULL);
185 int noffsets = 6 * 3;
191 memset(evr, 0,
sizeof(*evr));
193 nb = strlen(evr->str);
195 memset(offsets, -1,
sizeof(offsets));
198 xx =
mireRegexec(mire, evr->str, strlen(evr->str));
200 for (i = 0; i < noffsets; i += 2) {
208 case 0:
continue;
break;
209 case 1: ix = RPMEVR_E;
break;
210 case 2: ix = RPMEVR_V;
break;
211 case 3: ix = RPMEVR_T;
break;
212 case 4: ix = RPMEVR_R;
break;
213 case 5: ix = RPMEVR_D;
break;
216 assert(offsets[i ] >= 0 && offsets[i ] <= (
int)nb);
217 assert(offsets[i+1] >= 0 && offsets[i+1] <= (
int)nb);
218 {
char * te = (
char *) evr->str;
219 evr->F[ix] = te + offsets[i];
228 if (evr->F[RPMEVR_E] == NULL) evr->F[RPMEVR_E] =
"0";
229 if (evr->F[RPMEVR_V] == NULL) evr->F[RPMEVR_V] =
"";
230 if (evr->F[RPMEVR_T] == NULL) evr->F[RPMEVR_T] =
"";
231 if (evr->F[RPMEVR_R] == NULL) evr->F[RPMEVR_R] =
"";
232 if (evr->F[RPMEVR_D] == NULL) evr->F[RPMEVR_D] =
"";
235 evr->Elong = strtoul(evr->F[RPMEVR_E], NULL, 10);
268 if (evr_tuple_order == NULL) {
269 evr_tuple_order =
rpmExpand(
"%{?evr_tuple_order}", NULL);
270 if (evr_tuple_order == NULL || evr_tuple_order[0] ==
'\0') {
271 evr_tuple_order =
_free(evr_tuple_order);
272 evr_tuple_order =
xstrdup(_evr_tuple_order);
276 assert(evr_tuple_order != NULL && evr_tuple_order[0] !=
'\0');
285 assert(a->F[RPMEVR_E] != NULL);
286 assert(a->F[RPMEVR_V] != NULL);
287 assert(a->F[RPMEVR_T] != NULL);
288 assert(a->F[RPMEVR_R] != NULL);
289 assert(a->F[RPMEVR_D] != NULL);
290 assert(b->F[RPMEVR_E] != NULL);
291 assert(b->F[RPMEVR_V] != NULL);
292 assert(b->F[RPMEVR_T] != NULL);
293 assert(b->F[RPMEVR_R] != NULL);
294 assert(b->F[RPMEVR_D] != NULL);
300 default:
continue;
break;
301 case 'E': ix = RPMEVR_E;
break;
302 case 'V': ix = RPMEVR_V;
break;
303 case 'T': ix = RPMEVR_T;
break;
304 case 'R': ix = RPMEVR_R;
break;
305 case 'D': ix = RPMEVR_D;
break;
307 #if defined(RPM_VENDOR_MANDRIVA)
310 && *(b->F[ix]) ==
'\0')
316 && !strncmp(a->F[ix],
"set:",
sizeof(
"set:")-1)
317 && !strncmp(b->F[ix],
"set:",
sizeof(
"set:")-1))
348 if (a->F[RPMEVR_E] == NULL) a->F[RPMEVR_E] =
"0";
349 if (b->F[RPMEVR_E] == NULL) b->F[RPMEVR_E] =
"0";
350 if (a->F[RPMEVR_V] == NULL) a->F[RPMEVR_V] =
"";
351 if (b->F[RPMEVR_V] == NULL) b->F[RPMEVR_V] =
"";
352 if (a->F[RPMEVR_T] == NULL) a->F[RPMEVR_T] =
"";
353 if (b->F[RPMEVR_T] == NULL) b->F[RPMEVR_T] =
"";
354 if (a->F[RPMEVR_R] == NULL) a->F[RPMEVR_R] =
"";
355 if (b->F[RPMEVR_R] == NULL) b->F[RPMEVR_R] =
"";
356 if (a->F[RPMEVR_D] == NULL) a->F[RPMEVR_D] =
"";
357 if (b->F[RPMEVR_D] == NULL) b->F[RPMEVR_D] =
"";
363 result = (sense != 0);
366 else if (sense > 0 && ((aF & RPMSENSE_LESS) || (bF & RPMSENSE_GREATER)))
368 else if (sense == 0 &&
370 ((aF & RPMSENSE_LESS) && (bF & RPMSENSE_LESS)) ||
371 ((aF & RPMSENSE_GREATER) && (bF & RPMSENSE_GREATER))))
411 if (op == NULL || *op ==
'\0')
414 for (cop =
cops; cop->
opstr != NULL; cop++) {
415 if (strncmp(op, cop->
opstr, strlen(cop->
opstr)))
419 *end = op + strlen(cop->
opstr);
429 const char *
one, * two;
437 default:
continue;
break;
447 else if (Eone > Etwo)
453 one = (xx && Ahe->
p.
str ? Ahe->
p.
str :
"");
456 two = (xx && Bhe->
p.
str ? Bhe->
p.
str :
"");
462 one = (xx && Ahe->
p.
str ? Ahe->
p.
str :
"");
465 two = (xx && Bhe->
p.
str ? Bhe->
p.
str :
"");
471 one = (xx && Ahe->
p.
str ? Ahe->
p.
str :
"");
474 two = (xx && Bhe->
p.
str ? Bhe->
p.
str :
"");
static int compare_values(const char *a, const char *b)
Dressed rpmEVRcmp, handling missing values.
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(* rpmvercmp)(const char *a, const char *b)
Segmented string compare vector.
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 rpmsetCmp(const char *str1, const char *str2)
static const char _evr_tuple_order[]
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.
const char const bson const bson * op
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.
Structure(s) and routine(s) used for EVR parsing and comparison.
static const char _evr_tuple_match[]
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)