Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: /
Date: Thu, 02 Jan 2020 14:07:10
Message-Id: 1577969374.2e8bca1ee3fd0a3cf9c489a1b661245d20f808af.grobian@gentoo
1 commit: 2e8bca1ee3fd0a3cf9c489a1b661245d20f808af
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jan 2 12:49:34 2020 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Thu Jan 2 12:49:34 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2e8bca1e
7
8 qcheck: pass package atoms down to tree_foreach_pkg
9
10 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
11
12 qcheck.c | 39 ++++++++++-----------------------------
13 1 file changed, 10 insertions(+), 29 deletions(-)
14
15 diff --git a/qcheck.c b/qcheck.c
16 index 66a4ee7..e8db1b8 100644
17 --- a/qcheck.c
18 +++ b/qcheck.c
19 @@ -70,8 +70,9 @@ struct qcheck_opt_state {
20 };
21
22 static int
23 -qcheck_process_contents(tree_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
24 +qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
25 {
26 + struct qcheck_opt_state *state = priv;
27 FILE *fp_contents, *fp_contents_update;
28 size_t num_files, num_files_ok, num_files_unknown, num_files_ignored;
29 char *buffer, *line;
30 @@ -334,7 +335,7 @@ qcheck_process_contents(tree_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
31 printf("%s\n", atom_format(state->fmt, atom));
32 qcprintf(" %2$s*%1$s %3$s%4$zu%1$s out of %3$s%5$zu%1$s file%6$s are good",
33 NORM, BOLD, BLUE, num_files_ok, num_files,
34 - (num_files > 1 ? "s" : ""));
35 + (num_files != 1 ? "s" : ""));
36 if (num_files_unknown)
37 qcprintf(" (Unable to digest %2$s%3$zu%1$s file%4$s)",
38 NORM, BLUE, num_files_unknown,
39 @@ -351,32 +352,6 @@ qcheck_process_contents(tree_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
40 return EXIT_SUCCESS;
41 }
42
43 -static int
44 -qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
45 -{
46 - struct qcheck_opt_state *state = priv;
47 - bool showit = false;
48 -
49 - /* see if this cat/pkg is requested */
50 - if (array_cnt(state->atoms)) {
51 - size_t i;
52 - depend_atom *qatom;
53 - depend_atom *atom;
54 -
55 - qatom = tree_get_atom(pkg_ctx, false);
56 - array_for_each(state->atoms, i, atom) {
57 - if (atom_compare(qatom, atom) == EQUAL) {
58 - showit = true;
59 - break;
60 - }
61 - }
62 - } else {
63 - showit = true;
64 - }
65 -
66 - return showit ? qcheck_process_contents(pkg_ctx, priv) : 0;
67 -}
68 -
69 int qcheck_main(int argc, char **argv)
70 {
71 size_t i;
72 @@ -434,7 +409,13 @@ int qcheck_main(int argc, char **argv)
73 vdb = tree_open_vdb(portroot, portvdb);
74 ret = -1;
75 if (vdb != NULL) {
76 - ret = tree_foreach_pkg_sorted(vdb, qcheck_cb, &state, NULL);
77 + if (array_cnt(atoms) != 0) {
78 + array_for_each(atoms, i, atom) {
79 + ret |= tree_foreach_pkg_sorted(vdb, qcheck_cb, &state, atom);
80 + }
81 + } else {
82 + ret = tree_foreach_pkg_sorted(vdb, qcheck_cb, &state, NULL);
83 + }
84 tree_close(vdb);
85 }
86 if (array_cnt(regex_arr) > 0) {