Introduce parseEVRD()
It's similar to parseEVR() but also returns disttag.
This commit is contained in:
parent
fa25b864cd
commit
9618b8946f
@ -1488,7 +1488,9 @@ rpmEVRcmp(const char * const aE, const char * const aV, const char * const aR,
|
|||||||
* @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
|
||||||
|
* @retval *dp pointer to disttag
|
||||||
*/
|
*/
|
||||||
|
void parseEVRD(char * evr, const char ** ep, const char ** vp, const char ** rp, const char ** dp);
|
||||||
void parseEVR(char * evr,
|
void parseEVR(char * evr,
|
||||||
/*@exposed@*/ /*@out@*/ const char ** ep,
|
/*@exposed@*/ /*@out@*/ const char ** ep,
|
||||||
/*@exposed@*/ /*@out@*/ const char ** vp,
|
/*@exposed@*/ /*@out@*/ const char ** vp,
|
||||||
|
@ -110,46 +110,60 @@ int rpmvercmp(const char * a, const char * b)
|
|||||||
|
|
||||||
/* Moved from depends.c, because we use it in other places, too. */
|
/* Moved from depends.c, because we use it in other places, too. */
|
||||||
/**
|
/**
|
||||||
* Split EVR into epoch, version, and release components.
|
* Split EVRD into epoch, version, release and disttag components.
|
||||||
* @param evr [epoch:]version[-release] string
|
* @param evrd [epoch:]version[-release[:disttag]] 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
|
||||||
|
* @retval *dp pointer to disttag
|
||||||
*/
|
*/
|
||||||
void parseEVR(char * evr,
|
void parseEVRD(char * evrd,
|
||||||
/*@exposed@*/ /*@out@*/ const char ** ep,
|
const char ** ep,
|
||||||
/*@exposed@*/ /*@out@*/ const char ** vp,
|
const char ** vp,
|
||||||
/*@exposed@*/ /*@out@*/ const char ** rp)
|
const char ** rp,
|
||||||
/*@modifies *ep, *vp, *rp @*/
|
const char ** dp)
|
||||||
{
|
{
|
||||||
const char *epoch;
|
const char *epoch = NULL;
|
||||||
const char *version; /* assume only version is present */
|
const char *version = NULL; /* assume only version is present */
|
||||||
const char *release;
|
const char *release = NULL;
|
||||||
|
const char *disttag = NULL;
|
||||||
char *s, *se;
|
char *s, *se;
|
||||||
|
|
||||||
s = evr;
|
s = evrd;
|
||||||
while (*s && xisdigit(*s)) s++; /* s points to epoch terminator */
|
while (*s && xisdigit(*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 = evrd;
|
||||||
*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 */
|
version = evrd;
|
||||||
version = evr;
|
|
||||||
}
|
}
|
||||||
if (se) {
|
if (se) {
|
||||||
*se++ = '\0';
|
*se++ = '\0';
|
||||||
release = se;
|
release = se;
|
||||||
} else {
|
se = strchr(se, ':');
|
||||||
release = NULL;
|
if (se) {
|
||||||
|
*se++ = '\0';
|
||||||
|
disttag = se;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ep) *ep = epoch;
|
if (ep) *ep = epoch;
|
||||||
if (vp) *vp = version;
|
if (vp) *vp = version;
|
||||||
if (rp) *rp = release;
|
if (rp) *rp = release;
|
||||||
|
if (dp) *dp = disttag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* compat function */
|
||||||
|
void parseEVR(char *evr,
|
||||||
|
const char ** ep,
|
||||||
|
const char ** vp,
|
||||||
|
const char ** rp)
|
||||||
|
{
|
||||||
|
parseEVRD(evr, ep, vp, rp, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compare {A,B} [epoch:]version[-release] */
|
/* Compare {A,B} [epoch:]version[-release] */
|
||||||
|
Loading…
Reference in New Issue
Block a user