aboutsummaryrefslogtreecommitdiff
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
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>
-rw-r--r--libq/dep.c34
-rw-r--r--tests/qdepends/list03.good4
-rw-r--r--tests/qdepends/list04.good4
-rw-r--r--tests/qdepends/list05.good4
4 files changed, 32 insertions, 14 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:
diff --git a/tests/qdepends/list03.good b/tests/qdepends/list03.good
index f66b636..d0eb5d2 100644
--- a/tests/qdepends/list03.good
+++ b/tests/qdepends/list03.good
@@ -1,5 +1,3 @@
DEPEND="
- foo? (
- a/b
- )
+ foo? ( a/b )
"
diff --git a/tests/qdepends/list04.good b/tests/qdepends/list04.good
index 2457caf..7f0887a 100644
--- a/tests/qdepends/list04.good
+++ b/tests/qdepends/list04.good
@@ -1,5 +1,3 @@
DEPEND="
- || (
- a/b
- )
+ || ( a/b )
"
diff --git a/tests/qdepends/list05.good b/tests/qdepends/list05.good
index 0b7d420..868efae 100644
--- a/tests/qdepends/list05.good
+++ b/tests/qdepends/list05.good
@@ -1,9 +1,7 @@
DEPEND="
|| (
|| (
- || (
- x
- )
+ || ( x )
a
)
)