From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D44E0138336 for ; Sat, 11 May 2019 07:14:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 90BCAE087B; Sat, 11 May 2019 07:14:52 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 62DD9E087B for ; Sat, 11 May 2019 07:14:52 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8898234400C for ; Sat, 11 May 2019 07:14:50 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id DFEFA5E1 for ; Sat, 11 May 2019 07:14:48 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1557512518.569ce6581ce8823e9a827d22a2326351017835c0.grobian@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: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 569ce6581ce8823e9a827d22a2326351017835c0 X-VCS-Branch: master Date: Sat, 11 May 2019 07:14:48 +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-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 7f484d70-8ca6-451f-a1c7-9f9979cb92fb X-Archives-Hash: 0e751a507dec9dc6f1df820dbc6e6e6a commit: 569ce6581ce8823e9a827d22a2326351017835c0 Author: Fabian Groffen gentoo org> AuthorDate: Fri May 10 18:21:58 2019 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Fri May 10 18:21:58 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=569ce658 qlist: use tree_get_atom where possible Signed-off-by: Fabian Groffen gentoo.org> qlist.c | 52 ++++++++++++++-------------------------------------- 1 file changed, 14 insertions(+), 38 deletions(-) diff --git a/qlist.c b/qlist.c index abefbcf..32c87b4 100644 --- a/qlist.c +++ b/qlist.c @@ -193,24 +193,19 @@ qlist_match( const char *urepo; size_t urepo_len = 0; depend_atom *atom; + depend_atom *_atom = NULL; uslot = strchr(name, ':'); - if (uslot) { + if (uslot != NULL) { if (*++uslot == ':') uslot = NULL; else { - if (!pkg_ctx->slot) - tree_pkg_vdb_eat(pkg_ctx, "SLOT", &pkg_ctx->slot, - &pkg_ctx->slot_len); uslot_len = strlen(uslot); } } urepo = strstr(name, "::"); - if (urepo) { - if (!pkg_ctx->repo) - tree_pkg_vdb_eat(pkg_ctx, "repository", &pkg_ctx->repo, - &pkg_ctx->repo_len); + if (urepo != NULL) { urepo += 2; urepo_len = strlen(urepo); @@ -224,28 +219,18 @@ qlist_match( case '>': case '<': case '~': - snprintf(buf, sizeof(buf), "%s/%s%c%s%s%s", catname, pkgname, - pkg_ctx->slot ? ':' : '\0', pkg_ctx->slot ? : "", - pkg_ctx->repo ? "::" : "", pkg_ctx->repo ? : ""); - if ((atom = atom_explode(buf)) == NULL) { - warn("invalid atom %s", buf); - return false; - } + atom = tree_get_atom(pkg_ctx, uslot != NULL || urepo != NULL); - depend_atom *_atom = NULL; if (!name_atom) name_atom = &_atom; if (!*name_atom) { if ((*name_atom = atom_explode(name)) == NULL) { - atom_implode(atom); warn("invalid atom %s", name); return false; } } - bool ret = atom_compare(atom, *name_atom) == EQUAL; - atom_implode(atom); - return ret; + return atom_compare(atom, *name_atom) == EQUAL; } if (uslot) { @@ -277,10 +262,7 @@ qlist_match( return true; /* let's try exact matching w/out the PV */ - if ((atom = atom_explode(buf)) == NULL) { - warn("invalid atom %s", buf); - return false; - } + atom = tree_get_atom(pkg_ctx, uslot != NULL || urepo != NULL); i = snprintf(swap, sizeof(swap), "%s/%s", atom->CATEGORY, atom->PN); if (uslot && i <= (int)sizeof(swap)) @@ -288,7 +270,6 @@ qlist_match( if (urepo && i <= (int)sizeof(swap)) i += snprintf(swap + i, sizeof(swap) - i, "::%s", atom->REPO); - atom_implode(atom); /* exact match: CAT/PN[:SLOT][::REPO] */ if (strcmp(name, swap) == 0) return true; @@ -345,6 +326,7 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv) FILE *fp; const char *catname = pkg_ctx->cat_ctx->name; const char *pkgname = pkg_ctx->name; + depend_atom *atom; /* see if this cat/pkg is requested */ for (i = optind; i < state->argc; ++i) @@ -354,23 +336,19 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv) if ((i == state->argc) && (state->argc != optind)) return 0; + atom = tree_get_atom(pkg_ctx, false); if (state->just_pkgname) { - depend_atom *atom; - atom = (verbose ? NULL : atom_explode(pkgname)); if ((state->all + state->just_pkgname) < 2) { + atom = tree_get_atom(pkg_ctx, + state->show_slots || state->show_repo); if (state->show_slots && !pkg_ctx->slot) { - tree_pkg_vdb_eat(pkg_ctx, "SLOT", - &pkg_ctx->slot, &pkg_ctx->slot_len); /* chop off the subslot if desired */ - if (state->show_slots == 1) { + if (state->show_slots == 1 && pkg_ctx->slot != NULL) { char *s = strchr(pkg_ctx->slot, '/'); if (s) *s = '\0'; } } - if (state->show_repo && !pkg_ctx->repo) - tree_pkg_vdb_eat(pkg_ctx, "repository", - &pkg_ctx->repo, &pkg_ctx->repo_len); /* display it */ printf("%s%s/%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", BOLD, catname, BLUE, @@ -387,16 +365,14 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv) NORM, umapstr(state->show_umap, pkg_ctx)); } - if (atom) - atom_implode(atom); if (!state->all) return 1; } if (verbose) - printf("%s%s/%s%s%s %sCONTENTS%s:\n", - BOLD, catname, BLUE, pkgname, NORM, DKBLUE, NORM); + printf("%s %sCONTENTS%s:\n", + atom_format("%[CATEGORY]%[PF]", atom, 0), DKBLUE, NORM); fp = tree_pkg_vdb_fopenat_ro(pkg_ctx, "CONTENTS"); if (fp == NULL) @@ -423,7 +399,7 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv) break; case CONTENTS_OBJ: if (state->show_obj) - printf("%s%s%s\n", WHITE, e->name, NORM); + printf("%s%s%s\n", DKGREEN, e->name, NORM); break; case CONTENTS_SYM: if (state->show_sym) {