Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 209305
b: refs/heads/master
c: a64b44e
h: refs/heads/master
i:
  209303: 8a299dc
v: v3
  • Loading branch information
Sam Ravnborg authored and Michal Marek committed Aug 12, 2010
1 parent a2dd9da commit bcf6361
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 36 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 801690caf1894d4f8b1277ca9f5dcf0bcf9b3f58
refs/heads/master: a64b44ead002ba15fdf841106a6fd344b8dd46d8
102 changes: 67 additions & 35 deletions trunk/scripts/kconfig/confdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,13 +918,73 @@ void conf_set_changed_callback(void (*fn)(void))
conf_changed_callback = fn;
}

static void randomize_choice_values(struct symbol *csym)
{
struct property *prop;
struct symbol *sym;
struct expr *e;
int cnt, def;

void conf_set_all_new_symbols(enum conf_def_mode mode)
/*
* If choice is mod then we may have more items slected
* and if no then no-one.
* In both cases stop.
*/
if (csym->curr.tri != yes)
return;

prop = sym_get_choice_prop(csym);

/* count entries in choice block */
cnt = 0;
expr_list_for_each_sym(prop->expr, e, sym)
cnt++;

/*
* find a random value and set it to yes,
* set the rest to no so we have only one set
*/
def = (rand() % cnt);

cnt = 0;
expr_list_for_each_sym(prop->expr, e, sym) {
if (def == cnt++) {
sym->def[S_DEF_USER].tri = yes;
csym->def[S_DEF_USER].val = sym;
}
else {
sym->def[S_DEF_USER].tri = no;
}
}
csym->flags |= SYMBOL_DEF_USER;
/* clear VALID to get value calculated */
csym->flags &= ~(SYMBOL_VALID);
}

static void set_all_choice_values(struct symbol *csym)
{
struct symbol *sym, *csym;
struct property *prop;
struct symbol *sym;
struct expr *e;
int i, cnt, def;

prop = sym_get_choice_prop(csym);

/*
* Set all non-assinged choice values to no
*/
expr_list_for_each_sym(prop->expr, e, sym) {
if (!sym_has_value(sym))
sym->def[S_DEF_USER].tri = no;
}
csym->flags |= SYMBOL_DEF_USER;
/* clear VALID to get value calculated */
csym->flags &= ~(SYMBOL_VALID);
}

void conf_set_all_new_symbols(enum conf_def_mode mode)
{
struct symbol *sym, *csym;
int i, cnt;

for_all_symbols(i, sym) {
if (sym_has_value(sym))
Expand Down Expand Up @@ -960,8 +1020,6 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)

sym_clear_all_valid();

if (mode != def_random)
return;
/*
* We have different type of choice blocks.
* If curr.tri equal to mod then we can select several
Expand All @@ -976,35 +1034,9 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
continue;

sym_calc_value(csym);

if (csym->curr.tri != yes)
continue;

prop = sym_get_choice_prop(csym);

/* count entries in choice block */
cnt = 0;
expr_list_for_each_sym(prop->expr, e, sym)
cnt++;

/*
* find a random value and set it to yes,
* set the rest to no so we have only one set
*/
def = (rand() % cnt);

cnt = 0;
expr_list_for_each_sym(prop->expr, e, sym) {
if (def == cnt++) {
sym->def[S_DEF_USER].tri = yes;
csym->def[S_DEF_USER].val = sym;
}
else {
sym->def[S_DEF_USER].tri = no;
}
}
csym->flags |= SYMBOL_DEF_USER;
/* clear VALID to get value calculated */
csym->flags &= ~(SYMBOL_VALID);
if (mode == def_random)
randomize_choice_values(csym);
else
set_all_choice_values(csym);
}
}

0 comments on commit bcf6361

Please sign in to comment.