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: Tue, 07 May 2019 06:19:56
Message-Id: 1557165840.2615b1a350ac54af4bb0f31e8eb13fed9979b564.grobian@gentoo
1 commit: 2615b1a350ac54af4bb0f31e8eb13fed9979b564
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Mon May 6 18:04:00 2019 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Mon May 6 18:04:00 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2615b1a3
7
8 qcheck: use atom_format to unify atom representation
9
10 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
11
12 qcheck.c | 43 ++++++++++++++++---------------------------
13 1 file changed, 16 insertions(+), 27 deletions(-)
14
15 diff --git a/qcheck.c b/qcheck.c
16 index 377a187..68cdb30 100644
17 --- a/qcheck.c
18 +++ b/qcheck.c
19 @@ -69,14 +69,13 @@ qcheck_process_contents(vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
20 {
21 int fd_contents;
22 FILE *fp_contents, *fp_contents_update;
23 - const char *catname = pkg_ctx->cat_ctx->name;
24 - const char *pkgname = pkg_ctx->name;
25 size_t num_files, num_files_ok, num_files_unknown, num_files_ignored;
26 char *buffer, *line;
27 size_t linelen;
28 struct stat st, cst;
29 int cp_argc, cpm_argc;
30 char **cp_argv, **cpm_argv;
31 + depend_atom *atom;
32
33 fp_contents_update = NULL;
34
35 @@ -94,15 +93,16 @@ qcheck_process_contents(vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
36 }
37
38 /* Open contents_update, if needed */
39 + atom = vdb_get_atom(pkg_ctx, false);
40 num_files = num_files_ok = num_files_unknown = num_files_ignored = 0;
41 - qcprintf("%sing %s%s/%s%s ...\n",
42 + qcprintf("%sing %s ...\n",
43 (state->qc_update ? "Updat" : "Check"),
44 - GREEN, catname, pkgname, NORM);
45 + atom_format("%[CATEGORY]%[PF]", atom, 0));
46 if (state->qc_update) {
47 fp_contents_update = vdb_pkg_fopenat_rw(pkg_ctx, "CONTENTS~");
48 if (fp_contents_update == NULL) {
49 fclose(fp_contents);
50 - warnp("unable to fopen(%s/%s, w)", pkgname, "CONTENTS~");
51 + warnp("unable to fopen(%s/%s, w)", atom->P, "CONTENTS~");
52 return EXIT_FAILURE;
53 }
54 }
55 @@ -165,13 +165,14 @@ qcheck_process_contents(vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
56 break;
57 if (i == cpm_argc) {
58 /* Not explicitly masked, so it's protected */
59 - for (i = 1; i < cp_argc; ++i)
60 + for (i = 1; i < cp_argc; ++i) {
61 if (strncmp(cp_argv[i], entry->name,
62 strlen(cp_argv[i])) == 0)
63 {
64 num_files_ok++;
65 continue;
66 }
67 + }
68 }
69 }
70
71 @@ -329,18 +330,9 @@ qcheck_process_contents(vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
72 }
73 if (state->bad_only && num_files_ok != num_files) {
74 if (verbose)
75 - printf("%s/%s\n", catname, pkgname);
76 + printf("%s\n", atom_format("%[CATEGORY]%[PF]", atom, 0));
77 else {
78 - depend_atom *atom = NULL;
79 - char *buf;
80 - xasprintf(&buf, "%s/%s", catname, pkgname);
81 - if ((atom = atom_explode(buf)) != NULL) {
82 - printf("%s/%s\n", catname, atom->PN);
83 - atom_implode(atom);
84 - } else {
85 - printf("%s/%s\n", catname, pkgname);
86 - }
87 - free(buf);
88 + printf("%s\n", atom_format("%[CATEGORY]%[PN]", atom, 0));
89 }
90 }
91 qcprintf(" %2$s*%1$s %3$s%4$zu%1$s out of %3$s%5$zu%1$s file%6$s are good",
92 @@ -366,27 +358,24 @@ static int
93 qcheck_cb(vdb_pkg_ctx *pkg_ctx, void *priv)
94 {
95 struct qcheck_opt_state *state = priv;
96 - const char *catname = pkg_ctx->cat_ctx->name;
97 - const char *pkgname = pkg_ctx->name;
98 bool showit = false;
99
100 /* see if this cat/pkg is requested */
101 if (array_cnt(state->atoms)) {
102 - char *buf;
103 size_t i;
104 - depend_atom *qatom, *atom;
105 + depend_atom *qatom;
106 + depend_atom *atom;
107
108 - xasprintf(&buf, "%s/%s", catname, pkgname);
109 - qatom = atom_explode(buf);
110 - array_for_each(state->atoms, i, atom)
111 + qatom = vdb_get_atom(pkg_ctx, false);
112 + array_for_each(state->atoms, i, atom) {
113 if (atom_compare(atom, qatom) == EQUAL) {
114 showit = true;
115 break;
116 }
117 - atom_implode(qatom);
118 - free(buf);
119 - } else
120 + }
121 + } else {
122 showit = true;
123 + }
124
125 return showit ? qcheck_process_contents(pkg_ctx, priv) : 0;
126 }