commit: 6d6c6c1c7c066ce642b58190c4d6df5a6e5e1a40
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 1 19:52:01 2020 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 1 19:52:01 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6d6c6c1c
libq/dep: fix parsing of USE-deps
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
TODO.md | 3 ---
libq/dep.c | 14 +++++++++++---
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/TODO.md b/TODO.md
index cd4f2b2..191e91c 100644
--- a/TODO.md
+++ b/TODO.md
@@ -48,9 +48,6 @@
# qdepends
-- add -S/-v/-R behavior like qlist #574934
-- bring back -k? (but seems solved by using qlist -IF%{SLOT} pkg)
-- -Qt acts weird (if not, incorrect)
- -v should lookup whether packages are installed for || cases/colouring
# qpkg
diff --git a/libq/dep.c b/libq/dep.c
index 49edf10..0507326 100644
--- a/libq/dep.c
+++ b/libq/dep.c
@@ -110,7 +110,8 @@ dep_grow_tree(const char *depend)
#define _maybe_consume_word(t) \
do { \
- if (!word) break; \
+ if (word == NULL) \
+ break; \
new_node = _dep_grow_node(t, word, ptr-word); \
if (!ret) \
ret = curr_node = new_node; \
@@ -124,8 +125,8 @@ dep_grow_tree(const char *depend)
} while (0)
saw_whitespace = true;
- for (ptr = depend; *ptr; ++ptr) {
- if (isspace(*ptr)) {
+ for (ptr = depend; *ptr != '\0'; ptr++) {
+ if (isspace((int)*ptr)) {
saw_whitespace = true;
_maybe_consume_word(DEP_NORM);
continue;
@@ -185,6 +186,13 @@ dep_grow_tree(const char *depend)
curr_attach = _DEP_NEIGH;
break;
}
+ case '[': {
+ /* USE-dep, seek to matching ']', since they cannot be
+ * nested, this is simple */
+ while (*ptr != '\0' && *ptr != ']')
+ ptr++;
+ break;
+ }
default:
if (!word)
word = ptr;