xbps-alternatives: fix -l.

This commit is contained in:
Juan RP 2015-10-30 13:37:24 +01:00
parent 35718e676c
commit 802158e324

View File

@ -72,7 +72,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbd _unused)
} }
static void static void
list_pkg_alternatives(xbps_dictionary_t pkgd, bool print_key) list_pkg_alternatives(xbps_dictionary_t pkgd, const char *group, bool print_key)
{ {
xbps_dictionary_t pkg_alternatives; xbps_dictionary_t pkg_alternatives;
xbps_array_t allkeys; xbps_array_t allkeys;
@ -91,6 +91,9 @@ list_pkg_alternatives(xbps_dictionary_t pkgd, bool print_key)
keyname = xbps_dictionary_keysym_cstring_nocopy(keysym); keyname = xbps_dictionary_keysym_cstring_nocopy(keysym);
array = xbps_dictionary_get_keysym(pkg_alternatives, keysym); array = xbps_dictionary_get_keysym(pkg_alternatives, keysym);
if (group && strcmp(group, keyname))
continue;
if (print_key) if (print_key)
printf("%s\n", keyname); printf("%s\n", keyname);
@ -117,7 +120,7 @@ list_alternatives(struct xbps_handle *xhp, const char *pkgname)
if ((pkgd = xbps_pkgdb_get_pkg(xhp, pkgname)) == NULL) if ((pkgd = xbps_pkgdb_get_pkg(xhp, pkgname)) == NULL)
return ENOENT; return ENOENT;
list_pkg_alternatives(pkgd, true); list_pkg_alternatives(pkgd, NULL, true);
return 0; return 0;
} }
assert(xhp->pkgdb); assert(xhp->pkgdb);
@ -144,7 +147,7 @@ list_alternatives(struct xbps_handle *xhp, const char *pkgname)
printf(" - %s%s\n", str, x == 0 ? " (current)" : ""); printf(" - %s%s\n", str, x == 0 ? " (current)" : "");
pkgd = xbps_pkgdb_get_pkg(xhp, str); pkgd = xbps_pkgdb_get_pkg(xhp, str);
assert(pkgd); assert(pkgd);
list_pkg_alternatives(pkgd, false); list_pkg_alternatives(pkgd, keyname, false);
} }
} }
xbps_object_release(allkeys); xbps_object_release(allkeys);