[pacman-dev] (no subject)
This asciicast demonstrates the output of this patch: https://asciinema.org/a/321160
This patch splits the monolithic 'Packages (count):' output on transactions into multiple package outputs per category of action: 'Installing (count):', 'Upgrading (count):', and 'Removing (count):'. Signed-off-by: Carson Black <uhhadd@gmail.com> --- src/pacman/util.c | 80 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 14 deletions(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index 6693ec75..2fd8688f 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -898,7 +898,10 @@ static void _display_targets(alpm_list_t *targets, int verbose) char *str; off_t isize = 0, rsize = 0, dlsize = 0; unsigned short cols; - alpm_list_t *i, *names = NULL, *header = NULL, *rows = NULL; + char *install_header = ""; + char *upgrade_header = ""; + char *remove_header = ""; + alpm_list_t *i, *install = NULL, *upgrade = NULL, *remove = NULL, *header = NULL, *rows = NULL; if(!targets) { return; @@ -918,6 +921,10 @@ static void _display_targets(alpm_list_t *targets, int verbose) } } + uint install_targets = 0; + uint upgrade_targets = 0; + uint remove_targets = 0; + /* form data for both verbose and non-verbose display */ for(i = targets; i; i = alpm_list_next(i)) { pm_target_t *target = i->data; @@ -926,38 +933,83 @@ static void _display_targets(alpm_list_t *targets, int verbose) rows = alpm_list_add(rows, create_verbose_row(target)); } - if(target->install) { + if(target->install && target->remove) { pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->install), config->colstr.faint, - alpm_pkg_get_version(target->install), config->colstr.nocolor); - } else if(isize == 0) { - pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->remove), config->colstr.faint, - alpm_pkg_get_version(target->remove), config->colstr.nocolor); + alpm_pkg_get_version(target->install), config->colstr.nocolor); + } else if(target->install) { + pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->install), config->colstr.faint, + alpm_pkg_get_version(target->install), config->colstr.nocolor); } else { - pm_asprintf(&str, "%s%s-%s %s[%s]%s", alpm_pkg_get_name(target->remove), config->colstr.faint, - alpm_pkg_get_version(target->remove), config->colstr.nocolor, _("removal"), config->colstr.nocolor); + const char* target_name = alpm_pkg_get_name(target->remove); + pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->remove), config->colstr.faint, + alpm_pkg_get_version(target->remove), config->colstr.nocolor); + } + + if (target->install && target->remove) { + upgrade = alpm_list_add(upgrade, str); + upgrade_targets++; + } else if (target->install) { + install = alpm_list_add(install, str); + install_targets++; + } else if (target->remove) { + remove = alpm_list_add(remove, str); + remove_targets++; } - names = alpm_list_add(names, str); } /* print to screen */ - pm_asprintf(&str, "%s (%zu)", _("Packages"), alpm_list_count(targets)); - printf("\n"); + if (install_targets) { + pm_asprintf(&install_header, _("Installing (%u):"), install_targets); + } + if (remove_targets) { + pm_asprintf(&remove_header, _("Removing (%u):"), remove_targets); + } + if (upgrade_targets) { + pm_asprintf(&upgrade_header, _("Upgrading (%u):"), upgrade_targets); + } cols = getcols(); if(verbose) { header = create_verbose_header(alpm_list_count(targets)); if(table_display(header, rows, cols) != 0) { /* fallback to list display if table wouldn't fit */ - list_display(str, names, cols); + if (install_targets) { + list_display(install_header, install, cols); + } + if (upgrade_targets) { + list_display(upgrade_header, upgrade, cols); + } + if (remove_targets) { + list_display(remove_header, remove, cols); + } } } else { - list_display(str, names, cols); + if (install_targets) { + list_display(install_header, install, cols); + if (upgrade_targets || remove_targets) { + printf("\n"); + } + } + if (upgrade_targets) { + list_display(upgrade_header, upgrade, cols); + if (remove_targets) { + printf("\n"); + } + } + if (remove_targets) { + list_display(remove_header, remove, cols); + } } printf("\n"); table_free(header, rows); - FREELIST(names); + if (install) alpm_list_free(install); + if (upgrade) alpm_list_free(upgrade); + if (remove) alpm_list_free(remove); free(str); + if (install_header != "") free(install_header); + if (upgrade_header != "") free(upgrade_header); + if (remove_header != "") free(remove_header); rows = NULL; if(dlsize > 0 || config->op_s_downloadonly) { -- 2.26.0
On 4/17/20 6:22 PM, Carson Black wrote:
This patch splits the monolithic 'Packages (count):' output on transactions into multiple package outputs per category of action: 'Installing (count):', 'Upgrading (count):', and 'Removing (count):'.
Signed-off-by: Carson Black <uhhadd@gmail.com>
This builds with warnings, which means that development builds including -Werror will fail. [1/4] Compiling C object 'pacman@exe/src_pacman_util.c.o' FAILED: pacman@exe/src_pacman_util.c.o ccache cc -Ipacman@exe -I. -I.. -Isrc/common -I../src/common -Ilib/libalpm -I../lib/libalpm -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -std=gnu99 -g -Wcast-align -Wclobbered -Wempty-body -Wfloat-equal -Wformat-nonliteral -Wformat-security -Wignored-qualifiers -Wimplicit-fallthrough -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-field-initializers -Wmissing-parameter-type -Wmissing-prototypes -Wold-style-declaration -Woverride-init -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-compare -Wstrict-aliasing -Wstrict-overflow=5 -Wstrict-prototypes -Wtype-limits -Wuninitialized -Wunused-but-set-parameter -Wunused-parameter -Wwrite-strings -include config.h -MD -MQ 'pacman@exe/src_pacman_util.c.o' -MF 'pacman@exe/src_pacman_util.c.o.d' -o 'pacman@exe/src_pacman_util.c.o' -c ../src/pacman/util.c ../src/pacman/util.c: In function ‘_display_targets’: ../src/pacman/util.c:901:25: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] 901 | char *install_header = ""; | ^~ ../src/pacman/util.c:902:25: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] 902 | char *upgrade_header = ""; | ^~ ../src/pacman/util.c:903:24: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] 903 | char *remove_header = ""; | ^~ ../src/pacman/util.c:943:16: error: unused variable ‘target_name’ [-Werror=unused-variable] 943 | const char* target_name = alpm_pkg_get_name(target->remove); | ^~~~~~~~~~~ ../src/pacman/util.c:1010:21: error: comparison with string literal results in unspecified behavior [-Werror=address] 1010 | if (install_header != "") free(install_header); | ^~ ../src/pacman/util.c:1011:21: error: comparison with string literal results in unspecified behavior [-Werror=address] 1011 | if (upgrade_header != "") free(upgrade_header); | ^~ ../src/pacman/util.c:1012:20: error: comparison with string literal results in unspecified behavior [-Werror=address] 1012 | if (remove_header != "") free(remove_header); | ^~ cc1: all warnings being treated as errors -- Eli Schwartz Bug Wrangler and Trusted User
Thanks for pointing that out; addressed compiler warnings.
This patch splits the monolithic 'Packages (count):' output on transactions into multiple package outputs per category of action: 'Installing (count):', 'Upgrading (count):', and 'Removing (count):'. Signed-off-by: Carson Black <uhhadd@gmail.com> --- src/pacman/util.c | 79 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 14 deletions(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index 6693ec75..3bec6774 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -898,7 +898,10 @@ static void _display_targets(alpm_list_t *targets, int verbose) char *str; off_t isize = 0, rsize = 0, dlsize = 0; unsigned short cols; - alpm_list_t *i, *names = NULL, *header = NULL, *rows = NULL; + char *install_header; + char *upgrade_header; + char *remove_header; + alpm_list_t *i, *install = NULL, *upgrade = NULL, *remove = NULL, *header = NULL, *rows = NULL; if(!targets) { return; @@ -918,6 +921,10 @@ static void _display_targets(alpm_list_t *targets, int verbose) } } + uint install_targets = 0; + uint upgrade_targets = 0; + uint remove_targets = 0; + /* form data for both verbose and non-verbose display */ for(i = targets; i; i = alpm_list_next(i)) { pm_target_t *target = i->data; @@ -926,38 +933,82 @@ static void _display_targets(alpm_list_t *targets, int verbose) rows = alpm_list_add(rows, create_verbose_row(target)); } - if(target->install) { + if(target->install && target->remove) { pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->install), config->colstr.faint, - alpm_pkg_get_version(target->install), config->colstr.nocolor); - } else if(isize == 0) { - pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->remove), config->colstr.faint, - alpm_pkg_get_version(target->remove), config->colstr.nocolor); + alpm_pkg_get_version(target->install), config->colstr.nocolor); + } else if(target->install) { + pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->install), config->colstr.faint, + alpm_pkg_get_version(target->install), config->colstr.nocolor); } else { - pm_asprintf(&str, "%s%s-%s %s[%s]%s", alpm_pkg_get_name(target->remove), config->colstr.faint, - alpm_pkg_get_version(target->remove), config->colstr.nocolor, _("removal"), config->colstr.nocolor); + pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->remove), config->colstr.faint, + alpm_pkg_get_version(target->remove), config->colstr.nocolor); + } + + if (target->install && target->remove) { + upgrade = alpm_list_add(upgrade, str); + upgrade_targets++; + } else if (target->install) { + install = alpm_list_add(install, str); + install_targets++; + } else if (target->remove) { + remove = alpm_list_add(remove, str); + remove_targets++; } - names = alpm_list_add(names, str); } /* print to screen */ - pm_asprintf(&str, "%s (%zu)", _("Packages"), alpm_list_count(targets)); - printf("\n"); + if (install_targets) { + pm_asprintf(&install_header, _("Installing (%u):"), install_targets); + } + if (remove_targets) { + pm_asprintf(&remove_header, _("Removing (%u):"), remove_targets); + } + if (upgrade_targets) { + pm_asprintf(&upgrade_header, _("Upgrading (%u):"), upgrade_targets); + } cols = getcols(); if(verbose) { header = create_verbose_header(alpm_list_count(targets)); if(table_display(header, rows, cols) != 0) { /* fallback to list display if table wouldn't fit */ - list_display(str, names, cols); + if (install_targets) { + list_display(install_header, install, cols); + } + if (upgrade_targets) { + list_display(upgrade_header, upgrade, cols); + } + if (remove_targets) { + list_display(remove_header, remove, cols); + } } } else { - list_display(str, names, cols); + if (install_targets) { + list_display(install_header, install, cols); + if (upgrade_targets || remove_targets) { + printf("\n"); + } + } + if (upgrade_targets) { + list_display(upgrade_header, upgrade, cols); + if (remove_targets) { + printf("\n"); + } + } + if (remove_targets) { + list_display(remove_header, remove, cols); + } } printf("\n"); table_free(header, rows); - FREELIST(names); + if (install) alpm_list_free(install); + if (upgrade) alpm_list_free(upgrade); + if (remove) alpm_list_free(remove); free(str); + if (install_header) free(install_header); + if (upgrade_header) free(upgrade_header); + if (remove_header) free(remove_header); rows = NULL; if(dlsize > 0 || config->op_s_downloadonly) { -- 2.26.0
On 04/17/20 at 06:57pm, Carson Black wrote:
This patch splits the monolithic 'Packages (count):' output on transactions into multiple package outputs per category of action: 'Installing (count):', 'Upgrading (count):', and 'Removing (count):'.
Signed-off-by: Carson Black <uhhadd@gmail.com> --- src/pacman/util.c | 79 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 14 deletions(-)
diff --git a/src/pacman/util.c b/src/pacman/util.c index 6693ec75..3bec6774 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -898,7 +898,10 @@ static void _display_targets(alpm_list_t *targets, int verbose) char *str; off_t isize = 0, rsize = 0, dlsize = 0; unsigned short cols; - alpm_list_t *i, *names = NULL, *header = NULL, *rows = NULL; + char *install_header; + char *upgrade_header; + char *remove_header; + alpm_list_t *i, *install = NULL, *upgrade = NULL, *remove = NULL, *header = NULL, *rows = NULL;
if(!targets) { return; @@ -918,6 +921,10 @@ static void _display_targets(alpm_list_t *targets, int verbose) } }
+ uint install_targets = 0; + uint upgrade_targets = 0; + uint remove_targets = 0;
No need for these, just use alpm_list_count as needed.
/* form data for both verbose and non-verbose display */ for(i = targets; i; i = alpm_list_next(i)) { pm_target_t *target = i->data; @@ -926,38 +933,82 @@ static void _display_targets(alpm_list_t *targets, int verbose) rows = alpm_list_add(rows, create_verbose_row(target)); }
- if(target->install) { + if(target->install && target->remove) { pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->install), config->colstr.faint, - alpm_pkg_get_version(target->install), config->colstr.nocolor); - } else if(isize == 0) { - pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->remove), config->colstr.faint, - alpm_pkg_get_version(target->remove), config->colstr.nocolor); + alpm_pkg_get_version(target->install), config->colstr.nocolor);
Remove the extra indentation.
+ } else if(target->install) { + pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->install), config->colstr.faint, + alpm_pkg_get_version(target->install), config->colstr.nocolor); } else { - pm_asprintf(&str, "%s%s-%s %s[%s]%s", alpm_pkg_get_name(target->remove), config->colstr.faint, - alpm_pkg_get_version(target->remove), config->colstr.nocolor, _("removal"), config->colstr.nocolor); + pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->remove), config->colstr.faint, + alpm_pkg_get_version(target->remove), config->colstr.nocolor); + } + + if (target->install && target->remove) { + upgrade = alpm_list_add(upgrade, str); + upgrade_targets++; + } else if (target->install) { + install = alpm_list_add(install, str); + install_targets++; + } else if (target->remove) { + remove = alpm_list_add(remove, str); + remove_targets++;
This just duplicates the conditional above, combine the two.
} - names = alpm_list_add(names, str); }
/* print to screen */ - pm_asprintf(&str, "%s (%zu)", _("Packages"), alpm_list_count(targets)); - printf("\n"); + if (install_targets) { + pm_asprintf(&install_header, _("Installing (%u):"), install_targets); + } + if (remove_targets) { + pm_asprintf(&remove_header, _("Removing (%u):"), remove_targets); + } + if (upgrade_targets) { + pm_asprintf(&upgrade_header, _("Upgrading (%u):"), upgrade_targets); + }
I don't see any point in pre-generating all three headers, just use str and generate and free them as they're used.
cols = getcols(); if(verbose) { header = create_verbose_header(alpm_list_count(targets)); if(table_display(header, rows, cols) != 0) { /* fallback to list display if table wouldn't fit */ - list_display(str, names, cols); + if (install_targets) { + list_display(install_header, install, cols); + } + if (upgrade_targets) { + list_display(upgrade_header, upgrade, cols); + } + if (remove_targets) { + list_display(remove_header, remove, cols); + }
This does not match the way packages are displayed without verbose.
} } else { - list_display(str, names, cols); + if (install_targets) { + list_display(install_header, install, cols); + if (upgrade_targets || remove_targets) { + printf("\n"); + } + } + if (upgrade_targets) { + list_display(upgrade_header, upgrade, cols); + if (remove_targets) { + printf("\n"); + } + } + if (remove_targets) { + list_display(remove_header, remove, cols); + } } printf("\n");
table_free(header, rows); - FREELIST(names); + if (install) alpm_list_free(install); + if (upgrade) alpm_list_free(upgrade); + if (remove) alpm_list_free(remove);
These should be FREELIST just like the line they're replacing.
free(str); + if (install_header) free(install_header); + if (upgrade_header) free(upgrade_header); + if (remove_header) free(remove_header); rows = NULL;
if(dlsize > 0 || config->op_s_downloadonly) { -- 2.26.0
-- apg
This patch splits the monolithic 'Packages (count):' output on transactions into multiple package outputs per category of action: 'Installing (count):', 'Upgrading (count):', and 'Removing (count):'. Signed-off-by: Carson Black <uhhadd@gmail.com> --- src/pacman/util.c | 63 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index 6693ec75..8fdf2cea 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -898,7 +898,10 @@ static void _display_targets(alpm_list_t *targets, int verbose) char *str; off_t isize = 0, rsize = 0, dlsize = 0; unsigned short cols; - alpm_list_t *i, *names = NULL, *header = NULL, *rows = NULL; + char *install_header; + char *upgrade_header; + char *remove_header; + alpm_list_t *i, *install = NULL, *upgrade = NULL, *remove = NULL, *header = NULL, *rows = NULL; if(!targets) { return; @@ -926,38 +929,68 @@ static void _display_targets(alpm_list_t *targets, int verbose) rows = alpm_list_add(rows, create_verbose_row(target)); } - if(target->install) { + if(target->install && target->remove) { + pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->install), config->colstr.faint, + alpm_pkg_get_version(target->install), config->colstr.nocolor); + upgrade = alpm_list_add(upgrade, str); + } else if(target->install) { pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->install), config->colstr.faint, alpm_pkg_get_version(target->install), config->colstr.nocolor); - } else if(isize == 0) { + install = alpm_list_add(install, str); + } else { pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->remove), config->colstr.faint, alpm_pkg_get_version(target->remove), config->colstr.nocolor); - } else { - pm_asprintf(&str, "%s%s-%s %s[%s]%s", alpm_pkg_get_name(target->remove), config->colstr.faint, - alpm_pkg_get_version(target->remove), config->colstr.nocolor, _("removal"), config->colstr.nocolor); + remove = alpm_list_add(remove, str); } - names = alpm_list_add(names, str); } - /* print to screen */ - pm_asprintf(&str, "%s (%zu)", _("Packages"), alpm_list_count(targets)); - printf("\n"); - cols = getcols(); if(verbose) { header = create_verbose_header(alpm_list_count(targets)); if(table_display(header, rows, cols) != 0) { /* fallback to list display if table wouldn't fit */ - list_display(str, names, cols); + if (alpm_list_count(install)) { + pm_asprintf(&install_header, _("Installing (%lu):"), alpm_list_count(install)); + list_display(install_header, install, cols); + } + if (alpm_list_count(upgrade)) { + pm_asprintf(&upgrade_header, _("Upgrading (%lu):"), alpm_list_count(upgrade)); + list_display(upgrade_header, upgrade, cols); + } + if (alpm_list_count(remove)) { + pm_asprintf(&remove_header, _("Removing (%lu):"), alpm_list_count(remove)); + list_display(remove_header, remove, cols); + } } } else { - list_display(str, names, cols); + if (alpm_list_count(install)) { + pm_asprintf(&install_header, _("Installing (%lu):"), alpm_list_count(install)); + list_display(install_header, install, cols); + if (alpm_list_count(upgrade) || alpm_list_count(remove)) { + printf("\n"); + } + } + if (alpm_list_count(upgrade)) { + pm_asprintf(&upgrade_header, _("Upgrading (%lu):"), alpm_list_count(upgrade)); + list_display(upgrade_header, upgrade, cols); + if (alpm_list_count(remove)) { + printf("\n"); + } + } + if (alpm_list_count(remove)) { + pm_asprintf(&remove_header, _("Removing (%lu):"), alpm_list_count(remove)); + list_display(remove_header, remove, cols); + } } printf("\n"); table_free(header, rows); - FREELIST(names); - free(str); + if (install) FREELIST(install); + if (upgrade) FREELIST(upgrade); + if (remove) FREELIST(remove); + if (install_header) free(install_header); + if (upgrade_header) free(upgrade_header); + if (remove_header) free(remove_header); rows = NULL; if(dlsize > 0 || config->op_s_downloadonly) { -- I believe this should address your feedback. 2.26.0
On 4/26/20 8:34 PM, Carson Black wrote:
This patch splits the monolithic 'Packages (count):' output on transactions into multiple package outputs per category of action: 'Installing (count):', 'Upgrading (count):', and 'Removing (count):'.
Signed-off-by: Carson Black <uhhadd@gmail.com> --- src/pacman/util.c | 63 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 15 deletions(-)
diff --git a/src/pacman/util.c b/src/pacman/util.c index 6693ec75..8fdf2cea 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -898,7 +898,10 @@ static void _display_targets(alpm_list_t *targets, int verbose) char *str; off_t isize = 0, rsize = 0, dlsize = 0; unsigned short cols; - alpm_list_t *i, *names = NULL, *header = NULL, *rows = NULL; + char *install_header; + char *upgrade_header; + char *remove_header;
These do need to be initialized to *something*. Set them = NULL; Without setting them to NULL, I get a crash later.
+ alpm_list_t *i, *install = NULL, *upgrade = NULL, *remove = NULL, *header = NULL, *rows = NULL;
if(!targets) { return; @@ -926,38 +929,68 @@ static void _display_targets(alpm_list_t *targets, int verbose) rows = alpm_list_add(rows, create_verbose_row(target)); }
- if(target->install) { + if(target->install && target->remove) { + pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->install), config->colstr.faint, + alpm_pkg_get_version(target->install), config->colstr.nocolor); + upgrade = alpm_list_add(upgrade, str); + } else if(target->install) { pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->install), config->colstr.faint, alpm_pkg_get_version(target->install), config->colstr.nocolor); - } else if(isize == 0) { + install = alpm_list_add(install, str); + } else { pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->remove), config->colstr.faint, alpm_pkg_get_version(target->remove), config->colstr.nocolor); - } else { - pm_asprintf(&str, "%s%s-%s %s[%s]%s", alpm_pkg_get_name(target->remove), config->colstr.faint, - alpm_pkg_get_version(target->remove), config->colstr.nocolor, _("removal"), config->colstr.nocolor); + remove = alpm_list_add(remove, str); } - names = alpm_list_add(names, str); }
- /* print to screen */ - pm_asprintf(&str, "%s (%zu)", _("Packages"), alpm_list_count(targets)); - printf("\n"); - cols = getcols(); if(verbose) { header = create_verbose_header(alpm_list_count(targets)); if(table_display(header, rows, cols) != 0) { /* fallback to list display if table wouldn't fit */ - list_display(str, names, cols); + if (alpm_list_count(install)) { + pm_asprintf(&install_header, _("Installing (%lu):"), alpm_list_count(install)); + list_display(install_header, install, cols); + } + if (alpm_list_count(upgrade)) { + pm_asprintf(&upgrade_header, _("Upgrading (%lu):"), alpm_list_count(upgrade)); + list_display(upgrade_header, upgrade, cols); + } + if (alpm_list_count(remove)) { + pm_asprintf(&remove_header, _("Removing (%lu):"), alpm_list_count(remove)); + list_display(remove_header, remove, cols); + } } } else { - list_display(str, names, cols); + if (alpm_list_count(install)) { + pm_asprintf(&install_header, _("Installing (%lu):"), alpm_list_count(install)); + list_display(install_header, install, cols); + if (alpm_list_count(upgrade) || alpm_list_count(remove)) { + printf("\n"); + } + } + if (alpm_list_count(upgrade)) { + pm_asprintf(&upgrade_header, _("Upgrading (%lu):"), alpm_list_count(upgrade)); + list_display(upgrade_header, upgrade, cols); + if (alpm_list_count(remove)) { + printf("\n"); + } + } + if (alpm_list_count(remove)) { + pm_asprintf(&remove_header, _("Removing (%lu):"), alpm_list_count(remove)); + list_display(remove_header, remove, cols); + } } printf("\n");
table_free(header, rows); - FREELIST(names); - free(str); + if (install) FREELIST(install); + if (upgrade) FREELIST(upgrade); + if (remove) FREELIST(remove); + if (install_header) free(install_header); + if (upgrade_header) free(upgrade_header); + if (remove_header) free(remove_header);
resolving dependencies... looking for conflicting packages... Upgrading (46): bind-tools-9.16.2-2 bluez-libs-5.54-2 checkbashisms-2.20.3-1 containerd-1.3.4-2 cryptsetup-2.3.1-2 dkms-2.8.1-2 fanficfare-3.18.0-1 firefox-developer-edition-76.0b8-1 gedit-3.36.2-1 gnome-terminal-3.36.2-1 gvim-8.2.0510-2 imagemagick-7.0.10.8-1 json-c-0.14-1 lib32-mesa-20.0.5-1 libmfx-20.1.1-1 libslirp-4.3.0-1 lilv-0.24.8-1 linux-firmware-20200421.78c0348-1 man-pages-5.06-2 meson-0.54.1-1 ndctl-68-2 perl-exporter-tiny-1.002002-1 python-distro-1.5.0-1 python-peewee-3.13.3-1 python-sphinx-3.0.3-1 python-wcwidth-0.1.9-1 python2-distro-1.5.0-1 python2-wcwidth-0.1.9-1 qbittorrent-4.2.5-1 rust-1:1.43.0-2 s-nail-14.9.19-1 serd-0.30.4-1 systemd-245.5-2 systemd-libs-245.5-2 systemd-sysvcompat-245.5-2 texinfo-6.7-3 tmux-3.1-1 tzdata-2020a-1 unzip-6.0-14 vim-runtime-8.2.0510-2 vte-common-0.60.2-1 vte3-0.60.2-1 webkit2gtk-2.28.2-1 wine-5.7-1 xapps-1.8.0-1 zip-3.0-9 Total Download Size: 88.22 MiB Total Installed Size: 1860.56 MiB Net Upgrade Size: 2.28 MiB double free or corruption (out) Aborted All I have are upgrades.
rows = NULL;
if(dlsize > 0 || config->op_s_downloadonly) {
-- Eli Schwartz Bug Wrangler and Trusted User
This patch splits the monolithic 'Packages (count):' output on transactions into multiple package outputs per category of action: 'Installing (count):', 'Upgrading (count):', and 'Removing (count):'. Signed-off-by: Carson Black <uhhadd@gmail.com> --- src/pacman/util.c | 61 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/src/pacman/util.c b/src/pacman/util.c index 6693ec75..9b192317 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -898,7 +898,8 @@ static void _display_targets(alpm_list_t *targets, int verbose) char *str; off_t isize = 0, rsize = 0, dlsize = 0; unsigned short cols; - alpm_list_t *i, *names = NULL, *header = NULL, *rows = NULL; + char *install_header = NULL, *upgrade_header = NULL, *remove_header = NULL; + alpm_list_t *i, *install = NULL, *upgrade = NULL, *remove = NULL, *header = NULL, *rows = NULL; if(!targets) { return; @@ -926,38 +927,68 @@ static void _display_targets(alpm_list_t *targets, int verbose) rows = alpm_list_add(rows, create_verbose_row(target)); } - if(target->install) { + if(target->install && target->remove) { + pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->install), config->colstr.faint, + alpm_pkg_get_version(target->install), config->colstr.nocolor); + upgrade = alpm_list_add(upgrade, str); + } else if(target->install) { pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->install), config->colstr.faint, alpm_pkg_get_version(target->install), config->colstr.nocolor); - } else if(isize == 0) { + install = alpm_list_add(install, str); + } else { pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->remove), config->colstr.faint, alpm_pkg_get_version(target->remove), config->colstr.nocolor); - } else { - pm_asprintf(&str, "%s%s-%s %s[%s]%s", alpm_pkg_get_name(target->remove), config->colstr.faint, - alpm_pkg_get_version(target->remove), config->colstr.nocolor, _("removal"), config->colstr.nocolor); + remove = alpm_list_add(remove, str); } - names = alpm_list_add(names, str); } - /* print to screen */ - pm_asprintf(&str, "%s (%zu)", _("Packages"), alpm_list_count(targets)); - printf("\n"); - cols = getcols(); if(verbose) { header = create_verbose_header(alpm_list_count(targets)); if(table_display(header, rows, cols) != 0) { /* fallback to list display if table wouldn't fit */ - list_display(str, names, cols); + if (alpm_list_count(install)) { + pm_asprintf(&install_header, _("Installing (%lu):"), alpm_list_count(install)); + list_display(install_header, install, cols); + } + if (alpm_list_count(upgrade)) { + pm_asprintf(&upgrade_header, _("Upgrading (%lu):"), alpm_list_count(upgrade)); + list_display(upgrade_header, upgrade, cols); + } + if (alpm_list_count(remove)) { + pm_asprintf(&remove_header, _("Removing (%lu):"), alpm_list_count(remove)); + list_display(remove_header, remove, cols); + } } } else { - list_display(str, names, cols); + if (alpm_list_count(install)) { + pm_asprintf(&install_header, _("Installing (%lu):"), alpm_list_count(install)); + list_display(install_header, install, cols); + if (alpm_list_count(upgrade) || alpm_list_count(remove)) { + printf("\n"); + } + } + if (alpm_list_count(upgrade)) { + pm_asprintf(&upgrade_header, _("Upgrading (%lu):"), alpm_list_count(upgrade)); + list_display(upgrade_header, upgrade, cols); + if (alpm_list_count(remove)) { + printf("\n"); + } + } + if (alpm_list_count(remove)) { + pm_asprintf(&remove_header, _("Removing (%lu):"), alpm_list_count(remove)); + list_display(remove_header, remove, cols); + } } printf("\n"); table_free(header, rows); - FREELIST(names); - free(str); + FREELIST(install); + FREELIST(upgrade); + FREELIST(remove); + free(install_header); + free(upgrade_header); + free(remove_header); rows = NULL; if(dlsize > 0 || config->op_s_downloadonly) { -- Ok, this should fix memory management issues. 2.26.0
On 27/4/20 11:35 am, Carson Black wrote:
This patch splits the monolithic 'Packages (count):' output on transactions into multiple package outputs per category of action: 'Installing (count):', 'Upgrading (count):', and 'Removing (count):'.
Comment without patch review... pacman -Suu could perform package downgrades. pacman -S <pkg> could reinstall a package. Both those would be reported as "Upgrading". A
Signed-off-by: Carson Black <uhhadd@gmail.com> --- src/pacman/util.c | 61 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 15 deletions(-)
diff --git a/src/pacman/util.c b/src/pacman/util.c index 6693ec75..9b192317 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -898,7 +898,8 @@ static void _display_targets(alpm_list_t *targets, int verbose) char *str; off_t isize = 0, rsize = 0, dlsize = 0; unsigned short cols; - alpm_list_t *i, *names = NULL, *header = NULL, *rows = NULL; + char *install_header = NULL, *upgrade_header = NULL, *remove_header = NULL; + alpm_list_t *i, *install = NULL, *upgrade = NULL, *remove = NULL, *header = NULL, *rows = NULL;
if(!targets) { return; @@ -926,38 +927,68 @@ static void _display_targets(alpm_list_t *targets, int verbose) rows = alpm_list_add(rows, create_verbose_row(target)); }
- if(target->install) { + if(target->install && target->remove) { + pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->install), config->colstr.faint, + alpm_pkg_get_version(target->install), config->colstr.nocolor); + upgrade = alpm_list_add(upgrade, str); + } else if(target->install) { pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->install), config->colstr.faint, alpm_pkg_get_version(target->install), config->colstr.nocolor); - } else if(isize == 0) { + install = alpm_list_add(install, str); + } else { pm_asprintf(&str, "%s%s-%s%s", alpm_pkg_get_name(target->remove), config->colstr.faint, alpm_pkg_get_version(target->remove), config->colstr.nocolor); - } else { - pm_asprintf(&str, "%s%s-%s %s[%s]%s", alpm_pkg_get_name(target->remove), config->colstr.faint, - alpm_pkg_get_version(target->remove), config->colstr.nocolor, _("removal"), config->colstr.nocolor); + remove = alpm_list_add(remove, str); } - names = alpm_list_add(names, str); }
- /* print to screen */ - pm_asprintf(&str, "%s (%zu)", _("Packages"), alpm_list_count(targets)); - printf("\n"); - cols = getcols(); if(verbose) { header = create_verbose_header(alpm_list_count(targets)); if(table_display(header, rows, cols) != 0) { /* fallback to list display if table wouldn't fit */ - list_display(str, names, cols); + if (alpm_list_count(install)) { + pm_asprintf(&install_header, _("Installing (%lu):"), alpm_list_count(install)); + list_display(install_header, install, cols); + } + if (alpm_list_count(upgrade)) { + pm_asprintf(&upgrade_header, _("Upgrading (%lu):"), alpm_list_count(upgrade)); + list_display(upgrade_header, upgrade, cols); + } + if (alpm_list_count(remove)) { + pm_asprintf(&remove_header, _("Removing (%lu):"), alpm_list_count(remove)); + list_display(remove_header, remove, cols); + } } } else { - list_display(str, names, cols); + if (alpm_list_count(install)) { + pm_asprintf(&install_header, _("Installing (%lu):"), alpm_list_count(install)); + list_display(install_header, install, cols); + if (alpm_list_count(upgrade) || alpm_list_count(remove)) { + printf("\n"); + } + } + if (alpm_list_count(upgrade)) { + pm_asprintf(&upgrade_header, _("Upgrading (%lu):"), alpm_list_count(upgrade)); + list_display(upgrade_header, upgrade, cols); + if (alpm_list_count(remove)) { + printf("\n"); + } + } + if (alpm_list_count(remove)) { + pm_asprintf(&remove_header, _("Removing (%lu):"), alpm_list_count(remove)); + list_display(remove_header, remove, cols); + } } printf("\n");
table_free(header, rows); - FREELIST(names); - free(str); + FREELIST(install); + FREELIST(upgrade); + FREELIST(remove); + free(install_header); + free(upgrade_header); + free(remove_header); rows = NULL;
if(dlsize > 0 || config->op_s_downloadonly) {
On 18/4/20 8:57 am, Carson Black wrote:
Thanks for pointing that out; addressed compiler warnings.
Please don't use a cover letter email. Just edit the patch and put comments under the "---" line. Also, adjust the subject to include "v2" for revised patches. Allan
Sorry, my bad. Still not the most used to submitting patches with git send-email. WIll do. -- Carson Black [ jan Pontaoski ] Am Fr., 17. Apr. 2020 um 21:34 Uhr schrieb Allan McRae <allan@archlinux.org>:
On 18/4/20 8:57 am, Carson Black wrote:
Thanks for pointing that out; addressed compiler warnings.
Please don't use a cover letter email. Just edit the patch and put comments under the "---" line.
Also, adjust the subject to include "v2" for revised patches.
Allan
On 4/17/20 6:22 PM, Carson Black wrote:
This asciicast demonstrates the output of this patch: https://asciinema.org/a/321160
Can you use LC_ALL=C for stuff like this? For much the same reason the patch commit message itself is in English -- if this context helps us see live what the patch does, and we want to understand it, English is the generally accepted way to do it. -- Eli Schwartz Bug Wrangler and Trusted User
Sure, I'll keep that in mind for the future. -- Carson Black [ jan Pontaoski ] Am Fr., 17. Apr. 2020 um 18:33 Uhr schrieb Eli Schwartz <eschwartz@archlinux.org>:
On 4/17/20 6:22 PM, Carson Black wrote:
This asciicast demonstrates the output of this patch: https://asciinema.org/a/321160
Can you use LC_ALL=C for stuff like this? For much the same reason the patch commit message itself is in English -- if this context helps us see live what the patch does, and we want to understand it, English is the generally accepted way to do it.
-- Eli Schwartz Bug Wrangler and Trusted User
participants (4)
-
Allan McRae
-
Andrew Gregory
-
Carson Black
-
Eli Schwartz