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 56773138334 for ; Thu, 2 Jan 2020 14:07:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E732DE0A53; Thu, 2 Jan 2020 14:07:07 +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 CA050E0A65 for ; Thu, 2 Jan 2020 14:07:07 +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 AB9B534DE5D for ; Thu, 2 Jan 2020 14:07:06 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 396F37B for ; Thu, 2 Jan 2020 14:07:04 +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: <1577969374.2e8bca1ee3fd0a3cf9c489a1b661245d20f808af.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: 2e8bca1ee3fd0a3cf9c489a1b661245d20f808af X-VCS-Branch: master Date: Thu, 2 Jan 2020 14:07:04 +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: 20d1c1ee-2e2a-4aaa-89f4-870157cf4f8f X-Archives-Hash: 539946b58fbecad878edfcfd6e1a0b10 commit: 2e8bca1ee3fd0a3cf9c489a1b661245d20f808af Author: Fabian Groffen gentoo org> AuthorDate: Thu Jan 2 12:49:34 2020 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Thu Jan 2 12:49:34 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2e8bca1e qcheck: pass package atoms down to tree_foreach_pkg Signed-off-by: Fabian Groffen gentoo.org> qcheck.c | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/qcheck.c b/qcheck.c index 66a4ee7..e8db1b8 100644 --- a/qcheck.c +++ b/qcheck.c @@ -70,8 +70,9 @@ struct qcheck_opt_state { }; static int -qcheck_process_contents(tree_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state) +qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv) { + struct qcheck_opt_state *state = priv; FILE *fp_contents, *fp_contents_update; size_t num_files, num_files_ok, num_files_unknown, num_files_ignored; char *buffer, *line; @@ -334,7 +335,7 @@ qcheck_process_contents(tree_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state) printf("%s\n", atom_format(state->fmt, atom)); qcprintf(" %2$s*%1$s %3$s%4$zu%1$s out of %3$s%5$zu%1$s file%6$s are good", NORM, BOLD, BLUE, num_files_ok, num_files, - (num_files > 1 ? "s" : "")); + (num_files != 1 ? "s" : "")); if (num_files_unknown) qcprintf(" (Unable to digest %2$s%3$zu%1$s file%4$s)", NORM, BLUE, num_files_unknown, @@ -351,32 +352,6 @@ qcheck_process_contents(tree_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state) return EXIT_SUCCESS; } -static int -qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv) -{ - struct qcheck_opt_state *state = priv; - bool showit = false; - - /* see if this cat/pkg is requested */ - if (array_cnt(state->atoms)) { - size_t i; - depend_atom *qatom; - depend_atom *atom; - - qatom = tree_get_atom(pkg_ctx, false); - array_for_each(state->atoms, i, atom) { - if (atom_compare(qatom, atom) == EQUAL) { - showit = true; - break; - } - } - } else { - showit = true; - } - - return showit ? qcheck_process_contents(pkg_ctx, priv) : 0; -} - int qcheck_main(int argc, char **argv) { size_t i; @@ -434,7 +409,13 @@ int qcheck_main(int argc, char **argv) vdb = tree_open_vdb(portroot, portvdb); ret = -1; if (vdb != NULL) { - ret = tree_foreach_pkg_sorted(vdb, qcheck_cb, &state, NULL); + if (array_cnt(atoms) != 0) { + array_for_each(atoms, i, atom) { + ret |= tree_foreach_pkg_sorted(vdb, qcheck_cb, &state, atom); + } + } else { + ret = tree_foreach_pkg_sorted(vdb, qcheck_cb, &state, NULL); + } tree_close(vdb); } if (array_cnt(regex_arr) > 0) {