2006-12-19 00:17:44 +01:00
|
|
|
This patch supports an extension in the condition evaluation.
|
|
|
|
If the condition is a format and returns an nonempty string, it is
|
|
|
|
assumed to be true.
|
|
|
|
This mechanism is used by the weakdeps patch to filter the
|
|
|
|
"RPMSENSE_STRONG" flag.
|
|
|
|
|
2008-09-12 20:37:28 +02:00
|
|
|
Index: rpmdb/header.c
|
|
|
|
===================================================================
|
|
|
|
--- rpmdb/header.c.orig
|
|
|
|
+++ rpmdb/header.c
|
|
|
|
@@ -2984,8 +2984,12 @@ static int parseExpression(headerSprintf
|
2006-12-19 00:17:44 +01:00
|
|
|
|
|
|
|
*endPtr = chptr;
|
|
|
|
|
|
|
|
+ token->u.cond.tag.type = NULL;
|
|
|
|
+ token->u.cond.tag.format = "";
|
|
|
|
token->type = PTOK_COND;
|
|
|
|
|
|
|
|
+ if ((token->u.cond.tag.type = strchr(str, ':')) != 0)
|
|
|
|
+ *token->u.cond.tag.type++ = 0;
|
|
|
|
(void) findTag(hsa, token, str);
|
|
|
|
|
|
|
|
return 0;
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -3226,6 +3230,7 @@ static char * singleSprintf(headerSprint
|
2006-12-19 00:17:44 +01:00
|
|
|
int_32 type;
|
|
|
|
int_32 count;
|
2006-12-19 00:17:44 +01:00
|
|
|
sprintfToken spft;
|
|
|
|
+ sprintfTag stag;
|
|
|
|
int condNumFormats;
|
|
|
|
size_t need;
|
|
|
|
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -3257,6 +3262,18 @@ static char * singleSprintf(headerSprint
|
2006-12-19 00:17:44 +01:00
|
|
|
if (token->u.cond.tag.ext || headerIsEntry(hsa->h, token->u.cond.tag.tag)) {
|
2006-12-19 00:17:44 +01:00
|
|
|
spft = token->u.cond.ifFormat;
|
|
|
|
condNumFormats = token->u.cond.numIfTokens;
|
|
|
|
+ if (token->u.cond.tag.fmt) {
|
|
|
|
+ /* check if format creates output */
|
|
|
|
+ size_t vallen = hsa->vallen;
|
|
|
|
+ formatValue(hsa, &token->u.cond.tag, element);
|
|
|
|
+ if (hsa->vallen == vallen) {
|
|
|
|
+ spft = token->u.cond.elseFormat;
|
|
|
|
+ condNumFormats = token->u.cond.numElseTokens;
|
|
|
|
+ } else {
|
|
|
|
+ hsa->vallen = vallen;
|
|
|
|
+ hsa->val[hsa->vallen] = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
} else {
|
|
|
|
spft = token->u.cond.elseFormat;
|
|
|
|
condNumFormats = token->u.cond.numElseTokens;
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -3278,19 +3295,22 @@ static char * singleSprintf(headerSprint
|
2006-12-19 00:17:44 +01:00
|
|
|
spft = token->u.array.format;
|
2006-12-19 00:17:44 +01:00
|
|
|
for (i = 0; i < token->u.array.numTokens; i++, spft++)
|
|
|
|
{
|
|
|
|
- if (spft->type != PTOK_TAG ||
|
2006-12-19 00:17:44 +01:00
|
|
|
- spft->u.tag.arrayCount ||
|
2006-12-19 00:17:44 +01:00
|
|
|
- spft->u.tag.justOne) continue;
|
|
|
|
+ if (spft->type != PTOK_TAG && spft->type != PTOK_COND)
|
|
|
|
+ continue;
|
2006-12-19 00:17:44 +01:00
|
|
|
+
|
2006-12-19 00:17:44 +01:00
|
|
|
+ stag = (spft->type == PTOK_COND ? &spft->u.cond.tag : &spft->u.tag);
|
2006-12-19 00:17:44 +01:00
|
|
|
+ if (stag->arrayCount || stag->justOne)
|
2006-12-19 00:17:44 +01:00
|
|
|
+ continue;
|
|
|
|
|
2006-12-19 00:17:44 +01:00
|
|
|
- if (spft->u.tag.ext) {
|
|
|
|
+ if (stag->ext) {
|
|
|
|
/*@-boundswrite@*/
|
|
|
|
- if (getExtension(hsa, spft->u.tag.ext, &type, NULL, &count,
|
|
|
|
- hsa->ec + spft->u.tag.extNum))
|
2008-09-12 20:37:28 +02:00
|
|
|
+ if (getExtension(hsa, stag->ext, &type, NULL, &count,
|
2006-12-19 00:17:44 +01:00
|
|
|
+ hsa->ec + stag->extNum))
|
|
|
|
continue;
|
|
|
|
/*@=boundswrite@*/
|
|
|
|
} else {
|
|
|
|
/*@-boundswrite@*/
|
|
|
|
- if (!headerGetEntry(hsa->h, spft->u.tag.tag, &type, NULL, &count))
|
|
|
|
+ if (!headerGetEntry(hsa->h, stag->tag, &type, NULL, &count))
|
|
|
|
continue;
|
|
|
|
/*@=boundswrite@*/
|
|
|
|
}
|