diff options
author | Dave Reisner <dreisner@archlinux.org> | 2014-11-20 20:29:44 -0500 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2014-11-20 20:31:56 -0500 |
commit | 0075c5b195400daa4f9cf76ef54902a74dbb166f (patch) | |
tree | a902aa2a68319e8d44395b5e4955fe193be83857 | |
parent | b65a4c4deea3d9b0965bd2421083b98213804768 (diff) | |
download | expac-0075c5b195400daa4f9cf76ef54902a74dbb166f.tar.xz |
Properly support formatting of %!
-rw-r--r-- | expac.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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)); |