summaryrefslogtreecommitdiff
path: root/lib/headerfmt.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2017-08-30 15:28:23 +0300
committerPanu Matilainen <pmatilai@redhat.com>2017-08-30 15:35:01 +0300
commit7eb620f595486309670797a2436559598ff1f8f0 (patch)
tree95d5810c36f417ca5f522daec88378a8595d3050 /lib/headerfmt.c
parent9c979cffe937fd76f70ca111c76eaa797585dddc (diff)
downloadrpm-7eb620f595486309670797a2436559598ff1f8f0.tar.gz
Restore 4.13 behavior with single value tags in query format arrays
Rpm documentation actually states that you must use %{=TAG} for the case commit 7f47cbbd7d1600ae280e48a655c9e870cf9361e0 was trying to fix, but caused regressions in other situations. So the 4.12 behavior is little more than accidental, rpm is actually supposed to error out here (but doesn't, which is another bug). This reverts commits 7f47cbbd7d1600ae280e48a655c9e870cf9361e0 and ead9cdd587bbf052722f0f8598e0983e565e3415.
Diffstat (limited to 'lib/headerfmt.c')
-rw-r--r--lib/headerfmt.c38
1 files changed, 7 insertions, 31 deletions
diff --git a/lib/headerfmt.c b/lib/headerfmt.c
index fdd842c60..3f1880e5f 100644
--- a/lib/headerfmt.c
+++ b/lib/headerfmt.c
@@ -414,13 +414,6 @@ static int parseFormat(headerSprintfArgs hsa, char * str,
goto errxit;
}
- /* Set justOne = 1 for non ARRAY tags */
- if (token->type == PTOK_TAG &&
- !(rpmTagGetReturnType(token->u.tag.tag) &
- RPM_ARRAY_RETURN_TYPE)) {
- token->u.tag.justOne = 1;
- }
-
start = next;
break;
@@ -689,8 +682,8 @@ static char * singleSprintf(headerSprintfArgs hsa, sprintfToken token,
int element)
{
char * t, * te;
- int i, j, found, singleItem;
- int count, numElements;
+ int i, j, found;
+ rpm_count_t count, numElements;
sprintfToken spft;
int condNumFormats;
size_t need;
@@ -739,32 +732,23 @@ static char * singleSprintf(headerSprintfArgs hsa, sprintfToken token,
break;
case PTOK_ARRAY:
- numElements = -1;
- singleItem = 0;
+ numElements = 0;
found = 0;
spft = token->u.array.format;
- /* get number of array items */
for (i = 0; i < token->u.array.numTokens; i++, spft++)
{
rpmtd td = NULL;
- if (spft->type != PTOK_TAG) continue;
+ if (spft->type != PTOK_TAG ||
+ spft->u.tag.justOne) continue;
if (!(td = getData(hsa, spft->u.tag.tag))) {
continue;
}
- count = rpmtdCount(td);
found = 1;
+ count = rpmtdCount(td);
- if (spft->u.tag.justOne) {
- if (count) {
- singleItem = 1;
- }
- continue;
- }
-
-
- if (numElements > 0 && count != numElements)
+ if (numElements > 1 && count != numElements)
switch (td->type) {
default:
hsaError(hsa,
@@ -779,14 +763,6 @@ static char * singleSprintf(headerSprintfArgs hsa, sprintfToken token,
numElements = count;
}
- if (numElements == -1 && singleItem) {
- /* only justOne elements */
- numElements = 1;
- } else if (numElements == -1) {
- /* nothing at all */
- numElements = 0;
- }
-
if (found) {
int isxml;