diff options
author | 2019-05-12 11:58:24 +0200 | |
---|---|---|
committer | 2019-05-12 11:58:24 +0200 | |
commit | 0dd41363d51b4d49fd5db414a4680d30ec78edd2 (patch) | |
tree | c311df42fd906a8977432541e17aad88c772f78f /quse.c | |
parent | qsize: use tree_get_atom (diff) | |
download | portage-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.c | 32 |
1 files changed, 12 insertions, 20 deletions
@@ -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); |