1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-15 04:33:08 +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,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));
}