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 43DB2138335 for ; Tue, 7 May 2019 06:19:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 28BB1E08D9; Tue, 7 May 2019 06:19:55 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 00B44E08D9 for ; Tue, 7 May 2019 06:19:54 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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 29C983439D9 for ; Tue, 7 May 2019 06:19:53 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D21475D9 for ; Tue, 7 May 2019 06:19:50 +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: <1557165840.2615b1a350ac54af4bb0f31e8eb13fed9979b564.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qcheck.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 2615b1a350ac54af4bb0f31e8eb13fed9979b564 X-VCS-Branch: master Date: Tue, 7 May 2019 06:19: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-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: e26dd3fd-e425-4d65-a2e8-d30097ed41a5 X-Archives-Hash: 7278d45a7792fe03d13ca9aee6e6409c commit: 2615b1a350ac54af4bb0f31e8eb13fed9979b564 Author: Fabian Groffen gentoo org> AuthorDate: Mon May 6 18:04:00 2019 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Mon May 6 18:04:00 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2615b1a3 qcheck: use atom_format to unify atom representation Signed-off-by: Fabian Groffen gentoo.org> qcheck.c | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/qcheck.c b/qcheck.c index 377a187..68cdb30 100644 --- a/qcheck.c +++ b/qcheck.c @@ -69,14 +69,13 @@ qcheck_process_contents(vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state) { int fd_contents; FILE *fp_contents, *fp_contents_update; - const char *catname = pkg_ctx->cat_ctx->name; - const char *pkgname = pkg_ctx->name; size_t num_files, num_files_ok, num_files_unknown, num_files_ignored; char *buffer, *line; size_t linelen; struct stat st, cst; int cp_argc, cpm_argc; char **cp_argv, **cpm_argv; + depend_atom *atom; fp_contents_update = NULL; @@ -94,15 +93,16 @@ qcheck_process_contents(vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state) } /* Open contents_update, if needed */ + atom = vdb_get_atom(pkg_ctx, false); num_files = num_files_ok = num_files_unknown = num_files_ignored = 0; - qcprintf("%sing %s%s/%s%s ...\n", + qcprintf("%sing %s ...\n", (state->qc_update ? "Updat" : "Check"), - GREEN, catname, pkgname, NORM); + atom_format("%[CATEGORY]%[PF]", atom, 0)); if (state->qc_update) { fp_contents_update = vdb_pkg_fopenat_rw(pkg_ctx, "CONTENTS~"); if (fp_contents_update == NULL) { fclose(fp_contents); - warnp("unable to fopen(%s/%s, w)", pkgname, "CONTENTS~"); + warnp("unable to fopen(%s/%s, w)", atom->P, "CONTENTS~"); return EXIT_FAILURE; } } @@ -165,13 +165,14 @@ qcheck_process_contents(vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state) break; if (i == cpm_argc) { /* Not explicitly masked, so it's protected */ - for (i = 1; i < cp_argc; ++i) + for (i = 1; i < cp_argc; ++i) { if (strncmp(cp_argv[i], entry->name, strlen(cp_argv[i])) == 0) { num_files_ok++; continue; } + } } } @@ -329,18 +330,9 @@ qcheck_process_contents(vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state) } if (state->bad_only && num_files_ok != num_files) { if (verbose) - printf("%s/%s\n", catname, pkgname); + printf("%s\n", atom_format("%[CATEGORY]%[PF]", atom, 0)); else { - depend_atom *atom = NULL; - char *buf; - xasprintf(&buf, "%s/%s", catname, pkgname); - if ((atom = atom_explode(buf)) != NULL) { - printf("%s/%s\n", catname, atom->PN); - atom_implode(atom); - } else { - printf("%s/%s\n", catname, pkgname); - } - free(buf); + printf("%s\n", atom_format("%[CATEGORY]%[PN]", atom, 0)); } } qcprintf(" %2$s*%1$s %3$s%4$zu%1$s out of %3$s%5$zu%1$s file%6$s are good", @@ -366,27 +358,24 @@ static int qcheck_cb(vdb_pkg_ctx *pkg_ctx, void *priv) { struct qcheck_opt_state *state = priv; - const char *catname = pkg_ctx->cat_ctx->name; - const char *pkgname = pkg_ctx->name; bool showit = false; /* see if this cat/pkg is requested */ if (array_cnt(state->atoms)) { - char *buf; size_t i; - depend_atom *qatom, *atom; + depend_atom *qatom; + depend_atom *atom; - xasprintf(&buf, "%s/%s", catname, pkgname); - qatom = atom_explode(buf); - array_for_each(state->atoms, i, atom) + qatom = vdb_get_atom(pkg_ctx, false); + array_for_each(state->atoms, i, atom) { if (atom_compare(atom, qatom) == EQUAL) { showit = true; break; } - atom_implode(qatom); - free(buf); - } else + } + } else { showit = true; + } return showit ? qcheck_process_contents(pkg_ctx, priv) : 0; }