From: ewt Date: Mon, 7 Jul 1997 19:20:47 +0000 (+0000) Subject: Restored %{#TAG} style X-Git-Tag: rpm-4.4-release~4006 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f253cb1c13493c20654ee4eedb2103064c734417;p=platform%2Fupstream%2Frpm.git Restored %{#TAG} style CVS patchset: 1729 CVS date: 1997/07/07 19:20:47 --- diff --git a/CHANGES b/CHANGES index 2afee5b..df9f19d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ 2.4.2 -> 2.4.3: - implemented install time prerequisites + - repaired %{#TAG} query format 2.4.1 -> 2.4.2: - completely rewrote queryformat code diff --git a/lib/header.c b/lib/header.c index 08c0c41..a52578a 100644 --- a/lib/header.c +++ b/lib/header.c @@ -72,6 +72,7 @@ struct sprintfTag { int extNum; int_32 tag; int justOne; + int arrayCount; char * format; char * type; int pad; @@ -1131,6 +1132,7 @@ int parseFormat(char * str, const struct headerTagTableEntry * tags, format[currToken].u.tag.format = start; format[currToken].u.tag.pad = 0; format[currToken].u.tag.justOne = 0; + format[currToken].u.tag.arrayCount = 0; chptr = start; while (*chptr && *chptr != '{') chptr++; @@ -1154,6 +1156,10 @@ int parseFormat(char * str, const struct headerTagTableEntry * tags, if (*start == '=') { format[currToken].u.tag.justOne = 1; start++; + } else if (*start == '#') { + format[currToken].u.tag.justOne = 1; + format[currToken].u.tag.arrayCount = 1; + start++; } next = start; @@ -1307,6 +1313,7 @@ static char * formatValue(struct sprintfTag * tag, Header h, char * val = NULL; char ** strarray; int mayfree = 0; + int countBuf; headerTagFormatFunction tagtype = NULL; const struct headerSprintfExtension * ext; @@ -1327,6 +1334,15 @@ static char * formatValue(struct sprintfTag * tag, Header h, mayfree = 1; } + if (tag->arrayCount) { + if (type == RPM_STRING_ARRAY_TYPE) free(data); + + countBuf = count; + data = &countBuf; + count = 1; + type = RPM_INT32_TYPE; + } + strcpy(buf, "%"); strcat(buf, tag->format); @@ -1436,13 +1452,14 @@ static char * singleSprintf(Header h, struct sprintfToken * token, case PTOK_TAG: val = formatValue(&token->u.tag, h, extensions, extCache, - token->u.tag.justOne ? 1 : element); + token->u.tag.justOne ? 0 : element); break; case PTOK_ARRAY: numElements = -1; for (i = 0; i < token->u.array.numTokens; i++) { if (token->u.array.format[i].type != PTOK_TAG || + token->u.array.format[i].u.tag.arrayCount || token->u.array.format[i].u.tag.justOne) continue; if (token->u.array.format[i].u.tag.ext) {