index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2008-04-07 18:36:18 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2008-04-07 19:09:46 -0500 |
commit | bec2ba5b4005053ce8f7048fa825ed58e3adfdc2 (patch) | |
tree | 30be07c6ff6626f984690649335ed1fc4152e6e2 /src | |
parent | 9441fba12430f568b8b7456fcbe54d4c8a42d24d (diff) |
-rw-r--r-- | src/pacman/callback.c | 10 |
diff --git a/src/pacman/callback.c b/src/pacman/callback.c index 01e65a95..a7686483 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -393,7 +393,17 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent, len = strlen(opr) + ((pkgname) ? strlen(pkgname) : 0) + 2; wcstr = calloc(len, sizeof(wchar_t)); /* print our strings to the alloc'ed memory */ +#if defined(HAVE_SWPRINTF) wclen = swprintf(wcstr, len, L"%s %s", opr, pkgname); +#else + /* because the format string was simple, we can easily do this without + * using swprintf, although it is probably not as safe/fast. The max + * chars we can copy is decremented each time by subtracting the length + * of the already printed/copied wide char string. */ + wclen = mbstowcs(wcstr, opr, len); + wclen += mbstowcs(wcstr + wclen, " ", len - wclen); + wclen += mbstowcs(wcstr + wclen, pkgname, len - wclen); +#endif wcwid = wcswidth(wcstr, wclen); padwid = textlen - wcwid; /* if padwid is < 0, we need to trim the string so padwid = 0 */ |