From b0c29c4d7a26db7e37b343a757a215a1b3eb8754 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sun, 21 Nov 2010 22:50:42 -0300 Subject: [PATCH] qpkg: improve "qpkg ... list" - qpkg.c (list_all_packages): jrb indicates end-of-tree with pointer to jrb_nil(), not NULL - qpkg.c (list_all_packages, list_one_package): use ID2PF - qpkg.c (list_all_packages): iterate over versions --- qpkg/qpkg.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/qpkg/qpkg.c b/qpkg/qpkg.c index 76d6834..a4799b7 100644 --- a/qpkg/qpkg.c +++ b/qpkg/qpkg.c @@ -32,22 +32,24 @@ int debug = 0; static void list_all_packages(void) { const struct jrb *n; + const struct pkg *pkg; - for (n = jrb_first(packages->root); n; n = jrb_next(n)) { + for (n = jrb_first(packages->root); n != jrb_nil(packages->root); + n = jrb_next(n)) { const struct id *id = n->key; - struct pkg *pkg = n->val; - printf("%.*s", (int) id->len, id->s); - if (!pkg) - printf(" (virtual)"); - else { - if (pkg->version) - printf(" (%.*s)", - (int) pkg->version->len, pkg->version->s); - if (pkg->more) - printf(" +++"); + for (pkg = n->val; pkg; pkg = pkg->more) { + printf("%.*s", ID2PF(id)); + if (!pkg) + printf(" (virtual)"); + else { + if (pkg->version) + printf(" (%.*s)", ID2PF(pkg->version)); + if (pkg->more) + printf(" +++"); + } + printf("\n"); } - printf("\n"); } } @@ -62,7 +64,7 @@ static void list_one_package(const char *name) exit(1); } for (pkg = n->val; pkg; pkg = pkg->more) - printf("%.*s\n", (int) pkg->version->len, pkg->version->s); + printf("%.*s\n", ID2PF(pkg->version)); }