Lose the useless rpmtdToString()

- either use rpmtdFormat() or xstrdup() on rpmtdGetString() as appropriate
This commit is contained in:
Panu Matilainen 2008-05-20 12:07:38 +03:00
parent fae1edeb93
commit fc38b84c01
5 changed files with 4 additions and 52 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -149,17 +149,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

View File

@ -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);