summaryrefslogtreecommitdiff
path: root/lib/rpmps.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rpmps.c')
-rw-r--r--lib/rpmps.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/lib/rpmps.c b/lib/rpmps.c
index 26623c757..92bf8bd7a 100644
--- a/lib/rpmps.c
+++ b/lib/rpmps.c
@@ -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;
}