Restore 4.13 behavior with single value tags in query format arrays
Rpm documentation actually states that you must use %{=TAG} for the case commit7f47cbbd7d
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 commits7f47cbbd7d
andead9cdd587
.
This commit is contained in:
parent
9c979cffe9
commit
7eb620f595
|
@ -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;
|
||||
|
||||
|
|
|
@ -416,7 +416,6 @@ AT_CLEANUP
|
|||
AT_SETUP([xml format])
|
||||
AT_KEYWORDS([query])
|
||||
AT_CHECK([
|
||||
AT_XFAIL_IF([test $RPM_XFAIL -ne 0])
|
||||
runroot rpm -qp --xml data/RPMS/hello-2.0-1.x86_64.rpm
|
||||
],
|
||||
[0],
|
||||
|
|
Loading…
Reference in New Issue