aboutsummaryrefslogtreecommitdiff
path: root/package/config/expr.c
diff options
context:
space:
mode:
authorGravatar Peter Korsgaard <jacmet@sunsite.dk>2011-02-02 14:59:18 +0100
committerGravatar Peter Korsgaard <jacmet@sunsite.dk>2011-02-02 15:54:50 +0100
commita72ab0542ff1dd8909ba5f1065627e41e3316b45 (patch)
tree0b6fe75709ffe7dbf821ed2b7ac038f8cd49510c /package/config/expr.c
parenta538d4057e3add76889270ec097572223b11ba07 (diff)
downloadbuildroot-a72ab0542ff1dd8909ba5f1065627e41e3316b45.tar.gz
buildroot-a72ab0542ff1dd8909ba5f1065627e41e3316b45.tar.bz2
package/config: rebase against 2.6.38-rc3
Fixes nconfig crash on comments within choice groups. Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Diffstat (limited to 'package/config/expr.c')
-rw-r--r--package/config/expr.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/package/config/expr.c b/package/config/expr.c
index 88aace9c98..c5182f4d43 100644
--- a/package/config/expr.c
+++ b/package/config/expr.c
@@ -64,7 +64,7 @@ struct expr *expr_alloc_or(struct expr *e1, struct expr *e2)
return e2 ? expr_alloc_two(E_OR, e1, e2) : e1;
}
-struct expr *expr_copy(struct expr *org)
+struct expr *expr_copy(const struct expr *org)
{
struct expr *e;
@@ -1013,6 +1013,48 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2)
#endif
}
+static inline struct expr *
+expr_get_leftmost_symbol(const struct expr *e)
+{
+
+ if (e == NULL)
+ return NULL;
+
+ while (e->type != E_SYMBOL)
+ e = e->left.expr;
+
+ return expr_copy(e);
+}
+
+/*
+ * Given expression `e1' and `e2', returns the leaf of the longest
+ * sub-expression of `e1' not containing 'e2.
+ */
+struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2)
+{
+ struct expr *ret;
+
+ switch (e1->type) {
+ case E_OR:
+ return expr_alloc_and(
+ expr_simplify_unmet_dep(e1->left.expr, e2),
+ expr_simplify_unmet_dep(e1->right.expr, e2));
+ case E_AND: {
+ struct expr *e;
+ e = expr_alloc_and(expr_copy(e1), expr_copy(e2));
+ e = expr_eliminate_dups(e);
+ ret = (!expr_eq(e, e1)) ? e1 : NULL;
+ expr_free(e);
+ break;
+ }
+ default:
+ ret = e1;
+ break;
+ }
+
+ return expr_get_leftmost_symbol(ret);
+}
+
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
{
if (!e) {