From 1cef52795c44bb41db5afa220f423993478d8d83 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Tue, 30 Apr 2013 09:57:44 -0400 Subject: support optdepends as alpm_depend_t Fixes FS#35035. --- expac.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/expac.c b/expac.c index c971bb1..75bb7aa 100644 --- a/expac.c +++ b/expac.c @@ -137,15 +137,23 @@ static char *strtrim(char *str) { return str; } -static char *trim_optdep(char *optdep) { +static char *format_optdep(alpm_depend_t *optdep) { + char *out; + + asprintf(&out, "%s: %s", optdep->name, optdep->desc); + + return out; +} + +static char *trim_optdep(alpm_depend_t *optdep) { char *colon; - colon = strchr(optdep, ':'); + colon = strchr(optdep->name, ':'); if (colon) { *colon = '\0'; } - return optdep; + return optdep->name; } static alpm_handle_t *alpm_init(void) { @@ -567,7 +575,7 @@ static int print_pkg(alpm_pkg_t *pkg, const char *format) { out += print_list(alpm_pkg_get_depends(pkg), (extractfn)alpm_dep_compute_string, shortdeps); break; case 'O': /* optdepends */ - out += print_list(alpm_pkg_get_optdepends(pkg), NULL, shortdeps); + out += print_list(alpm_pkg_get_optdepends(pkg), (extractfn)format_optdep, shortdeps); break; case 'o': /* optdepends (shortdeps) */ out += print_list(alpm_pkg_get_optdepends(pkg), (extractfn)trim_optdep, shortdeps); -- cgit v1.2.3-70-g09d2