aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2013-09-29 10:03:06 +0000
committerMike Frysinger <vapier@gentoo.org>2013-09-29 10:03:06 +0000
commitcb4371845ceef2c08b93062a13120739fdabf8c3 (patch)
treebdf22435188e752fa22aec272e2a06c16815e373 /qdepends.c
parentqdepends: pass back an empty node when parsing is OK so -f can exit appropria... (diff)
downloadportage-utils-cb4371845ceef2c08b93062a13120739fdabf8c3.tar.gz
portage-utils-cb4371845ceef2c08b93062a13120739fdabf8c3.tar.bz2
portage-utils-cb4371845ceef2c08b93062a13120739fdabf8c3.zip
qdepends: check for whitespace around node elements as PMS requires it and it makes parsing of USE deps possible #470180
Diffstat (limited to 'qdepends.c')
-rw-r--r--qdepends.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/qdepends.c b/qdepends.c
index 0f16022..b25ed9b 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2013 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.61 2013/09/29 10:01:55 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.62 2013/09/29 10:03:06 vapier Exp $
*
* Copyright 2005-2010 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2013 Mike Frysinger - <vapier@gentoo.org>
@@ -32,7 +32,7 @@ static const char * const qdepends_opts_help[] = {
"Pretty format specified depend strings",
COMMON_OPTS_HELP
};
-static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.61 2013/09/29 10:01:55 vapier Exp $";
+static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.62 2013/09/29 10:03:06 vapier Exp $";
#define qdepends_usage(ret) usage(ret, QDEPENDS_FLAGS, qdepends_long_opts, qdepends_opts_help, lookup_applet_idx("qdepends"))
static char qdep_name_only = 0;
@@ -146,6 +146,7 @@ void _dep_attach(dep_node *root, dep_node *attach_me, int type)
_q_static dep_node *dep_grow_tree(const char *depend)
{
+ bool saw_whitespace;
signed long paren_balanced;
const char *ptr, *word;
int curr_attach;
@@ -175,8 +176,10 @@ _q_static dep_node *dep_grow_tree(const char *depend)
word = NULL; \
} while (0)
+ saw_whitespace = true;
for (ptr = depend; *ptr; ++ptr) {
if (isspace(*ptr)) {
+ saw_whitespace = true;
_maybe_consume_word(DEP_NORM);
continue;
}
@@ -192,6 +195,8 @@ _q_static dep_node *dep_grow_tree(const char *depend)
continue;
}
case '|': {
+ if (!saw_whitespace)
+ break;
if (ptr[1] != '|') {
warnf("Found a | but not ||");
goto error_out;
@@ -203,6 +208,8 @@ _q_static dep_node *dep_grow_tree(const char *depend)
}
case '(': {
++paren_balanced;
+ if (!saw_whitespace)
+ break;
if (prev_type == DEP_OR || prev_type == DEP_USE) {
_maybe_consume_word(DEP_NORM);
prev_type = DEP_NULL;
@@ -219,6 +226,8 @@ _q_static dep_node *dep_grow_tree(const char *depend)
}
case ')': {
--paren_balanced;
+ if (!saw_whitespace)
+ break;
_maybe_consume_word(DEP_NORM);
if (curr_node->parent == NULL) {
@@ -233,6 +242,7 @@ _q_static dep_node *dep_grow_tree(const char *depend)
if (!word)
word = ptr;
}
+ saw_whitespace = false;
/* fall through to the paren failure below */
if (paren_balanced < 0)