mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-18 21:28:02 +00:00
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;
|
||||
}
|
||||
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;
|
||||
if (!expr_eq(e1, e2))
|
||||
return;
|
||||
@ -347,7 +348,7 @@ struct expr *expr_trans_bool(struct expr *e)
|
||||
/*
|
||||
* 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 symbol *sym1, *sym2;
|
||||
@ -411,7 +412,7 @@ struct expr *expr_join_or(struct expr *e1, struct expr *e2)
|
||||
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 symbol *sym1, *sym2;
|
||||
@ -1012,73 +1013,79 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2)
|
||||
#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) {
|
||||
fn(data, "y");
|
||||
fn(data, NULL, "y");
|
||||
return;
|
||||
}
|
||||
|
||||
if (expr_compare_type(prevtoken, e->type) > 0)
|
||||
fn(data, "(");
|
||||
fn(data, NULL, "(");
|
||||
switch (e->type) {
|
||||
case E_SYMBOL:
|
||||
if (e->left.sym->name)
|
||||
fn(data, e->left.sym->name);
|
||||
fn(data, e->left.sym, e->left.sym->name);
|
||||
else
|
||||
fn(data, "<choice>");
|
||||
fn(data, NULL, "<choice>");
|
||||
break;
|
||||
case E_NOT:
|
||||
fn(data, "!");
|
||||
fn(data, NULL, "!");
|
||||
expr_print(e->left.expr, fn, data, E_NOT);
|
||||
break;
|
||||
case E_EQUAL:
|
||||
fn(data, e->left.sym->name);
|
||||
fn(data, "=");
|
||||
fn(data, e->right.sym->name);
|
||||
if (e->left.sym->name)
|
||||
fn(data, e->left.sym, e->left.sym->name);
|
||||
else
|
||||
fn(data, NULL, "<choice>");
|
||||
fn(data, NULL, "=");
|
||||
fn(data, e->right.sym, e->right.sym->name);
|
||||
break;
|
||||
case E_UNEQUAL:
|
||||
fn(data, e->left.sym->name);
|
||||
fn(data, "!=");
|
||||
fn(data, e->right.sym->name);
|
||||
if (e->left.sym->name)
|
||||
fn(data, e->left.sym, e->left.sym->name);
|
||||
else
|
||||
fn(data, NULL, "<choice>");
|
||||
fn(data, NULL, "!=");
|
||||
fn(data, e->right.sym, e->right.sym->name);
|
||||
break;
|
||||
case 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);
|
||||
break;
|
||||
case 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);
|
||||
break;
|
||||
case E_CHOICE:
|
||||
fn(data, e->right.sym->name);
|
||||
fn(data, e->right.sym, e->right.sym->name);
|
||||
if (e->left.expr) {
|
||||
fn(data, " ^ ");
|
||||
fn(data, NULL, " ^ ");
|
||||
expr_print(e->left.expr, fn, data, E_CHOICE);
|
||||
}
|
||||
break;
|
||||
case E_RANGE:
|
||||
fn(data, "[");
|
||||
fn(data, e->left.sym->name);
|
||||
fn(data, " ");
|
||||
fn(data, e->right.sym->name);
|
||||
fn(data, "]");
|
||||
fn(data, NULL, "[");
|
||||
fn(data, e->left.sym, e->left.sym->name);
|
||||
fn(data, NULL, " ");
|
||||
fn(data, e->right.sym, e->right.sym->name);
|
||||
fn(data, NULL, "]");
|
||||
break;
|
||||
default:
|
||||
{
|
||||
char buf[32];
|
||||
sprintf(buf, "<unknown type %d>", e->type);
|
||||
fn(data, buf);
|
||||
fn(data, NULL, buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
@ -1088,9 +1095,34 @@ void expr_fprint(struct expr *e, FILE *out)
|
||||
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)
|
||||
|
@ -77,7 +77,7 @@ struct symbol {
|
||||
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_MOD 0x0002
|
||||
@ -98,7 +98,6 @@ struct symbol {
|
||||
|
||||
#define SYMBOL_MAXLENGTH 256
|
||||
#define SYMBOL_HASHSIZE 257
|
||||
#define SYMBOL_HASHMASK 0xff
|
||||
|
||||
enum prop_type {
|
||||
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 {
|
||||
size_t len;
|
||||
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_assign(const char *s);
|
||||
|
@ -39,4 +39,4 @@ P(prop_get_type_name,const char *,(enum prop_type type));
|
||||
|
||||
/* expr.c */
|
||||
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 symbol *sym = menu->sym;
|
||||
|
||||
help.max_width = cols - 10;
|
||||
|
||||
if (sym->help)
|
||||
{
|
||||
if (sym->name) {
|
||||
|
@ -56,7 +56,6 @@ void sym_init(void)
|
||||
|
||||
sym = sym_lookup("ARCH", 0);
|
||||
sym->type = S_STRING;
|
||||
sym->flags |= SYMBOL_AUTO;
|
||||
p = getenv("ARCH");
|
||||
if (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_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);
|
||||
|
||||
if (modules_sym == sym)
|
||||
modules_val = modules_sym->curr.tri;
|
||||
if (modules_sym == sym) {
|
||||
sym_set_all_changed();
|
||||
modules_val = modules_sym->curr.tri;
|
||||
}
|
||||
}
|
||||
|
||||
if (sym_is_choice(sym)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (sym->flags & SYMBOL_AUTO)
|
||||
sym->flags &= ~SYMBOL_WRITE;
|
||||
}
|
||||
|
||||
void sym_clear_all_valid(void)
|
||||
@ -462,8 +467,6 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val)
|
||||
sym->user.tri = val;
|
||||
if (oldval != val) {
|
||||
sym_clear_all_valid();
|
||||
if (sym == modules_sym)
|
||||
sym_set_all_changed();
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -756,6 +759,7 @@ struct symbol **sym_re_search(const char *pattern)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
sym_calc_value(sym);
|
||||
sym_arr[cnt++] = sym;
|
||||
}
|
||||
if (sym_arr)
|
||||
|
@ -169,7 +169,7 @@ static void zconf_error(const char *err, ...);
|
||||
static void zconferror(const char *err);
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user