Use asprintf instead of sbuf

This commit is contained in:
bapt 2020-10-19 07:26:42 +00:00
parent f103c610ff
commit 540621addf

View File

@ -32,8 +32,8 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/sbuf.h>
#include <sys/utsname.h>
#include <sys/sbuf.h>
#include <sys/sysctl.h>
#include <dirent.h>
@ -168,7 +168,7 @@ pkg_get_myabi(char *dest, size_t sz)
static void
subst_packagesite(const char *abi)
{
struct sbuf *newval;
char *newval;
const char *variable_string;
const char *oldval;
@ -180,14 +180,14 @@ subst_packagesite(const char *abi)
if ((variable_string = strstr(oldval, "${ABI}")) == NULL)
return;
newval = sbuf_new_auto();
sbuf_bcat(newval, oldval, variable_string - oldval);
sbuf_cat(newval, abi);
sbuf_cat(newval, variable_string + strlen("${ABI}"));
sbuf_finish(newval);
asprintf(&newval, "%.*s%s%s",
(int)(variable_string - oldval), oldval, abi,
variable_string + strlen("${ABI}"));
if (newval == NULL)
errx(EXIT_FAILURE, "asprintf");
free(c[PACKAGESITE].value);
c[PACKAGESITE].value = strdup(sbuf_data(newval));
c[PACKAGESITE].value = newval;
}
static int