From e94207efe93141ce2d58436c56ea4271948bf148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sat, 12 Sep 2015 11:46:26 +0200 Subject: Fix parse_kconfig choice parsing Parsing choices was implemented wrong. For non-optional choice output rules must contain also dependency of all choice symbols. Because if no choice symbol has fulfilled dependencies, than choice shouldn't be selected. --- scripts/parse_kconfig/boolexpr.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'scripts/parse_kconfig/boolexpr.c') diff --git a/scripts/parse_kconfig/boolexpr.c b/scripts/parse_kconfig/boolexpr.c index 4d58654..b6f008d 100644 --- a/scripts/parse_kconfig/boolexpr.c +++ b/scripts/parse_kconfig/boolexpr.c @@ -4,7 +4,7 @@ struct boolexpr *boolexpr_eql(struct symlist *sl, struct symbol *sym1, struct symbol *sym2); struct boolexpr *boolexpr_kconfig(struct symlist *sl, struct expr *expr, - bool modulesym) { + bool modulesym, struct symbol **as_true) { struct stck { struct expr *expr; struct boolexpr *bl; @@ -30,7 +30,7 @@ struct boolexpr *boolexpr_kconfig(struct symlist *sl, struct expr *expr, } switch (expr->type) { case E_SYMBOL: - rtn = boolexpr_sym(sl, expr->left.sym, modulesym); + rtn = boolexpr_sym(sl, expr->left.sym, modulesym, as_true); goto go_up; case E_NOT: if (rtn == NULL) @@ -111,7 +111,7 @@ struct boolexpr *boolexpr_false() { } struct boolexpr *boolexpr_sym(struct symlist *sl, struct symbol *sym, - bool modulesym) { + bool modulesym, struct symbol **as_true) { struct boolexpr *rtn; rtn = malloc(sizeof(struct boolexpr)); rtn->overusage = 0; @@ -125,6 +125,14 @@ struct boolexpr *boolexpr_sym(struct symlist *sl, struct symbol *sym, } else if (!strcmp(sym->name, "y")) { rtn->type = BT_TRUE; } else { + if (as_true != NULL) { + for (; *as_true != NULL; as_true++) { + if (!strcmp((*as_true)->name, sym->name)) { + rtn->type = BT_TRUE; + return rtn; + } + } + } rtn->id = symlist_id(sl, sym->name); if (rtn->id != 0) rtn->type = BT_SYM; @@ -144,18 +152,18 @@ struct boolexpr *boolexpr_eql(struct symlist *sl, return rtn; } if (!strcmp(sym2->name, "n")) - return boolexpr_not(boolexpr_sym(sl, sym1, false)); + return boolexpr_not(boolexpr_sym(sl, sym1, false, NULL)); if (!strcmp(sym2->name, "y")) - return boolexpr_sym(sl, sym1, false); + return boolexpr_sym(sl, sym1, false, NULL); // sym1 <-> sym2 // (!sym1 || sym2) && (sym1 || !sym2) return boolexpr_and(boolexpr_or - (boolexpr_not(boolexpr_sym(sl, sym1, false)), - boolexpr_sym(sl, sym2, false)), - boolexpr_or(boolexpr_sym(sl, sym1, false), + (boolexpr_not(boolexpr_sym(sl, sym1, false, NULL)), + boolexpr_sym(sl, sym2, false, NULL)), + boolexpr_or(boolexpr_sym(sl, sym1, false, NULL), boolexpr_not(boolexpr_sym - (sl, sym2, false)))); + (sl, sym2, false, NULL)))); } struct boolexpr *boolexpr_or(struct boolexpr *e1, struct boolexpr *e2) { -- cgit v1.2.3