mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 16:28:50 -05:00
Remove trailing whitespace on all lines in list_display
This ensures we never have trailing whitespace. Take the following text, with line numbers added for clarity: 1. Title : item1 item2 item3 item4 2. item5 item6 item7 item8 3. item9 itemA itemB itemC Laszlo Papp helpfully pointed out we would have two trailing spaces on line three after the last item. However, we also had these trailing spaces on lines one and two, which the initial patch didn't take care of. This can be seen on something like `pacman -Qi glibc`. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
926dfe5827
commit
e612eb6ba2
@ -446,16 +446,18 @@ void list_display(const char *title, const alpm_list_t *list)
|
|||||||
for(i = list, cols = len; i; i = alpm_list_next(i)) {
|
for(i = list, cols = len; i; i = alpm_list_next(i)) {
|
||||||
char *str = alpm_list_getdata(i);
|
char *str = alpm_list_getdata(i);
|
||||||
int s = string_length(str);
|
int s = string_length(str);
|
||||||
/* two additional spaces are added to the length */
|
|
||||||
s += 2;
|
|
||||||
int maxcols = getcols();
|
int maxcols = getcols();
|
||||||
if(s + cols > maxcols && maxcols > 0) {
|
if(maxcols > 0 && (cols + s + 2) >= maxcols) {
|
||||||
int j;
|
int j;
|
||||||
cols = len;
|
cols = len;
|
||||||
printf("\n");
|
printf("\n");
|
||||||
for (j = 1; j <= len; j++) {
|
for (j = 1; j <= len; j++) {
|
||||||
printf(" ");
|
printf(" ");
|
||||||
}
|
}
|
||||||
|
} else if (cols != len) {
|
||||||
|
/* 2 spaces are added if this is not the first element on a line. */
|
||||||
|
printf(" ");
|
||||||
|
cols += 2;
|
||||||
}
|
}
|
||||||
printf("%s", str);
|
printf("%s", str);
|
||||||
cols += s;
|
cols += s;
|
||||||
|
Loading…
Reference in New Issue
Block a user