From 4c14dcc5804aa6736616d35aac4db1ea3b29985e Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 22 Feb 2008 23:47:03 -0600 Subject: A few more wide character output fixes Fix up the indentprint and list printing functions so they work properly. This output can be seen in places such as -Ss, -Si, -Qs, and -Qi. Signed-off-by: Dan McGee --- src/pacman/package.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/pacman/package.c') diff --git a/src/pacman/package.c b/src/pacman/package.c index cc4be139..7019e7e6 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -48,6 +49,8 @@ void dump_pkg_full(pmpkg_t *pkg, int level) char bdatestr[50] = "", idatestr[50] = ""; const alpm_list_t *i; alpm_list_t *requiredby = NULL, *depstrings = NULL; + wchar_t *wcstr; + int len; if(pkg == NULL) { return; @@ -86,8 +89,6 @@ void dump_pkg_full(pmpkg_t *pkg, int level) requiredby = alpm_pkg_compute_requiredby(pkg); } - descheader = _("Description : "); - /* actual output */ if(level == 0) { string_display(_("Filename :"), alpm_pkg_get_filename(pkg)); @@ -136,8 +137,16 @@ void dump_pkg_full(pmpkg_t *pkg, int level) } /* printed using a variable to make i18n safe */ + descheader = _("Description : "); + /* len goes from # bytes -> # chars -> # cols */ + len = strlen(descheader) + 1; + wcstr = calloc(len, sizeof(wchar_t)); + len = mbstowcs(wcstr, descheader, len); + len = wcswidth(wcstr, len); + free(wcstr); + /* we can finally print the darn thing */ printf("%s", descheader); - indentprint(alpm_pkg_get_desc(pkg), mbstowcs(NULL, descheader, 0)); + indentprint(alpm_pkg_get_desc(pkg), len); printf("\n\n"); /* Print additional package info if info flag passed more than once */ -- cgit v1.2.3