commit: bee2b445ae583187d2b8218a5b1429828f872663
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 8 08:11:38 2020 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jul 8 08:11:38 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=bee2b445
qlop: fix crash when encountering a long option with -E -v
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
qlop.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/qlop.c b/qlop.c
index 5048b1e..a5761d7 100644
--- a/qlop.c
+++ b/qlop.c
@@ -545,7 +545,7 @@ static int do_emerge_log(
char shortopts[8]; /* must hold as many opts converted
below */
int numopts = 0;
- printf("emerge");
+ printf("%semerge%s", DKBLUE, NORM);
for (p += 13; (q = strtok(p, " \n")) != NULL; p = NULL)
{
if (strncmp(q, "--", 2) == 0) {
/* portage seems to normalise options
given into
@@ -556,24 +556,31 @@ static int do_emerge_log(
q += 2;
if (strcmp(q, "ask") == 0) {
shortopts[numopts++] = 'a';
+ q = NULL;
} else if (strcmp(q, "verbose") == 0) {
shortopts[numopts++] = 'v';
+ q = NULL;
} else if (strcmp(q, "oneshot") == 0) {
shortopts[numopts++] = '1';
+ q = NULL;
} else if (strcmp(q, "deep") == 0) {
shortopts[numopts++] = 'D';
+ q = NULL;
} else if (strcmp(q, "update") == 0) {
shortopts[numopts++] = 'u';
+ q = NULL;
} else if (strcmp(q, "depclean") == 0) {
shortopts[numopts++] = 'c';
+ q = NULL;
} else if (strcmp(q, "unmerge") == 0) {
shortopts[numopts++] = 'C';
- } else {
q = NULL;
+ } else {
+ q -= 2;
}
/* process next token */
- if (q != NULL)
+ if (q == NULL)
continue;
}
@@ -590,7 +597,7 @@ static int do_emerge_log(
}
if (strncmp(q, "--", 2) == 0) {
- printf(" %s--%s%s", GREEN, q, NORM);
+ printf(" %s%s%s", GREEN, q, NORM);
} else if (strcmp(q, "@world") == 0 ||
strcmp(q, "@system") == 0)
{