commit:     7eac64ac2553e18d0b45a14bb746a4229966baf0
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 20 14:22:21 2025 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Aug 20 14:22:21 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7eac64ac

q: make -m work properly after ROOT fixes

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 q.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/q.c b/q.c
index c9df5f7..db7b653 100644
--- a/q.c
+++ b/q.c
@@ -365,11 +365,14 @@ int q_main(int argc, char **argv)
                                                strncmp(lastmfile, mfile, s - 
mfile + 1) != 0 ||
                                                lastcbeg != cbeg || lastcend != 
cend)
                                {
-                                       *s = '\0';
+                                       char mfileloc[_Q_PATH_MAX];
+
+                                       snprintf(mfileloc, sizeof(mfileloc), 
"%s%.*s",
+                                                        portroot, (int)(s - 
mfile), mfile);
+
                                        if (buf != NULL)
                                                *buf = '\0';
-                                       eat_file(mfile, &buf, &buflen);
-                                       *s = ':';
+                                       eat_file(mfileloc, &buf, &buflen);
 
                                        line = 0;
                                        for (l = buf; (s = strchr(l, '\n')) != 
NULL; l = s + 1)
@@ -390,7 +393,7 @@ int q_main(int argc, char **argv)
                                                atom));
 
                        if (verbose == 1) {
-                               printf(" [%s]\n", (char *)array_get_elem(files, 
n));
+                               printf(" [%s%s]\n", portroot, (char 
*)array_get_elem(files, n));
                        } else {
                                printf("\n");
                        }

Reply via email to