aboutsummaryrefslogtreecommitdiff
path: root/scripts/parse_kconfig
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/parse_kconfig')
-rw-r--r--scripts/parse_kconfig/boolexpr.c3
-rw-r--r--scripts/parse_kconfig/parse.c38
2 files changed, 33 insertions, 8 deletions
diff --git a/scripts/parse_kconfig/boolexpr.c b/scripts/parse_kconfig/boolexpr.c
index b6f008d..0595461 100644
--- a/scripts/parse_kconfig/boolexpr.c
+++ b/scripts/parse_kconfig/boolexpr.c
@@ -286,6 +286,7 @@ void boolexpr_free(struct boolexpr *e) {
}
struct boolexpr *boolexpr_copy(struct boolexpr *e) {
+ struct boolexpr *cop = e;
struct boolexpr **stack;
size_t stack_size = 2, stack_pos = 0;
stack = malloc(stack_size * sizeof(struct boolexpr *));
@@ -311,5 +312,5 @@ struct boolexpr *boolexpr_copy(struct boolexpr *e) {
}
}
free(stack);
- return e;
+ return cop;
}
diff --git a/scripts/parse_kconfig/parse.c b/scripts/parse_kconfig/parse.c
index 9de456f..6dc08ce 100644
--- a/scripts/parse_kconfig/parse.c
+++ b/scripts/parse_kconfig/parse.c
@@ -126,22 +126,46 @@ void cpy_dep() {
goto choice_exception;
}
// Default value
+ struct boolexpr **defexpr = NULL;
+ size_t defexpr_size = 0;
+ int z;
+ bool exitdef = false;
for_all_defaults(sym, prop) {
Dprintf(" Default value:\n");
doutput_expr(prop->expr);
struct boolexpr *def =
boolexpr_kconfig(gsymlist, prop->expr, true, NULL);
+ struct boolexpr *vis;
if (prop->visible.expr != NULL)
- def =
- boolexpr_and(def,
- boolexpr_kconfig(gsymlist,
- prop->visible.expr,
- false, NULL));
- if (el->def == NULL) {
- el->def = def;
+ vis = boolexpr_kconfig(gsymlist, prop->visible.expr,
+ false, NULL);
+ else
+ vis = boolexpr_true();
+ if (vis->type != BT_TRUE) {
+ defexpr = realloc(defexpr,
+ ++defexpr_size * sizeof(struct boolexpr *));
+ defexpr[defexpr_size - 1] = boolexpr_copy(vis);
} else {
+ ++defexpr_size;
+ exitdef = true;
+ }
+ def = boolexpr_and(def, vis);
+ for (z = 0; z < ((int)defexpr_size - 1); z++) {
+ def = boolexpr_and(def, boolexpr_not(
+ boolexpr_copy(defexpr[z])));
+ }
+ if (el->def == NULL)
+ el->def = def;
+ else
el->def = boolexpr_or(el->def, def);
+ if (exitdef)
+ break;
+ }
+ if (defexpr != NULL) {
+ for (z = 0; z < defexpr_size - 1; z++) {
+ boolexpr_free(defexpr[z]);
}
+ free(defexpr);
}
if (el->def == NULL)
el->def = boolexpr_false();