From 8d39c440602a944161451d8760f66cab62e0b471 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 10 Feb 2026 16:16:49 -0600 Subject: [PATCH] Fix choice logic, should only set one value (and reset when set again). --- scripts/kconfig.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/scripts/kconfig.c b/scripts/kconfig.c index 9581f51d..9c269754 100644 --- a/scripts/kconfig.c +++ b/scripts/kconfig.c @@ -145,8 +145,7 @@ struct kconfig *read_Config(char *name, struct kconfig *contain) // start a new config entry? else if ((ii = strany(ss, keywords))) { struct kconfig *kt = calloc(sizeof(struct kconfig), 1); - - if (ii>5) contain = kc->contain; + if (ii>5) contain = contain->contain; kt->contain = contain; if (ii<4) contain = kt; if (klist) kc = (kc->next = kt); @@ -237,6 +236,21 @@ int depends(struct kconfig *klist, struct kconfig *kc) return rc; } +void set_val(struct kconfig *kk, char *val) +{ + struct kconfig *k2; + + if (!strcmp(kk->contain->type, "choice")) { + for (k2 = kk; k2->contain == kk->contain; k2 = k2->next) { + free(k2->value); + k2->value = 0; + } + free(kk->contain->def); + kk->contain->def = strdup(kk->symbol); + } + val = strdup(val); + bump(&kk->value, &val); +} // Set values for symbols void read_dotconfig(struct kconfig *klist, FILE *fp) @@ -262,12 +276,7 @@ void read_dotconfig(struct kconfig *klist, FILE *fp) continue; } if (!(kk = lookup(klist, name))) dprintf(2, "bad symbol %s\n", name); - else { -// TODO if (!strcmp(kc->contain->type, "choice")) - - s = strdup(val); - bump(&kk->value, &s); - } + else set_val(kk, val); } fclose(fp); -- 2.39.5