Signed-off-by: Benedikt Morbach <benedikt.morbach@googlemail.com> --- src/pacman/query.c | 11 ++++++++++- src/pacman/util.c | 23 ++++++++++++++++++----- src/pacman/util.h | 1 + 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/pacman/query.c b/src/pacman/query.c index 8523e23..757afde 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -488,7 +488,16 @@ static int display(alpm_pkg_t *pkg) if(!config->op_q_info && !config->op_q_list && !config->op_q_changelog && !config->op_q_check) { if(!config->quiet) { - printf("%s %s\n", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg)); + printf("%s %s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg)); + + alpm_list_t *optrequires; + if(config->op_q_unrequired && config->op_q_optdeps && + (optrequires = alpm_pkg_compute_requiredby(pkg, 1)) != NULL) { + list_display_extra(_(" (optdepend for:"), optrequires, ", ", ")"); + FREELIST(optrequires); + } else { + printf("\n"); + } } else { printf("%s\n", alpm_pkg_get_name(pkg)); } diff --git a/src/pacman/util.c b/src/pacman/util.c index 1c534e3..5318142 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -600,16 +600,24 @@ int table_display(const char *title, const alpm_list_t *header, void list_display(const char *title, const alpm_list_t *list) { + list_display_extra(title, list, NULL, NULL); +} + +void list_display_extra(const char *title, const alpm_list_t *list, + const char *delim, const char *after) +{ const alpm_list_t *i; int len = 0; + delim = delim ? delim : " "; + if(title) { len = string_length(title) + 1; printf("%s ", title); } if(!list) { - printf("%s\n", _("None")); + printf("%s", _("None")); } else { const int maxcols = getcols(); int cols = len; @@ -628,15 +636,20 @@ void list_display(const char *title, const alpm_list_t *list) printf(" "); } } else if(cols != len) { - /* 2 spaces are added if this is not the first element on a line. */ - printf(" "); - cols += 2; + /* delimiter is added if this is not the first element on a line. */ + printf("%s", delim); + cols += strlen(delim); } printf("%s", str); cols += s; } - printf("\n"); } + + if(after) { + printf("%s", after); + } + + printf("\n"); } void list_display_linebreak(const char *title, const alpm_list_t *list) diff --git a/src/pacman/util.h b/src/pacman/util.h index 01d2211..0eac77a 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -57,6 +57,7 @@ void string_display(const char *title, const char *string); double humanize_size(off_t bytes, const char target_unit, const char **label); int table_display(const char *title, const alpm_list_t *header, const alpm_list_t *rows); void list_display(const char *title, const alpm_list_t *list); +void list_display_extra(const char *title, const alpm_list_t *list, const char *delim, const char *after); void list_display_linebreak(const char *title, const alpm_list_t *list); void signature_display(const char *title, alpm_siglist_t *siglist); void display_targets(const alpm_list_t *pkgs, int install); -- 1.7.6.1