From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 7AC3F1393EA for ; Sun, 16 Mar 2014 06:14:54 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D7EF5E0A9A; Sun, 16 Mar 2014 06:14:53 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 44A5DE0A9A for ; Sun, 16 Mar 2014 06:14:53 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4848833FB83 for ; Sun, 16 Mar 2014 06:14:52 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id CFCE0188EB for ; Sun, 16 Mar 2014 06:14:50 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1394950152.f09d626416e60d9f87dc1aaf8bb59e1638b483e0.vapier@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qlist.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: f09d626416e60d9f87dc1aaf8bb59e1638b483e0 X-VCS-Branch: master Date: Sun, 16 Mar 2014 06:14:50 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 5afda094-ccb9-435e-b615-249bc56fc378 X-Archives-Hash: d9192ae4d85139857533bedb01057538 commit: f09d626416e60d9f87dc1aaf8bb59e1638b483e0 Author: Mike Frysinger gentoo org> AuthorDate: Sun Mar 16 06:09:12 2014 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sun Mar 16 06:09:12 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=f09d6264 qlist: rewrite -U option to leverage q_vdb_pkg_eat This lets us kill off most consumers of grab_vdb_item and use the new vdb API which in turn makes the code cleaner and robust -- it can handle any sized input file now and leverages the openat helpers. --- qlist.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/qlist.c b/qlist.c index fa5e652..0ffa716 100644 --- a/qlist.c +++ b/qlist.c @@ -42,39 +42,40 @@ static const char * const qlist_opts_help[] = { }; #define qlist_usage(ret) usage(ret, QLIST_FLAGS, qlist_long_opts, qlist_opts_help, lookup_applet_idx("qlist")) -static char *grab_pkg_umap(const char *CAT, const char *PV) +static char *grab_pkg_umap(q_vdb_pkg_ctx *pkg_ctx) { static char umap[BUFSIZ]; - char *use = NULL; - char *iuse = NULL; + static char *use, *iuse; + static size_t use_len, iuse_len; int use_argc = 0, iuse_argc = 0; char **use_argv = NULL, **iuse_argv = NULL; queue *ll = NULL; queue *sets = NULL; int i, u; - if ((use = grab_vdb_item("USE", CAT, PV)) == NULL) + q_vdb_pkg_eat(pkg_ctx, "USE", &use, &use_len); + if (!use[0]) + return NULL; + q_vdb_pkg_eat(pkg_ctx, "IUSE", &iuse, &iuse_len); + if (!iuse[0]) return NULL; umap[0] = '\0'; /* reset the buffer */ - /* grab_vdb is a static function so save it to memory right away */ makeargv(use, &use_argc, &use_argv); - if ((iuse = grab_vdb_item("IUSE", CAT, PV)) != NULL) { - for (i = 0; i < (int)strlen(iuse); i++) - if (iuse[i] == '+' || iuse[i] == '-') - iuse[i] = ' '; - makeargv(iuse, &iuse_argc, &iuse_argv); - for (u = 1; u < use_argc; u++) { - for (i = 1; i < iuse_argc; i++) { - if (strcmp(use_argv[u], iuse_argv[i]) == 0) { - strncat(umap, use_argv[u], sizeof(umap)-strlen(umap)-1); - strncat(umap, " ", sizeof(umap)-strlen(umap)-1); - } + for (i = 0; i < (int)strlen(iuse); i++) + if (iuse[i] == '+' || iuse[i] == '-') + iuse[i] = ' '; + makeargv(iuse, &iuse_argc, &iuse_argv); + for (u = 1; u < use_argc; u++) { + for (i = 1; i < iuse_argc; i++) { + if (strcmp(use_argv[u], iuse_argv[i]) == 0) { + strncat(umap, use_argv[u], sizeof(umap)-strlen(umap)-1); + strncat(umap, " ", sizeof(umap)-strlen(umap)-1); } } - freeargv(iuse_argc, iuse_argv); } + freeargv(iuse_argc, iuse_argv); freeargv(use_argc, use_argv); /* filter out the dup use flags */ @@ -97,7 +98,7 @@ static char *grab_pkg_umap(const char *CAT, const char *PV) return umap; } -static const char *umapstr(char display, const char *cat, const char *name) +static const char *umapstr(char display, q_vdb_pkg_ctx *pkg_ctx) { static char buf[BUFSIZ]; char *umap = NULL; @@ -105,7 +106,7 @@ static const char *umapstr(char display, const char *cat, const char *name) buf[0] = '\0'; if (!display) return buf; - if ((umap = grab_pkg_umap(cat, name)) == NULL) + if ((umap = grab_pkg_umap(pkg_ctx)) == NULL) return buf; rmspace(umap); if (!strlen(umap)) @@ -191,7 +192,6 @@ qlist_match(q_vdb_pkg_ctx *pkg_ctx, const char *name, depend_atom **name_atom, b return false; } - /* printf("buf=%s:%s\n", buf,grab_vdb_item("SLOT", catname, pkgname)); */ if (exact) { int i; @@ -296,7 +296,7 @@ _q_static int qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv) (state->columns ? " " : ""), (state->columns ? atom->PV : ""), NORM, YELLOW, state->show_slots ? ":" : "", state->show_slots ? pkg_ctx->slot : "", NORM, NORM, GREEN, state->show_repo ? "::" : "", state->show_repo ? pkg_ctx->repo : "", NORM, - umapstr(state->show_umap, catname, pkgname)); + umapstr(state->show_umap, pkg_ctx)); } if (atom) atom_implode(atom);