scripts/config: merge fixes for various issues, including recursive dependency detection/handling (patch by mbm)
SVN-Revision: 28658
This commit is contained in:
parent
ab29084cdb
commit
5e48d47dfe
@ -145,7 +145,8 @@ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct e
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e1->type == E_SYMBOL && e2->type == E_SYMBOL &&
|
if (e1->type == E_SYMBOL && e2->type == E_SYMBOL &&
|
||||||
e1->left.sym == e2->left.sym && (e1->left.sym->flags & (SYMBOL_YES|SYMBOL_NO)))
|
e1->left.sym == e2->left.sym &&
|
||||||
|
(e1->left.sym == &symbol_yes || e1->left.sym == &symbol_no))
|
||||||
return;
|
return;
|
||||||
if (!expr_eq(e1, e2))
|
if (!expr_eq(e1, e2))
|
||||||
return;
|
return;
|
||||||
@ -347,7 +348,7 @@ struct expr *expr_trans_bool(struct expr *e)
|
|||||||
/*
|
/*
|
||||||
* e1 || e2 -> ?
|
* e1 || e2 -> ?
|
||||||
*/
|
*/
|
||||||
struct expr *expr_join_or(struct expr *e1, struct expr *e2)
|
static struct expr *expr_join_or(struct expr *e1, struct expr *e2)
|
||||||
{
|
{
|
||||||
struct expr *tmp;
|
struct expr *tmp;
|
||||||
struct symbol *sym1, *sym2;
|
struct symbol *sym1, *sym2;
|
||||||
@ -411,7 +412,7 @@ struct expr *expr_join_or(struct expr *e1, struct expr *e2)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct expr *expr_join_and(struct expr *e1, struct expr *e2)
|
static struct expr *expr_join_and(struct expr *e1, struct expr *e2)
|
||||||
{
|
{
|
||||||
struct expr *tmp;
|
struct expr *tmp;
|
||||||
struct symbol *sym1, *sym2;
|
struct symbol *sym1, *sym2;
|
||||||
@ -1012,73 +1013,79 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void expr_print(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken)
|
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
|
||||||
{
|
{
|
||||||
if (!e) {
|
if (!e) {
|
||||||
fn(data, "y");
|
fn(data, NULL, "y");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expr_compare_type(prevtoken, e->type) > 0)
|
if (expr_compare_type(prevtoken, e->type) > 0)
|
||||||
fn(data, "(");
|
fn(data, NULL, "(");
|
||||||
switch (e->type) {
|
switch (e->type) {
|
||||||
case E_SYMBOL:
|
case E_SYMBOL:
|
||||||
if (e->left.sym->name)
|
if (e->left.sym->name)
|
||||||
fn(data, e->left.sym->name);
|
fn(data, e->left.sym, e->left.sym->name);
|
||||||
else
|
else
|
||||||
fn(data, "<choice>");
|
fn(data, NULL, "<choice>");
|
||||||
break;
|
break;
|
||||||
case E_NOT:
|
case E_NOT:
|
||||||
fn(data, "!");
|
fn(data, NULL, "!");
|
||||||
expr_print(e->left.expr, fn, data, E_NOT);
|
expr_print(e->left.expr, fn, data, E_NOT);
|
||||||
break;
|
break;
|
||||||
case E_EQUAL:
|
case E_EQUAL:
|
||||||
fn(data, e->left.sym->name);
|
if (e->left.sym->name)
|
||||||
fn(data, "=");
|
fn(data, e->left.sym, e->left.sym->name);
|
||||||
fn(data, e->right.sym->name);
|
else
|
||||||
|
fn(data, NULL, "<choice>");
|
||||||
|
fn(data, NULL, "=");
|
||||||
|
fn(data, e->right.sym, e->right.sym->name);
|
||||||
break;
|
break;
|
||||||
case E_UNEQUAL:
|
case E_UNEQUAL:
|
||||||
fn(data, e->left.sym->name);
|
if (e->left.sym->name)
|
||||||
fn(data, "!=");
|
fn(data, e->left.sym, e->left.sym->name);
|
||||||
fn(data, e->right.sym->name);
|
else
|
||||||
|
fn(data, NULL, "<choice>");
|
||||||
|
fn(data, NULL, "!=");
|
||||||
|
fn(data, e->right.sym, e->right.sym->name);
|
||||||
break;
|
break;
|
||||||
case E_OR:
|
case E_OR:
|
||||||
expr_print(e->left.expr, fn, data, E_OR);
|
expr_print(e->left.expr, fn, data, E_OR);
|
||||||
fn(data, " || ");
|
fn(data, NULL, " || ");
|
||||||
expr_print(e->right.expr, fn, data, E_OR);
|
expr_print(e->right.expr, fn, data, E_OR);
|
||||||
break;
|
break;
|
||||||
case E_AND:
|
case E_AND:
|
||||||
expr_print(e->left.expr, fn, data, E_AND);
|
expr_print(e->left.expr, fn, data, E_AND);
|
||||||
fn(data, " && ");
|
fn(data, NULL, " && ");
|
||||||
expr_print(e->right.expr, fn, data, E_AND);
|
expr_print(e->right.expr, fn, data, E_AND);
|
||||||
break;
|
break;
|
||||||
case E_CHOICE:
|
case E_CHOICE:
|
||||||
fn(data, e->right.sym->name);
|
fn(data, e->right.sym, e->right.sym->name);
|
||||||
if (e->left.expr) {
|
if (e->left.expr) {
|
||||||
fn(data, " ^ ");
|
fn(data, NULL, " ^ ");
|
||||||
expr_print(e->left.expr, fn, data, E_CHOICE);
|
expr_print(e->left.expr, fn, data, E_CHOICE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case E_RANGE:
|
case E_RANGE:
|
||||||
fn(data, "[");
|
fn(data, NULL, "[");
|
||||||
fn(data, e->left.sym->name);
|
fn(data, e->left.sym, e->left.sym->name);
|
||||||
fn(data, " ");
|
fn(data, NULL, " ");
|
||||||
fn(data, e->right.sym->name);
|
fn(data, e->right.sym, e->right.sym->name);
|
||||||
fn(data, "]");
|
fn(data, NULL, "]");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
char buf[32];
|
char buf[32];
|
||||||
sprintf(buf, "<unknown type %d>", e->type);
|
sprintf(buf, "<unknown type %d>", e->type);
|
||||||
fn(data, buf);
|
fn(data, NULL, buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (expr_compare_type(prevtoken, e->type) > 0)
|
if (expr_compare_type(prevtoken, e->type) > 0)
|
||||||
fn(data, ")");
|
fn(data, NULL, ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void expr_print_file_helper(void *data, const char *str)
|
static void expr_print_file_helper(void *data, struct symbol *sym, const char *str)
|
||||||
{
|
{
|
||||||
fwrite(str, strlen(str), 1, data);
|
fwrite(str, strlen(str), 1, data);
|
||||||
}
|
}
|
||||||
@ -1088,9 +1095,34 @@ void expr_fprint(struct expr *e, FILE *out)
|
|||||||
expr_print(e, expr_print_file_helper, out, E_NONE);
|
expr_print(e, expr_print_file_helper, out, E_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void expr_print_gstr_helper(void *data, const char *str)
|
static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str)
|
||||||
{
|
{
|
||||||
str_append((struct gstr*)data, str);
|
struct gstr *gs = (struct gstr*)data;
|
||||||
|
const char *sym_str = NULL;
|
||||||
|
|
||||||
|
if (sym)
|
||||||
|
sym_str = sym_get_string_value(sym);
|
||||||
|
|
||||||
|
if (gs->max_width) {
|
||||||
|
unsigned extra_length = strlen(str);
|
||||||
|
const char *last_cr = strrchr(gs->s, '\n');
|
||||||
|
unsigned last_line_length;
|
||||||
|
|
||||||
|
if (sym_str)
|
||||||
|
extra_length += 4 + strlen(sym_str);
|
||||||
|
|
||||||
|
if (!last_cr)
|
||||||
|
last_cr = gs->s;
|
||||||
|
|
||||||
|
last_line_length = strlen(gs->s) - (last_cr - gs->s);
|
||||||
|
|
||||||
|
if ((last_line_length + extra_length) > gs->max_width)
|
||||||
|
str_append(gs, "\\\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
str_append(gs, str);
|
||||||
|
if (sym && sym->type != S_UNKNOWN)
|
||||||
|
str_printf(gs, " [=%s]", sym_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void expr_gstr_print(struct expr *e, struct gstr *gs)
|
void expr_gstr_print(struct expr *e, struct gstr *gs)
|
||||||
|
@ -77,7 +77,7 @@ struct symbol {
|
|||||||
struct expr_value rev_dep_inv;
|
struct expr_value rev_dep_inv;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
|
#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
|
||||||
|
|
||||||
#define SYMBOL_YES 0x0001
|
#define SYMBOL_YES 0x0001
|
||||||
#define SYMBOL_MOD 0x0002
|
#define SYMBOL_MOD 0x0002
|
||||||
@ -98,7 +98,6 @@ struct symbol {
|
|||||||
|
|
||||||
#define SYMBOL_MAXLENGTH 256
|
#define SYMBOL_MAXLENGTH 256
|
||||||
#define SYMBOL_HASHSIZE 257
|
#define SYMBOL_HASHSIZE 257
|
||||||
#define SYMBOL_HASHMASK 0xff
|
|
||||||
|
|
||||||
enum prop_type {
|
enum prop_type {
|
||||||
P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, P_DESELECT, P_SELECT, P_RANGE, P_RESET
|
P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, P_DESELECT, P_SELECT, P_RANGE, P_RESET
|
||||||
|
@ -88,6 +88,11 @@ int file_write_dep(const char *name);
|
|||||||
struct gstr {
|
struct gstr {
|
||||||
size_t len;
|
size_t len;
|
||||||
char *s;
|
char *s;
|
||||||
|
/*
|
||||||
|
* when max_width is not zero long lines in string s (if any) get
|
||||||
|
* wrapped not to exceed the max_width value
|
||||||
|
*/
|
||||||
|
int max_width;
|
||||||
};
|
};
|
||||||
struct gstr str_new(void);
|
struct gstr str_new(void);
|
||||||
struct gstr str_assign(const char *s);
|
struct gstr str_assign(const char *s);
|
||||||
|
@ -39,4 +39,4 @@ P(prop_get_type_name,const char *,(enum prop_type type));
|
|||||||
|
|
||||||
/* expr.c */
|
/* expr.c */
|
||||||
P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2));
|
P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2));
|
||||||
P(expr_print,void,(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken));
|
P(expr_print,void,(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken));
|
||||||
|
@ -872,6 +872,8 @@ static void show_help(struct menu *menu)
|
|||||||
struct gstr help = str_new();
|
struct gstr help = str_new();
|
||||||
struct symbol *sym = menu->sym;
|
struct symbol *sym = menu->sym;
|
||||||
|
|
||||||
|
help.max_width = cols - 10;
|
||||||
|
|
||||||
if (sym->help)
|
if (sym->help)
|
||||||
{
|
{
|
||||||
if (sym->name) {
|
if (sym->name) {
|
||||||
|
@ -56,7 +56,6 @@ void sym_init(void)
|
|||||||
|
|
||||||
sym = sym_lookup("ARCH", 0);
|
sym = sym_lookup("ARCH", 0);
|
||||||
sym->type = S_STRING;
|
sym->type = S_STRING;
|
||||||
sym->flags |= SYMBOL_AUTO;
|
|
||||||
p = getenv("ARCH");
|
p = getenv("ARCH");
|
||||||
if (p)
|
if (p)
|
||||||
sym_add_default(sym, p);
|
sym_add_default(sym, p);
|
||||||
@ -362,11 +361,14 @@ void sym_calc_value(struct symbol *sym)
|
|||||||
sym->curr.val = sym_calc_choice(sym);
|
sym->curr.val = sym_calc_choice(sym);
|
||||||
sym_validate_range(sym);
|
sym_validate_range(sym);
|
||||||
|
|
||||||
if (memcmp(&oldval, &sym->curr, sizeof(oldval)))
|
if (memcmp(&oldval, &sym->curr, sizeof(oldval))) {
|
||||||
|
sym->flags &= ~SYMBOL_VALID;
|
||||||
sym_set_changed(sym);
|
sym_set_changed(sym);
|
||||||
|
if (modules_sym == sym) {
|
||||||
if (modules_sym == sym)
|
sym_set_all_changed();
|
||||||
modules_val = modules_sym->curr.tri;
|
modules_val = modules_sym->curr.tri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sym_is_choice(sym)) {
|
if (sym_is_choice(sym)) {
|
||||||
int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
|
int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
|
||||||
@ -377,6 +379,9 @@ void sym_calc_value(struct symbol *sym)
|
|||||||
sym_set_changed(e->right.sym);
|
sym_set_changed(e->right.sym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sym->flags & SYMBOL_AUTO)
|
||||||
|
sym->flags &= ~SYMBOL_WRITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sym_clear_all_valid(void)
|
void sym_clear_all_valid(void)
|
||||||
@ -462,8 +467,6 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val)
|
|||||||
sym->user.tri = val;
|
sym->user.tri = val;
|
||||||
if (oldval != val) {
|
if (oldval != val) {
|
||||||
sym_clear_all_valid();
|
sym_clear_all_valid();
|
||||||
if (sym == modules_sym)
|
|
||||||
sym_set_all_changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -756,6 +759,7 @@ struct symbol **sym_re_search(const char *pattern)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sym_calc_value(sym);
|
||||||
sym_arr[cnt++] = sym;
|
sym_arr[cnt++] = sym;
|
||||||
}
|
}
|
||||||
if (sym_arr)
|
if (sym_arr)
|
||||||
|
@ -169,7 +169,7 @@ static void zconf_error(const char *err, ...);
|
|||||||
static void zconferror(const char *err);
|
static void zconferror(const char *err);
|
||||||
static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);
|
static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);
|
||||||
|
|
||||||
struct symbol *symbol_hash[257];
|
struct symbol *symbol_hash[SYMBOL_HASHSIZE];
|
||||||
|
|
||||||
static struct menu *current_menu, *current_entry;
|
static struct menu *current_menu, *current_entry;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user