From 119350cd9a9c8cff3fea31baef8a2f354c8ed91d Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Tue, 13 Jun 2023 14:54:05 +0300 Subject: [PATCH] Show the tag number for unknown tags in --xml output --xml is only really useful for diagnostics, and for that purpose in particular, showing "(unknown)" text instead of the tag number for unknown tags is just offensively dumb. No more! --- lib/headerfmt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/headerfmt.c b/lib/headerfmt.c index 971d16f2b1..890420d2a2 100644 --- a/lib/headerfmt.c +++ b/lib/headerfmt.c @@ -772,6 +772,12 @@ static char * singleSprintf(headerSprintfArgs hsa, sprintfToken token, if (isxml) { const char * tagN = rpmTagGetName(spft->u.tag.tag); + char *tagval = NULL; + + if (rstreq(tagN, "(unknown)")) { + rasprintf(&tagval, "[%u]", spft->u.tag.tag); + tagN = tagval; + } need = sizeof(" \n") - 1; if (tagN != NULL) @@ -782,6 +788,8 @@ static char * singleSprintf(headerSprintfArgs hsa, sprintfToken token, te = stpcpy(te, tagN); te = stpcpy(te, "\">\n"); hsa->vallen += (te - t); + + free(tagval); } t = hsaReserve(hsa, need);