aboutsummaryrefslogtreecommitdiff
path: root/quse.c
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2019-05-12 11:58:24 +0200
committerFabian Groffen <grobian@gentoo.org>2019-05-12 11:58:24 +0200
commit0dd41363d51b4d49fd5db414a4680d30ec78edd2 (patch)
treec311df42fd906a8977432541e17aad88c772f78f /quse.c
parentqsize: use tree_get_atom (diff)
downloadportage-utils-0dd41363d51b4d49fd5db414a4680d30ec78edd2.tar.gz
portage-utils-0dd41363d51b4d49fd5db414a4680d30ec78edd2.tar.bz2
portage-utils-0dd41363d51b4d49fd5db414a4680d30ec78edd2.zip
quse: use tree_get_atom and atom_format
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Diffstat (limited to 'quse.c')
-rw-r--r--quse.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/quse.c b/quse.c
index 6def799..c7fbe81 100644
--- a/quse.c
+++ b/quse.c
@@ -420,16 +420,12 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
int portdirfd = -1; /* pacify compiler */
if (state->match || verbose) {
- snprintf(buf, sizeof(buf), "%s/%s",
- pkg_ctx->cat_ctx->name, pkg_ctx->name);
- atom = atom_explode(buf);
+ atom = tree_get_atom(pkg_ctx, 0);
if (atom == NULL)
return 0;
if (state->match) {
match = atom_compare(atom, state->match) == EQUAL;
- if (!verbose || !match)
- atom_implode(atom);
if (!match)
return 0;
@@ -517,13 +513,17 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
}
if (match) {
- char *repo = state->do_repo ? pkg_ctx->repo : NULL;
+ const char *qfmt;
+
+ atom = tree_get_atom(pkg_ctx, state->do_repo);
+ if (state->do_repo) {
+ qfmt = "%[CATEGORY]%[PF]%[REPO]";
+ } else {
+ qfmt = "%[CATEGORY]%[PF]";
+ }
if (quiet) {
- printf("%s%s/%s%s%s%s%s%s\n", BOLD, pkg_ctx->cat_ctx->name,
- BLUE, pkg_ctx->name,
- repo ? RED : "", repo ? "::" : "", repo ? repo : "",
- NORM);
+ printf("%s\n", atom_format(qfmt, atom, 0));
} else if (verbose && !state->do_licence) {
/* multi-line result, printing USE-flags with their descs */
struct quse_state us = {
@@ -537,10 +537,7 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
.overlay = NULL,
};
- printf("%s%s/%s%s%s%s%s%s\n", BOLD, pkg_ctx->cat_ctx->name,
- BLUE, pkg_ctx->name,
- repo ? RED : "", repo ? "::" : "", repo ? repo : "",
- NORM);
+ printf("%s\n", atom_format(qfmt, atom, 0));
q = p = meta->IUSE;
buf[0] = '\0';
@@ -584,16 +581,11 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
free(us.retv);
free(us.argv);
} else {
- printf("%s%s/%s%s%s%s%s%s: %s\n", BOLD, pkg_ctx->cat_ctx->name,
- BLUE, pkg_ctx->name,
- repo ? RED : "", repo ? "::" : "", repo ? repo : "",
- NORM, v);
+ printf("%s: %s\n", atom_format(qfmt, atom, 0), v);
}
}
tree_close_meta(meta);
- if (state->match && verbose)
- atom_implode(atom);
if (verbose)
close(portdirfd);