mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 08:18:51 -05:00
Move the the description parsing logic to string_display()
So dump_pkg_full will indent all strings correctly. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> [Xav: add string_length function] Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
901e4aa5c2
commit
9451b2e4f2
@ -44,13 +44,11 @@
|
||||
*/
|
||||
void dump_pkg_full(pmpkg_t *pkg, int level)
|
||||
{
|
||||
const char *reason, *descheader;
|
||||
const char *reason;
|
||||
time_t bdate, idate;
|
||||
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;
|
||||
@ -132,19 +130,7 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
|
||||
if(level < 0) {
|
||||
string_display(_("MD5 Sum :"), alpm_pkg_get_md5sum(pkg));
|
||||
}
|
||||
|
||||
/* 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), len);
|
||||
printf("\n\n");
|
||||
string_display(_("Description :"), alpm_pkg_get_desc(pkg));
|
||||
|
||||
/* Print additional package info if info flag passed more than once */
|
||||
if(level > 1) {
|
||||
|
@ -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)
|
||||
{
|
||||
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"));
|
||||
} else {
|
||||
printf("%s\n", string);
|
||||
}
|
||||
if(string == NULL || string[0] == '\0') {
|
||||
printf(_("None"));
|
||||
} else {
|
||||
indentprint(string, len);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void list_display(const char *title, const alpm_list_t *list)
|
||||
|
Loading…
Reference in New Issue
Block a user