Use rasprintf() in rpmps to properly fix mdvbz#31680

This commit is contained in:
Panu Matilainen 2008-03-18 10:18:08 +02:00
parent 053cf9a25e
commit 5c48f597c8
1 changed files with 14 additions and 18 deletions

View File

@ -4,6 +4,7 @@
#include "system.h"
#include <rpm/rpmstring.h>
#include <rpm/rpmps.h>
#include "debug.h"
@ -280,48 +281,44 @@ char * rpmProblemString(const rpmProblem prob)
const char * pkgNEVR = (prob->pkgNEVR ? prob->pkgNEVR : "?pkgNEVR?");
const char * altNEVR = (prob->altNEVR ? prob->altNEVR : "? ?altNEVR?");
const char * str1 = (prob->str1 ? prob->str1 : N_("different"));
size_t nb = strlen(pkgNEVR) + strlen(str1) + strlen(altNEVR) + 256;
char * buf = xmalloc(nb+1);
char * buf = NULL;
int rc;
switch (prob->type) {
case RPMPROB_BADARCH:
rc = snprintf(buf, nb,
_("package %s is intended for a %s architecture"),
rc = rasprintf(&buf, _("package %s is intended for a %s architecture"),
pkgNEVR, str1);
break;
case RPMPROB_BADOS:
rc = snprintf(buf, nb,
rc = rasprintf(&buf,
_("package %s is intended for a %s operating system"),
pkgNEVR, str1);
break;
case RPMPROB_PKG_INSTALLED:
rc = snprintf(buf, nb,
_("package %s is already installed"),
rc = rasprintf(&buf, _("package %s is already installed"),
pkgNEVR);
break;
case RPMPROB_BADRELOCATE:
rc = snprintf(buf, nb,
_("path %s in package %s is not relocatable"),
rc = rasprintf(&buf, _("path %s in package %s is not relocatable"),
str1, pkgNEVR);
break;
case RPMPROB_NEW_FILE_CONFLICT:
rc = snprintf(buf, nb,
rc = rasprintf(&buf,
_("file %s conflicts between attempted installs of %s and %s"),
str1, pkgNEVR, altNEVR);
break;
case RPMPROB_FILE_CONFLICT:
rc = snprintf(buf, nb,
rc = rasprintf(&buf,
_("file %s from install of %s conflicts with file from package %s"),
str1, pkgNEVR, altNEVR);
break;
case RPMPROB_OLDPACKAGE:
rc = snprintf(buf, nb,
rc = rasprintf(&buf,
_("package %s (which is newer than %s) is already installed"),
altNEVR, pkgNEVR);
break;
case RPMPROB_DISKSPACE:
rc = snprintf(buf, nb,
rc = rasprintf(&buf,
_("installing package %s needs %ld%cB on the %s filesystem"),
pkgNEVR,
prob->ulong1 > (1024*1024)
@ -331,28 +328,27 @@ char * rpmProblemString(const rpmProblem prob)
str1);
break;
case RPMPROB_DISKNODES:
rc = snprintf(buf, nb,
rc = rasprintf(&buf,
_("installing package %s needs %ld inodes on the %s filesystem"),
pkgNEVR, (long)prob->ulong1, str1);
break;
case RPMPROB_REQUIRES:
rc = snprintf(buf, nb, _("%s is needed by %s%s"),
rc = rasprintf(&buf, _("%s is needed by %s%s"),
altNEVR+2,
(prob->ulong1 ? "" : _("(installed) ")), pkgNEVR);
break;
case RPMPROB_CONFLICT:
rc = snprintf(buf, nb, _("%s conflicts with %s%s"),
rc = rasprintf(&buf, _("%s conflicts with %s%s"),
altNEVR+2,
(prob->ulong1 ? "" : _("(installed) ")), pkgNEVR);
break;
default:
rc = snprintf(buf, nb,
rc = rasprintf(&buf,
_("unknown error %d encountered while manipulating package %s"),
prob->type, pkgNEVR);
break;
}
buf[nb] = '\0';
return buf;
}