lib/rpmver: replace tabs with spaces
This commit is contained in:
parent
a716dc290e
commit
4543e09b2b
@ -25,40 +25,40 @@ struct rpmver_s {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Split EVR into epoch, version, and release components.
|
* Split EVR into epoch, version, and release components.
|
||||||
* @param evr [epoch:]version[-release] string
|
* @param evr [epoch:]version[-release] string
|
||||||
* @retval *ep pointer to epoch
|
* @retval *ep pointer to epoch
|
||||||
* @retval *vp pointer to version
|
* @retval *vp pointer to version
|
||||||
* @retval *rp pointer to release
|
* @retval *rp pointer to release
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
void parseEVR(char * evr,
|
void parseEVR(char * evr,
|
||||||
const char ** ep,
|
const char ** ep,
|
||||||
const char ** vp,
|
const char ** vp,
|
||||||
const char ** rp)
|
const char ** rp)
|
||||||
{
|
{
|
||||||
const char *epoch;
|
const char *epoch;
|
||||||
const char *version; /* assume only version is present */
|
const char *version; /* assume only version is present */
|
||||||
const char *release;
|
const char *release;
|
||||||
char *s, *se;
|
char *s, *se;
|
||||||
|
|
||||||
s = evr;
|
s = evr;
|
||||||
while (*s && risdigit(*s)) s++; /* s points to epoch terminator */
|
while (*s && risdigit(*s)) s++; /* s points to epoch terminator */
|
||||||
se = strrchr(s, '-'); /* se points to version terminator */
|
se = strrchr(s, '-'); /* se points to version terminator */
|
||||||
|
|
||||||
if (*s == ':') {
|
if (*s == ':') {
|
||||||
epoch = evr;
|
epoch = evr;
|
||||||
*s++ = '\0';
|
*s++ = '\0';
|
||||||
version = s;
|
version = s;
|
||||||
if (*epoch == '\0') epoch = "0";
|
if (*epoch == '\0') epoch = "0";
|
||||||
} else {
|
} else {
|
||||||
epoch = NULL; /* XXX disable epoch compare if missing */
|
epoch = NULL; /* XXX disable epoch compare if missing */
|
||||||
version = evr;
|
version = evr;
|
||||||
}
|
}
|
||||||
if (se) {
|
if (se) {
|
||||||
*se++ = '\0';
|
*se++ = '\0';
|
||||||
release = se;
|
release = se;
|
||||||
} else {
|
} else {
|
||||||
release = NULL;
|
release = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ep) *ep = epoch;
|
if (ep) *ep = epoch;
|
||||||
@ -73,38 +73,38 @@ int rpmverOverlap(rpmver v1, rpmsenseFlags f1, rpmver v2, rpmsenseFlags f2)
|
|||||||
|
|
||||||
/* Compare {A,B} [epoch:]version[-release] */
|
/* Compare {A,B} [epoch:]version[-release] */
|
||||||
if (v1->e && *v1->e && v2->e && *v2->e)
|
if (v1->e && *v1->e && v2->e && *v2->e)
|
||||||
sense = rpmvercmp(v1->e, v2->e);
|
sense = rpmvercmp(v1->e, v2->e);
|
||||||
else if (v1->e && *v1->e && atol(v1->e) > 0) {
|
else if (v1->e && *v1->e && atol(v1->e) > 0) {
|
||||||
sense = 1;
|
sense = 1;
|
||||||
} else if (v2->e && *v2->e && atol(v2->e) > 0)
|
} else if (v2->e && *v2->e && atol(v2->e) > 0)
|
||||||
sense = -1;
|
sense = -1;
|
||||||
|
|
||||||
if (sense == 0) {
|
if (sense == 0) {
|
||||||
sense = rpmvercmp(v1->v, v2->v);
|
sense = rpmvercmp(v1->v, v2->v);
|
||||||
if (sense == 0) {
|
if (sense == 0) {
|
||||||
if (v1->r && *v1->r && v2->r && *v2->r) {
|
if (v1->r && *v1->r && v2->r && *v2->r) {
|
||||||
sense = rpmvercmp(v1->r, v2->r);
|
sense = rpmvercmp(v1->r, v2->r);
|
||||||
} else {
|
} else {
|
||||||
/* always matches if the side with no release has SENSE_EQUAL */
|
/* always matches if the side with no release has SENSE_EQUAL */
|
||||||
if ((v1->r && *v1->r && (f2 & RPMSENSE_EQUAL)) ||
|
if ((v1->r && *v1->r && (f2 & RPMSENSE_EQUAL)) ||
|
||||||
(v2->r && *v2->r && (f1 & RPMSENSE_EQUAL))) {
|
(v2->r && *v2->r && (f1 & RPMSENSE_EQUAL))) {
|
||||||
result = 1;
|
result = 1;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Detect overlap of {A,B} range. */
|
/* Detect overlap of {A,B} range. */
|
||||||
if (sense < 0 && ((f1 & RPMSENSE_GREATER) || (f2 & RPMSENSE_LESS))) {
|
if (sense < 0 && ((f1 & RPMSENSE_GREATER) || (f2 & RPMSENSE_LESS))) {
|
||||||
result = 1;
|
result = 1;
|
||||||
} else if (sense > 0 && ((f1 & RPMSENSE_LESS) || (f2 & RPMSENSE_GREATER))) {
|
} else if (sense > 0 && ((f1 & RPMSENSE_LESS) || (f2 & RPMSENSE_GREATER))) {
|
||||||
result = 1;
|
result = 1;
|
||||||
} else if (sense == 0 &&
|
} else if (sense == 0 &&
|
||||||
(((f1 & RPMSENSE_EQUAL) && (f2 & RPMSENSE_EQUAL)) ||
|
(((f1 & RPMSENSE_EQUAL) && (f2 & RPMSENSE_EQUAL)) ||
|
||||||
((f1 & RPMSENSE_LESS) && (f2 & RPMSENSE_LESS)) ||
|
((f1 & RPMSENSE_LESS) && (f2 & RPMSENSE_LESS)) ||
|
||||||
((f1 & RPMSENSE_GREATER) && (f2 & RPMSENSE_GREATER)))) {
|
((f1 & RPMSENSE_GREATER) && (f2 & RPMSENSE_GREATER)))) {
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
@ -114,11 +114,11 @@ exit:
|
|||||||
static int compare_values(const char *str1, const char *str2)
|
static int compare_values(const char *str1, const char *str2)
|
||||||
{
|
{
|
||||||
if (!str1 && !str2)
|
if (!str1 && !str2)
|
||||||
return 0;
|
return 0;
|
||||||
else if (str1 && !str2)
|
else if (str1 && !str2)
|
||||||
return 1;
|
return 1;
|
||||||
else if (!str1 && str2)
|
else if (!str1 && str2)
|
||||||
return -1;
|
return -1;
|
||||||
return rpmvercmp(str1, str2);
|
return rpmvercmp(str1, str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,9 +129,9 @@ int rpmverCmp(rpmver v1, rpmver v2)
|
|||||||
|
|
||||||
int rc = compare_values(e1, e2);
|
int rc = compare_values(e1, e2);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
rc = compare_values(v1->v, v2->v);
|
rc = compare_values(v1->v, v2->v);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
rc = compare_values(v1->r, v2->r);
|
rc = compare_values(v1->r, v2->r);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -160,9 +160,9 @@ char *rpmverEVR(rpmver rv)
|
|||||||
{
|
{
|
||||||
char *EVR = NULL;
|
char *EVR = NULL;
|
||||||
if (rv) {
|
if (rv) {
|
||||||
rstrscat(&EVR, rv->e ? rv-> e : "", rv->e ? ":" : "",
|
rstrscat(&EVR, rv->e ? rv-> e : "", rv->e ? ":" : "",
|
||||||
rv->v,
|
rv->v,
|
||||||
rv->r ? "-" : "", rv->r ? rv->r : "", NULL);
|
rv->r ? "-" : "", rv->r ? rv->r : "", NULL);
|
||||||
}
|
}
|
||||||
return EVR;
|
return EVR;
|
||||||
}
|
}
|
||||||
@ -171,10 +171,10 @@ rpmver rpmverParse(const char *evr)
|
|||||||
{
|
{
|
||||||
rpmver rv = NULL;
|
rpmver rv = NULL;
|
||||||
if (evr && *evr) {
|
if (evr && *evr) {
|
||||||
size_t evrlen = strlen(evr) + 1;
|
size_t evrlen = strlen(evr) + 1;
|
||||||
rv = xmalloc(sizeof(*rv) + evrlen);
|
rv = xmalloc(sizeof(*rv) + evrlen);
|
||||||
memcpy(rv->arena, evr, evrlen);
|
memcpy(rv->arena, evr, evrlen);
|
||||||
parseEVR(rv->arena, &rv->e, &rv->v, &rv->r);
|
parseEVR(rv->arena, &rv->e, &rv->v, &rv->r);
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -184,31 +184,31 @@ rpmver rpmverNew(const char *e, const char *v, const char *r)
|
|||||||
rpmver rv = NULL;
|
rpmver rv = NULL;
|
||||||
|
|
||||||
if (v && *v) {
|
if (v && *v) {
|
||||||
size_t nb = strlen(v) + 1;
|
size_t nb = strlen(v) + 1;
|
||||||
nb += (e != NULL) ? strlen(e) + 1 : 0;
|
nb += (e != NULL) ? strlen(e) + 1 : 0;
|
||||||
nb += (r != NULL) ? strlen(r) + 1 : 0;
|
nb += (r != NULL) ? strlen(r) + 1 : 0;
|
||||||
rv = xmalloc(sizeof(*rv) + nb);
|
rv = xmalloc(sizeof(*rv) + nb);
|
||||||
|
|
||||||
rv->e = NULL;
|
rv->e = NULL;
|
||||||
rv->v = NULL;
|
rv->v = NULL;
|
||||||
rv->r = NULL;
|
rv->r = NULL;
|
||||||
|
|
||||||
char *p = rv->arena;
|
char *p = rv->arena;
|
||||||
if (e) {
|
if (e) {
|
||||||
rv->e = p;
|
rv->e = p;
|
||||||
p = stpcpy(p, e);
|
p = stpcpy(p, e);
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv->v = p;
|
rv->v = p;
|
||||||
p = stpcpy(p, v);
|
p = stpcpy(p, v);
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
if (r) {
|
if (r) {
|
||||||
rv->r = p;
|
rv->r = p;
|
||||||
p = stpcpy(p, r);
|
p = stpcpy(p, r);
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ rpmver rpmverNew(const char *e, const char *v, const char *r)
|
|||||||
rpmver rpmverFree(rpmver rv)
|
rpmver rpmverFree(rpmver rv)
|
||||||
{
|
{
|
||||||
if (rv) {
|
if (rv) {
|
||||||
free(rv);
|
free(rv);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define _RPMVER_H
|
#define _RPMVER_H
|
||||||
|
|
||||||
#include <rpm/rpmtypes.h>
|
#include <rpm/rpmtypes.h>
|
||||||
#include <rpm/rpmds.h> /* sense flags */
|
#include <rpm/rpmds.h> /* sense flags */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -20,84 +20,84 @@ typedef struct rpmver_s * rpmver;
|
|||||||
/** \ingroup rpmver
|
/** \ingroup rpmver
|
||||||
* Segmented string compare for version or release strings.
|
* Segmented string compare for version or release strings.
|
||||||
*
|
*
|
||||||
* @param a 1st string
|
* @param a 1st string
|
||||||
* @param b 2nd string
|
* @param b 2nd string
|
||||||
* @return +1 if a is "newer", 0 if equal, -1 if b is "newer"
|
* @return +1 if a is "newer", 0 if equal, -1 if b is "newer"
|
||||||
*/
|
*/
|
||||||
int rpmvercmp(const char * a, const char * b);
|
int rpmvercmp(const char * a, const char * b);
|
||||||
|
|
||||||
/** \ingroup rpmver
|
/** \ingroup rpmver
|
||||||
* Parse rpm version handle from evr string
|
* Parse rpm version handle from evr string
|
||||||
*
|
*
|
||||||
* @param evr [epoch:]version[-release] string
|
* @param evr [epoch:]version[-release] string
|
||||||
* @return rpm version, NULL on invalid evr
|
* @return rpm version, NULL on invalid evr
|
||||||
*/
|
*/
|
||||||
rpmver rpmverParse(const char *evr);
|
rpmver rpmverParse(const char *evr);
|
||||||
|
|
||||||
/** \ingroup rpmver
|
/** \ingroup rpmver
|
||||||
* Create new rpm version handle from e, v, r components
|
* Create new rpm version handle from e, v, r components
|
||||||
*
|
*
|
||||||
* @param e epoch (or NULL)
|
* @param e epoch (or NULL)
|
||||||
* @param v version
|
* @param v version
|
||||||
* @param r release (or NULL)
|
* @param r release (or NULL)
|
||||||
* @return rpm version, NULL on invalid
|
* @return rpm version, NULL on invalid
|
||||||
*/
|
*/
|
||||||
rpmver rpmverNew(const char *e, const char *v, const char *r);
|
rpmver rpmverNew(const char *e, const char *v, const char *r);
|
||||||
|
|
||||||
/** \ingroup rpmver
|
/** \ingroup rpmver
|
||||||
* Free rpm version handle
|
* Free rpm version handle
|
||||||
*
|
*
|
||||||
* @param rv rpm version handle
|
* @param rv rpm version handle
|
||||||
* @return NULL always
|
* @return NULL always
|
||||||
*/
|
*/
|
||||||
rpmver rpmverFree(rpmver rv);
|
rpmver rpmverFree(rpmver rv);
|
||||||
|
|
||||||
/** \ingroup rpmver
|
/** \ingroup rpmver
|
||||||
* @param rv rpm version handle
|
* @param rv rpm version handle
|
||||||
* @return numerical value of epoch
|
* @return numerical value of epoch
|
||||||
*/
|
*/
|
||||||
uint32_t rpmverEVal(rpmver rv);
|
uint32_t rpmverEVal(rpmver rv);
|
||||||
|
|
||||||
/** \ingroup rpmver
|
/** \ingroup rpmver
|
||||||
* @param rv rpm version handle
|
* @param rv rpm version handle
|
||||||
* @return epoch portion
|
* @return epoch portion
|
||||||
*/
|
*/
|
||||||
const char *rpmverE(rpmver rv);
|
const char *rpmverE(rpmver rv);
|
||||||
|
|
||||||
/** \ingroup rpmver
|
/** \ingroup rpmver
|
||||||
* @param rv rpm version handle
|
* @param rv rpm version handle
|
||||||
* @return version portion
|
* @return version portion
|
||||||
*/
|
*/
|
||||||
const char *rpmverV(rpmver rv);
|
const char *rpmverV(rpmver rv);
|
||||||
|
|
||||||
/** \ingroup rpmver
|
/** \ingroup rpmver
|
||||||
* @param rv rpm version handle
|
* @param rv rpm version handle
|
||||||
* @return release portion
|
* @return release portion
|
||||||
*/
|
*/
|
||||||
const char *rpmverR(rpmver rv);
|
const char *rpmverR(rpmver rv);
|
||||||
|
|
||||||
/** \ingroup rpmver
|
/** \ingroup rpmver
|
||||||
* @param rv rpm version handle
|
* @param rv rpm version handle
|
||||||
* @return formatted [E:]V[-R] string (malloced)
|
* @return formatted [E:]V[-R] string (malloced)
|
||||||
*/
|
*/
|
||||||
char *rpmverEVR(rpmver rv);
|
char *rpmverEVR(rpmver rv);
|
||||||
|
|
||||||
/** \ingroup rpmver
|
/** \ingroup rpmver
|
||||||
* Compare two rpm version handles
|
* Compare two rpm version handles
|
||||||
*
|
*
|
||||||
* @param v1 1st version handle
|
* @param v1 1st version handle
|
||||||
* @param v2 2nd version handle
|
* @param v2 2nd version handle
|
||||||
* @return 0 if equal, -1 if v1 smaller, 1 if greater, than v2
|
* @return 0 if equal, -1 if v1 smaller, 1 if greater, than v2
|
||||||
*/
|
*/
|
||||||
int rpmverCmp(rpmver v1, rpmver v2);
|
int rpmverCmp(rpmver v1, rpmver v2);
|
||||||
|
|
||||||
/** \ingroup rpmver
|
/** \ingroup rpmver
|
||||||
* Determine whether two versioned ranges overlap.
|
* Determine whether two versioned ranges overlap.
|
||||||
* @param v1 1st version
|
* @param v1 1st version
|
||||||
* @param f1 1st sense flags
|
* @param f1 1st sense flags
|
||||||
* @param v2 2nd version
|
* @param v2 2nd version
|
||||||
* @param f2 2nd sense flags
|
* @param f2 2nd sense flags
|
||||||
* @return 1 if ranges overlap, 0 otherwise
|
* @return 1 if ranges overlap, 0 otherwise
|
||||||
*/
|
*/
|
||||||
int rpmverOverlap(rpmver v1, rpmsenseFlags f1, rpmver v2, rpmsenseFlags f2);
|
int rpmverOverlap(rpmver v1, rpmsenseFlags f1, rpmver v2, rpmsenseFlags f2);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user