1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-15 09:10:38 +02:00

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
This commit is contained in:
Werner Almesberger 2010-11-21 22:50:42 -03:00
parent dd8bb6eecd
commit b0c29c4d7a

View File

@ -32,24 +32,26 @@ int debug = 0;
static void list_all_packages(void) static void list_all_packages(void)
{ {
const struct jrb *n; 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; const struct id *id = n->key;
struct pkg *pkg = n->val;
printf("%.*s", (int) id->len, id->s); for (pkg = n->val; pkg; pkg = pkg->more) {
printf("%.*s", ID2PF(id));
if (!pkg) if (!pkg)
printf(" (virtual)"); printf(" (virtual)");
else { else {
if (pkg->version) if (pkg->version)
printf(" (%.*s)", printf(" (%.*s)", ID2PF(pkg->version));
(int) pkg->version->len, pkg->version->s);
if (pkg->more) if (pkg->more)
printf(" +++"); printf(" +++");
} }
printf("\n"); printf("\n");
} }
} }
}
static void list_one_package(const char *name) static void list_one_package(const char *name)
@ -62,7 +64,7 @@ static void list_one_package(const char *name)
exit(1); exit(1);
} }
for (pkg = n->val; pkg; pkg = pkg->more) for (pkg = n->val; pkg; pkg = pkg->more)
printf("%.*s\n", (int) pkg->version->len, pkg->version->s); printf("%.*s\n", ID2PF(pkg->version));
} }