commit:     a68b9b4ebc840805f504fe681196e7f15737985d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 25 11:03:36 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 25 11:03:36 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a68b9b4e

libq/atom: fixup USE-dep printing in atom_format

Bug: https://bugs.gentoo.org/724892
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 libq/atom.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/libq/atom.c b/libq/atom.c
index 7e72bf3..acf28be 100644
--- a/libq/atom.c
+++ b/libq/atom.c
@@ -939,12 +939,20 @@ atom_format_r(
                                } else if (!strncmp("USE", fmt, len)) {
                                        if (showit || atom->usedeps) {
                                                atom_usedep *ud;
-                                               append_buf(buf, buflen, "%s", 
"[");
-                                               for (ud = atom->usedeps; ud != 
NULL; ud = ud->next)
-                                                       append_buf(buf, buflen, 
"%s%s%s%s%s%s",
-                                                                       
MAGENTA, atom_usecond_str[ud->pfx_cond],
-                                                                       
ud->use, atom_usecond_str[ud->sfx_cond],
-                                                                       NORM, 
ud->next == NULL ? "]" : ",");
+                                               if (atom->usedeps == NULL) {
+                                                       append_buf(buf, buflen, 
"%s", "<unset>");
+                                               } else {
+                                                       if (connected)
+                                                               append_buf(buf, 
buflen, "%s", "[");
+                                                       for (ud = 
atom->usedeps; ud != NULL; ud = ud->next)
+                                                               append_buf(buf, 
buflen, "%s%s%s%s%s%s",
+                                                                               
MAGENTA, atom_usecond_str[ud->pfx_cond],
+                                                                               
ud->use, atom_usecond_str[ud->sfx_cond],
+                                                                               
NORM, ud->next == NULL ? "" :
+                                                                               
(connected ? "," : " "));
+                                                       if (connected)
+                                                               append_buf(buf, 
buflen, "%s", "]");
+                                               }
                                        }
                                } else
                                        append_buf(buf, buflen, "<BAD:%.*s>", 
(int)len, fmt);

Reply via email to