summaryrefslogtreecommitdiffstats
path: root/src/pacman/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pacman/util.c')
-rw-r--r--src/pacman/util.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 82c460b7..43835047 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -423,14 +423,39 @@ alpm_list_t *strsplit(const char *str, const char splitchar)
return(list);
}
+static int string_length(const char *s)
+{
+ int len;
+ wchar_t *wcstr;
+
+ if(!s) {
+ return(0);
+ }
+ /* len goes from # bytes -> # chars -> # cols */
+ len = strlen(s) + 1;
+ wcstr = calloc(len, sizeof(wchar_t));
+ len = mbstowcs(wcstr, s, len);
+ len = wcswidth(wcstr, len);
+ free(wcstr);
+
+ return(len);
+}
+
void string_display(const char *title, const char *string)
{
- printf("%s ", title);
+ int len = 0;
+
+ if(title) {
+ /* compute the length of title + a space */
+ len = string_length(title) + 1;
+ printf("%s ", title);
+ }
if(string == NULL || string[0] == '\0') {
- printf(_("None\n"));
+ printf(_("None"));
} else {
- printf("%s\n", string);
+ indentprint(string, len);
}
+ printf("\n");
}
void list_display(const char *title, const alpm_list_t *list)