Restored %{#TAG} style
authorewt <devnull@localhost>
Mon, 7 Jul 1997 19:20:47 +0000 (19:20 +0000)
committerewt <devnull@localhost>
Mon, 7 Jul 1997 19:20:47 +0000 (19:20 +0000)
CVS patchset: 1729
CVS date: 1997/07/07 19:20:47

CHANGES
lib/header.c

diff --git a/CHANGES b/CHANGES
index 2afee5b..df9f19d 100644 (file)
--- 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
index 08c0c41..a52578a 100644 (file)
@@ -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) {