From 0075c5b195400daa4f9cf76ef54902a74dbb166f Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Thu, 20 Nov 2014 20:29:44 -0500 Subject: Properly support formatting of %! --- expac.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/expac.c b/expac.c index 899881e..d57e8b6 100644 --- a/expac.c +++ b/expac.c @@ -409,7 +409,6 @@ static alpm_list_t *get_validation_method(alpm_pkg_t *pkg) { static int print_pkg(alpm_pkg_t *pkg, const char *format) { const char *f, *end; - char fmt[64], buf[64]; int len, out = 0; end = format + strlen(format); @@ -417,6 +416,7 @@ static int print_pkg(alpm_pkg_t *pkg, const char *format) { for (f = format; f < end; f++) { len = 0; if (*f == '%') { + char fmt[64]; len = strspn(f + 1 + len, printf_flags); len += strspn(f + 1 + len, digits); snprintf(fmt, len + 3, "%ss", f); @@ -458,8 +458,8 @@ static int print_pkg(alpm_pkg_t *pkg, const char *format) { out += printf(fmt, alpm_pkg_get_reason(pkg) ? "dependency" : "explicit"); break; case '!': /* result number */ - snprintf(buf, sizeof(buf), "%d", opt_pkgcounter++); - out += printf(fmt, buf); + fmt[strlen(fmt)-1] = 'd'; + out += printf(fmt, opt_pkgcounter++); break; case 'g': /* base64 gpg sig */ out += printf(fmt, alpm_pkg_get_base64_sig(pkg)); -- cgit v1.2.3-54-g00ecf