From 080334da8bfe74fc0139388e7afb5208b29757da Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 27 Jan 2011 14:45:40 +0100 Subject: [PATCH] xbps-bin: make 'list' target without arguments to only show pkgs in "installed" state. --- bin/xbps-bin/main.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/bin/xbps-bin/main.c b/bin/xbps-bin/main.c index e5ca66d9..a84009a4 100644 --- a/bin/xbps-bin/main.c +++ b/bin/xbps-bin/main.c @@ -58,18 +58,21 @@ list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done) struct list_pkgver_cb *lpc = arg; const char *pkgver, *short_desc; char *tmp = NULL; - pkg_state_t curstate, *wantstate = &lpc->state; + pkg_state_t curstate; size_t i = 0; (void)loop_done; - assert(prop_object_type(obj) == PROP_TYPE_DICTIONARY); + if (xbps_get_pkg_state_dictionary(obj, &curstate)) + return EINVAL; - if (wantstate && *wantstate != 0) { - if (xbps_get_pkg_state_dictionary(obj, &curstate)) - return EINVAL; - - if (curstate != *wantstate) + if (lpc->state == 0) { + /* Only list packages that are fully installed */ + if (curstate != XBPS_PKG_STATE_INSTALLED) + return 0; + } else { + /* Only list packages with specified state */ + if (curstate != lpc->state) return 0; }