---
 src/pacman/package.c |    5 +----
 src/pacman/util.c    |   15 ++++++++++++---
 src/pacman/util.h    |    2 +-
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/pacman/package.c b/src/pacman/package.c
index 6e6d379..3e882ef 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -88,10 +88,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, enum pkg_from from, int 
extra)
        }
 
        /* turn optdepends list into a text list */
-       for(i = alpm_pkg_get_optdepends(pkg); i; i = alpm_list_next(i)) {
-               alpm_optdepend_t *optdep = (alpm_optdepend_t 
*)alpm_list_getdata(i);
-               optstrings = alpm_list_add(optstrings, 
alpm_optdep_compute_string(optdep));
-       }
+       optstrings = optdep_string_list(alpm_pkg_get_optdepends(pkg), 1);
 
        if(extra || from == PKG_FROM_LOCALDB) {
                /* compute this here so we don't get a pause in the middle of 
output */
diff --git a/src/pacman/util.c b/src/pacman/util.c
index d3a5648..88b7872 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -996,7 +996,7 @@ void display_new_optdepends(alpm_pkg_t *oldpkg, alpm_pkg_t 
*newpkg)
        new = alpm_pkg_get_optdepends(newpkg);
        optdeps = alpm_list_diff(new,old,opt_cmp);
 
-       optstrings = optdep_string_list(optdeps);
+       optstrings = optdep_string_list(optdeps, 0);
 
        if(optstrings) {
                printf(_("New optional dependencies for %s\n"), 
alpm_pkg_get_name(newpkg));
@@ -1012,7 +1012,7 @@ void display_optdepends(alpm_pkg_t *pkg)
        alpm_list_t *optdeps, *optstrings;
 
        optdeps = alpm_pkg_get_optdepends(pkg);
-       optstrings = optdep_string_list(optdeps);
+       optstrings = optdep_string_list(optdeps, 0);
 
        if(optstrings) {
                printf(_("Optional dependencies for %s\n"), 
alpm_pkg_get_name(pkg));
@@ -1027,7 +1027,7 @@ void display_optdepends(alpm_pkg_t *pkg)
  * the returned list has to be freed!
  */
 
-alpm_list_t *optdep_string_list(const alpm_list_t *optlist)
+alpm_list_t *optdep_string_list(const alpm_list_t *optlist, const int 
include_installed)
 {
        alpm_list_t *optstrings = NULL;
        alpm_optdepend_t *optdep;
@@ -1040,6 +1040,15 @@ alpm_list_t *optdep_string_list(const alpm_list_t 
*optlist)
                optdep = (alpm_optdepend_t *)alpm_list_getdata(optlist);
                if(alpm_db_get_pkg(db_local, optdep->depend->name) == NULL) {
                        optstrings = alpm_list_add(optstrings, 
alpm_optdep_compute_string(optdep));
+               } else if (include_installed) {
+                       char *str, *tmp;
+                       tmp = alpm_optdep_compute_string(optdep);
+                       if ((str = realloc(tmp, strlen(tmp) + 13)) != NULL) {
+                               strcpy(str + strlen(str), " [installed]");
+                               optstrings = alpm_list_add(optstrings, str);
+                       } else {
+                               free(tmp);
+                       }
                }
        }
 
diff --git a/src/pacman/util.h b/src/pacman/util.h
index ed7c01f..f2fca85 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -62,7 +62,7 @@ void display_targets(const alpm_list_t *pkgs, int install);
 int str_cmp(const void *s1, const void *s2);
 void display_new_optdepends(alpm_pkg_t *oldpkg, alpm_pkg_t *newpkg);
 void display_optdepends(alpm_pkg_t *pkg);
-alpm_list_t *optdep_string_list(const alpm_list_t *optdeps);
+alpm_list_t *optdep_string_list(const alpm_list_t *optdeps, const int 
include_installed);
 void print_packages(const alpm_list_t *packages);
 void select_display(const alpm_list_t *pkglist);
 int select_question(int count);
-- 
1.7.6


Reply via email to