aboutsummaryrefslogtreecommitdiff
path: root/libq
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2022-04-07 19:14:08 +0200
committerFabian Groffen <grobian@gentoo.org>2022-04-07 19:14:08 +0200
commit82f8dc2ee9ba0ff97924df0dcc3feba3935b979c (patch)
treeb158f05e3b3b11808fb7145d51b962b9513ef2bd /libq
parentbuildsys: regenerate (diff)
downloadportage-utils-82f8dc2ee9ba0ff97924df0dcc3feba3935b979c.tar.gz
portage-utils-82f8dc2ee9ba0ff97924df0dcc3feba3935b979c.tar.bz2
portage-utils-82f8dc2ee9ba0ff97924df0dcc3feba3935b979c.zip
libq/dep: print single nodes on a single line
condense conditional and use-deps to a single line when there's a single target, e.g.: use? ( cat/pkg ) instead of use? ( cat/pkg ) Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Diffstat (limited to 'libq')
-rw-r--r--libq/dep.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/libq/dep.c b/libq/dep.c
index d431367..99629e7 100644
--- a/libq/dep.c
+++ b/libq/dep.c
@@ -238,6 +238,13 @@ dep_print_tree(
size_t s;
int indent = 4; /* Gentoo 4-wide indent standard */
depend_atom *d = NULL;
+ bool singlechild = false;
+ bool nonewline = false;
+
+ if (verbose < 0) {
+ nonewline = true;
+ verbose = -verbose - 1;
+ }
assert(root);
if (root->type == DEP_NULL)
@@ -248,7 +255,8 @@ dep_print_tree(
if (verbose > 0)
fprintf(fp, "Node [%s]: ", _dep_names[root->type]);
- /*printf("Node %p [%s] %p %p %p: ", root, _dep_names[root->type], root->parent, root->neighbor, root->children);*/
+ /*printf("Node %p [%s] %p %p %p: ", root, _dep_names[root->type],
+ * root->parent, root->neighbor, root->children);*/
if (root->type == DEP_OR)
fprintf(fp, "|| (");
if (root->info) {
@@ -286,14 +294,30 @@ dep_print_tree(
if (root->type == DEP_USE)
fprintf(fp, "? (");
}
- fprintf(fp, "\n");
+
+ if (root->children &&
+ root->children->children == NULL &&
+ root->children->neighbor == NULL)
+ {
+ singlechild = true;
+ }
+
+ if (singlechild)
+ fprintf(fp, " ");
+ else if (!nonewline)
+ fprintf(fp, "\n");
if (root->children)
- dep_print_tree(fp, root->children, space+1, hlatoms, hlcolor, verbose);
+ dep_print_tree(fp, root->children,
+ singlechild ? 0 : space + 1,
+ hlatoms, hlcolor, singlechild ? -verbose - 1 : verbose);
if (root->type == DEP_OR || root->type == DEP_USE) {
- for (s = space; s; --s)
- fprintf(fp, "%*s", indent, "");
+ if (singlechild)
+ fprintf(fp, " ");
+ else
+ for (s = space; s; --s)
+ fprintf(fp, "%*s", indent, "");
fprintf(fp, ")\n");
}
this_node_sucks: