From: Panu Matilainen Date: Tue, 20 May 2008 09:07:38 +0000 (+0300) Subject: Lose the useless rpmtdToString() X-Git-Tag: tznext/4.11.0.1.tizen20130304~4075 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc38b84c010fa8c4f2617b1351ceaccec9f5da60;p=tools%2Flibrpm-tizen.git Lose the useless rpmtdToString() - either use rpmtdFormat() or xstrdup() on rpmtdGetString() as appropriate --- diff --git a/lib/formats.c b/lib/formats.c index 05dc5c8..ade9f8f 100644 --- a/lib/formats.c +++ b/lib/formats.c @@ -621,7 +621,7 @@ static int instprefixTag(Header h, rpmtd td) } else if (headerGet(h, RPMTAG_INSTPREFIXES, &prefixes, flags)) { /* only return the first prefix of the array */ td->type = RPM_STRING_TYPE; - td->data = rpmtdToString(&prefixes); + td->data = xstrdup(rpmtdGetString(&prefixes)); td->freeData = 1; rpmtdFreeData(&prefixes); return 0; diff --git a/lib/psm.c b/lib/psm.c index 21078b9..be37293 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -128,7 +128,7 @@ static int rpmInstallLoadMacros(rpmfi fi, Header h) switch (rpmtdType(&td)) { case RPM_INT32_TYPE: /* fallthrough */ case RPM_STRING_TYPE: - body = rpmtdToString(&td); + body = rpmtdFormat(&td, RPMTD_FORMAT_STRING, NULL); addMacro(NULL, tagm->macroname, NULL, body, -1); free(body); break; diff --git a/lib/rpmtd.c b/lib/rpmtd.c index 57fdd52..6f411a4 100644 --- a/lib/rpmtd.c +++ b/lib/rpmtd.c @@ -165,43 +165,6 @@ char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg) return str; } -char *rpmtdToString(rpmtd td) -{ - char *res = NULL; - - switch (td->type) { - case RPM_STRING_TYPE: - case RPM_I18NSTRING_TYPE: - case RPM_STRING_ARRAY_TYPE: { - const char *s = rpmtdGetString(td); - if (s) { - res = xstrdup(s); - } - break; - } - case RPM_INT16_TYPE: { - uint16_t *num = rpmtdGetUint16(td); - if (num) { - rasprintf(&res, "%hd", *num); - } - break; - } - case RPM_INT32_TYPE: { - uint32_t *num = rpmtdGetUint32(td); - if (num) { - rasprintf(&res, "%d", *num); - } - break; - } - case RPM_BIN_TYPE: { - /* XXX TODO: convert to hex presentation */ - } - default: - break; - } - return res; -} - int rpmtdFromArgv(rpmtd td, rpmTag tag, ARGV_t argv) { int count = argvCount(argv); diff --git a/lib/rpmtd.h b/lib/rpmtd.h index 0c3388f..0edde14 100644 --- a/lib/rpmtd.h +++ b/lib/rpmtd.h @@ -150,17 +150,6 @@ typedef enum rpmtdFormats_e { char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg); /** \ingroup rpmtd - * Return data from tag container in string presentation. - * Return malloced string presentation of current data in container, - * converting from integers etc as necessary. On array types, data from - * current iteration index is returned. - * @param td Tag data container - * @return String representation of current data (malloc'ed), - * NULL on error - */ -char *rpmtdToString(rpmtd td); - -/** \ingroup rpmtd * Construct tag container from ARGV_t array. * Tag type is checked to be of string array type and array is checked * to be non-empty. diff --git a/lib/rpmte.c b/lib/rpmte.c index 79d9316..3633c74 100644 --- a/lib/rpmte.c +++ b/lib/rpmte.c @@ -91,13 +91,13 @@ static void addTE(rpmts ts, rpmte p, Header h, p->release = xstrdup(release); headerGet(h, RPMTAG_EPOCH, &td, HEADERGET_MINMEM); - p->epoch = rpmtdToString(&td); + p->epoch = rpmtdFormat(&td, RPMTD_FORMAT_STRING, NULL); p->arch = arch ? xstrdup(arch) : NULL; p->archScore = arch ? rpmMachineScore(RPM_MACHTABLE_INSTARCH, arch) : 0; headerGet(h, RPMTAG_OS, &td, HEADERGET_MINMEM); - p->os = rpmtdToString(&td); + p->os = xstrdup(rpmtdGetString(&td)); p->osScore = p->os ? rpmMachineScore(RPM_MACHTABLE_INSTOS, p->os) : 0; p->isSource = headerIsSource(h);