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 ef10220..f35729a 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -487,7 +487,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_nooptdeps && + (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 f633241..ba23356 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -597,16 +597,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; @@ -625,15 +633,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 ff1cec3..8daddbc 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -56,6 +56,7 @@ void string_display(const char *title, const char *string); double humanize_size(off_t bytes, const char target_unit, int long_labels, 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_sigresult_t *result); void display_targets(const alpm_list_t *pkgs, int install); -- 1.7.6