1 |
commit: d0d205c64d76c416eb83422828e30aea544f4591 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jan 2 13:34:16 2020 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jan 2 13:34:16 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d0d205c6 |
7 |
|
8 |
qsize: push query atoms down to tree_foreach_pkg |
9 |
|
10 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
11 |
|
12 |
qsize.c | 24 +++++++----------------- |
13 |
1 file changed, 7 insertions(+), 17 deletions(-) |
14 |
|
15 |
diff --git a/qsize.c b/qsize.c |
16 |
index 1f1dfc9..5cf7dae 100644 |
17 |
--- a/qsize.c |
18 |
+++ b/qsize.c |
19 |
@@ -109,22 +109,6 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv) |
20 |
FILE *fp; |
21 |
size_t num_files, num_nonfiles, num_ignored; |
22 |
uint64_t num_bytes; |
23 |
- bool showit = false; |
24 |
- |
25 |
- /* see if this cat/pkg is requested */ |
26 |
- if (array_cnt(state->atoms)) { |
27 |
- depend_atom *qatom; |
28 |
- |
29 |
- qatom = tree_get_atom(pkg_ctx, 0); |
30 |
- array_for_each(state->atoms, i, atom) |
31 |
- if (atom_compare(qatom, atom) == EQUAL) { |
32 |
- showit = true; |
33 |
- break; |
34 |
- } |
35 |
- } else |
36 |
- showit = true; |
37 |
- if (!showit) |
38 |
- return EXIT_SUCCESS; |
39 |
|
40 |
if ((fp = tree_pkg_vdb_fopenat_ro(pkg_ctx, "CONTENTS")) == NULL) |
41 |
return EXIT_SUCCESS; |
42 |
@@ -248,7 +232,13 @@ int qsize_main(int argc, char **argv) |
43 |
|
44 |
vdb = tree_open_vdb(portroot, portvdb); |
45 |
if (vdb != NULL) { |
46 |
- ret = tree_foreach_pkg_fast(vdb, qsize_cb, &state, NULL); |
47 |
+ if (array_cnt(atoms) > 0) { |
48 |
+ array_for_each(atoms, i, atom) { |
49 |
+ ret = tree_foreach_pkg_fast(vdb, qsize_cb, &state, atom); |
50 |
+ } |
51 |
+ } else { |
52 |
+ ret = tree_foreach_pkg_fast(vdb, qsize_cb, &state, NULL); |
53 |
+ } |
54 |
tree_close(vdb); |
55 |
} |