Commit a900d0f6 authored by Roman Zippel's avatar Roman Zippel Committed by Ben Collins

[PATCH] Remove old code and macros

Remove old code and debugging macros which were used by the cml1->kconfig
converter.
parent 9683c74d
...@@ -35,25 +35,6 @@ static struct menu *rootEntry; ...@@ -35,25 +35,6 @@ static struct menu *rootEntry;
static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; static char nohelp_text[] = "Sorry, no help available for this option yet.\n";
#if 0
static void printc(int ch)
{
static int sep = 0;
if (!sep) {
putchar('[');
sep = 1;
} else if (ch)
putchar('/');
if (!ch) {
putchar(']');
putchar(' ');
sep = 0;
} else
putchar(ch);
}
#endif
static void printo(const char *o) static void printo(const char *o)
{ {
static int sep = 0; static int sep = 0;
...@@ -314,8 +295,8 @@ static int conf_choice(struct menu *menu) ...@@ -314,8 +295,8 @@ static int conf_choice(struct menu *menu)
break; break;
} }
} else { } else {
sym->def = sym->curr; sym->user = sym->curr;
if (S_TRI(sym->curr) == mod) { if (sym->curr.tri == mod) {
printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
return 0; return 0;
} }
...@@ -422,7 +403,7 @@ static void conf(struct menu *menu) ...@@ -422,7 +403,7 @@ static void conf(struct menu *menu)
if (sym_is_choice(sym)) { if (sym_is_choice(sym)) {
conf_choice(menu); conf_choice(menu);
if (S_TRI(sym->curr) != mod) if (sym->curr.tri != mod)
return; return;
goto conf_childs; goto conf_childs;
} }
......
...@@ -105,11 +105,11 @@ int conf_read(const char *name) ...@@ -105,11 +105,11 @@ int conf_read(const char *name)
case S_INT: case S_INT:
case S_HEX: case S_HEX:
case S_STRING: case S_STRING:
if (S_VAL(sym->def)) if (sym->user.val)
free(S_VAL(sym->def)); free(sym->user.val);
default: default:
S_VAL(sym->def) = NULL; sym->user.val = NULL;
S_TRI(sym->def) = no; sym->user.tri = no;
} }
} }
...@@ -129,7 +129,7 @@ int conf_read(const char *name) ...@@ -129,7 +129,7 @@ int conf_read(const char *name)
switch (sym->type) { switch (sym->type) {
case S_BOOLEAN: case S_BOOLEAN:
case S_TRISTATE: case S_TRISTATE:
sym->def = symbol_no.curr; sym->user = symbol_no.curr;
sym->flags &= ~SYMBOL_NEW; sym->flags &= ~SYMBOL_NEW;
break; break;
default: default:
...@@ -154,18 +154,18 @@ int conf_read(const char *name) ...@@ -154,18 +154,18 @@ int conf_read(const char *name)
switch (sym->type) { switch (sym->type) {
case S_TRISTATE: case S_TRISTATE:
if (p[0] == 'm') { if (p[0] == 'm') {
S_TRI(sym->def) = mod; sym->user.tri = mod;
sym->flags &= ~SYMBOL_NEW; sym->flags &= ~SYMBOL_NEW;
break; break;
} }
case S_BOOLEAN: case S_BOOLEAN:
if (p[0] == 'y') { if (p[0] == 'y') {
S_TRI(sym->def) = yes; sym->user.tri = yes;
sym->flags &= ~SYMBOL_NEW; sym->flags &= ~SYMBOL_NEW;
break; break;
} }
if (p[0] == 'n') { if (p[0] == 'n') {
S_TRI(sym->def) = no; sym->user.tri = no;
sym->flags &= ~SYMBOL_NEW; sym->flags &= ~SYMBOL_NEW;
break; break;
} }
...@@ -187,7 +187,7 @@ int conf_read(const char *name) ...@@ -187,7 +187,7 @@ int conf_read(const char *name)
case S_INT: case S_INT:
case S_HEX: case S_HEX:
if (sym_string_valid(sym, p)) { if (sym_string_valid(sym, p)) {
S_VAL(sym->def) = strdup(p); sym->user.val = strdup(p);
sym->flags &= ~SYMBOL_NEW; sym->flags &= ~SYMBOL_NEW;
} else { } else {
fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name);
...@@ -199,20 +199,20 @@ int conf_read(const char *name) ...@@ -199,20 +199,20 @@ int conf_read(const char *name)
} }
if (sym_is_choice_value(sym)) { if (sym_is_choice_value(sym)) {
prop = sym_get_choice_prop(sym); prop = sym_get_choice_prop(sym);
switch (S_TRI(sym->def)) { switch (sym->user.tri) {
case mod: case mod:
if (S_TRI(prop->def->def) == yes) if (prop->def->user.tri == yes)
/* warn? */; /* warn? */;
break; break;
case yes: case yes:
if (S_TRI(prop->def->def) != no) if (prop->def->user.tri != no)
/* warn? */; /* warn? */;
S_VAL(prop->def->def) = sym; prop->def->user.val = sym;
break; break;
case no: case no:
break; break;
} }
S_TRI(prop->def->def) = S_TRI(sym->def); prop->def->user.tri = sym->user.tri;
} }
break; break;
case '\n': case '\n':
...@@ -228,7 +228,7 @@ int conf_read(const char *name) ...@@ -228,7 +228,7 @@ int conf_read(const char *name)
continue; continue;
prop = sym_get_choice_prop(sym); prop = sym_get_choice_prop(sym);
sym->flags &= ~SYMBOL_NEW; sym->flags &= ~SYMBOL_NEW;
for (e = prop->dep; e; e = e->left.expr) for (e = prop->expr; e; e = e->left.expr)
sym->flags |= e->right.sym->flags & SYMBOL_NEW; sym->flags |= e->right.sym->flags & SYMBOL_NEW;
} }
...@@ -286,7 +286,7 @@ int conf_write(const char *name) ...@@ -286,7 +286,7 @@ int conf_write(const char *name)
type = sym->type; type = sym->type;
if (type == S_TRISTATE) { if (type == S_TRISTATE) {
sym_calc_value(modules_sym); sym_calc_value(modules_sym);
if (S_TRI(modules_sym->curr) == no) if (modules_sym->curr.tri == no)
type = S_BOOLEAN; type = S_BOOLEAN;
} }
switch (type) { switch (type) {
......
...@@ -914,7 +914,7 @@ tristate expr_calc_value(struct expr *e) ...@@ -914,7 +914,7 @@ tristate expr_calc_value(struct expr *e)
switch (e->type) { switch (e->type) {
case E_SYMBOL: case E_SYMBOL:
sym_calc_value(e->left.sym); sym_calc_value(e->left.sym);
return S_TRI(e->left.sym->curr); return e->left.sym->curr.tri;
case E_AND: case E_AND:
val1 = expr_calc_value(e->left.expr); val1 = expr_calc_value(e->left.expr);
val2 = expr_calc_value(e->right.expr); val2 = expr_calc_value(e->right.expr);
......
...@@ -18,10 +18,6 @@ extern "C" { ...@@ -18,10 +18,6 @@ extern "C" {
struct file { struct file {
struct file *next; struct file *next;
struct file *parent; struct file *parent;
#ifdef CML1
struct statement *stmt;
struct statement *last_stmt;
#endif
char *name; char *name;
int lineno; int lineno;
int flags; int flags;
...@@ -45,18 +41,10 @@ union expr_data { ...@@ -45,18 +41,10 @@ union expr_data {
}; };
struct expr { struct expr {
#ifdef CML1
int token;
#else
enum expr_type type; enum expr_type type;
#endif
union expr_data left, right; union expr_data left, right;
}; };
#define E_TRI(ev) ((ev).tri)
#define E_EXPR(ev) ((ev).expr)
#define E_CALC(ev) (E_TRI(ev) = expr_calc_value(E_EXPR(ev)))
#define E_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2)) #define E_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2))
#define E_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2)) #define E_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2))
#define E_NOT(dep) (2-(dep)) #define E_NOT(dep) (2-(dep))
...@@ -66,12 +54,8 @@ struct expr_value { ...@@ -66,12 +54,8 @@ struct expr_value {
tristate tri; tristate tri;
}; };
#define S_VAL(sv) ((sv).value)
#define S_TRI(sv) ((sv).tri)
#define S_EQ(sv1, sv2) (S_VAL(sv1) == S_VAL(sv2) || !strcmp(S_VAL(sv1), S_VAL(sv2)))
struct symbol_value { struct symbol_value {
void *value; void *val;
tristate tri; tristate tri;
}; };
...@@ -83,31 +67,16 @@ struct symbol { ...@@ -83,31 +67,16 @@ struct symbol {
struct symbol *next; struct symbol *next;
char *name; char *name;
char *help; char *help;
#ifdef CML1
int type;
#else
enum symbol_type type; enum symbol_type type;
#endif struct symbol_value curr, user;
struct symbol_value curr, def;
tristate visible; tristate visible;
int flags; int flags;
struct property *prop; struct property *prop;
struct expr *dep, *dep2; struct expr *dep, *dep2;
struct menu *menu;
}; };
#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 < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
#ifdef CML1
#define SYMBOL_UNKNOWN S_UNKNOWN
#define SYMBOL_BOOLEAN S_BOOLEAN
#define SYMBOL_TRISTATE S_TRISTATE
#define SYMBOL_INT S_INT
#define SYMBOL_HEX S_HEX
#define SYMBOL_STRING S_STRING
#define SYMBOL_OTHER S_OTHER
#endif
#define SYMBOL_YES 0x0001 #define SYMBOL_YES 0x0001
#define SYMBOL_MOD 0x0002 #define SYMBOL_MOD 0x0002
#define SYMBOL_NO 0x0004 #define SYMBOL_NO 0x0004
...@@ -134,22 +103,14 @@ enum prop_type { ...@@ -134,22 +103,14 @@ enum prop_type {
struct property { struct property {
struct property *next; struct property *next;
struct symbol *sym; struct symbol *sym;
#ifdef CML1
int token;
#else
enum prop_type type; enum prop_type type;
#endif
const char *text; const char *text;
struct symbol *def; struct symbol *def;
struct expr_value visible; struct expr_value visible;
struct expr *dep; struct expr *expr;
struct expr *dep2;
struct menu *menu; struct menu *menu;
struct file *file; struct file *file;
int lineno; int lineno;
#ifdef CML1
struct property *next_pos;
#endif
}; };
#define for_all_properties(sym, st, tok) \ #define for_all_properties(sym, st, tok) \
...@@ -186,17 +147,10 @@ struct file *lookup_file(const char *name); ...@@ -186,17 +147,10 @@ struct file *lookup_file(const char *name);
extern struct symbol symbol_yes, symbol_no, symbol_mod; extern struct symbol symbol_yes, symbol_no, symbol_mod;
extern struct symbol *modules_sym; extern struct symbol *modules_sym;
extern int cdebug; extern int cdebug;
extern int print_type;
struct expr *expr_alloc_symbol(struct symbol *sym); struct expr *expr_alloc_symbol(struct symbol *sym);
#ifdef CML1
struct expr *expr_alloc_one(int token, struct expr *ce);
struct expr *expr_alloc_two(int token, struct expr *e1, struct expr *e2);
struct expr *expr_alloc_comp(int token, struct symbol *s1, struct symbol *s2);
#else
struct expr *expr_alloc_one(enum expr_type type, struct expr *ce); struct expr *expr_alloc_one(enum expr_type type, struct expr *ce);
struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2); struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2);
struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2);
#endif
struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
struct expr *expr_copy(struct expr *org); struct expr *expr_copy(struct expr *org);
void expr_free(struct expr *e); void expr_free(struct expr *e);
...@@ -217,17 +171,6 @@ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symb ...@@ -217,17 +171,6 @@ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symb
void expr_fprint(struct expr *e, FILE *out); void expr_fprint(struct expr *e, FILE *out);
void print_expr(int mask, struct expr *e, int prevtoken); void print_expr(int mask, struct expr *e, int prevtoken);
#ifdef CML1
static inline int expr_is_yes(struct expr *e)
{
return !e || (e->token == WORD && e->left.sym == &symbol_yes);
}
static inline int expr_is_no(struct expr *e)
{
return e && (e->token == WORD && e->left.sym == &symbol_no);
}
#else
static inline int expr_is_yes(struct expr *e) static inline int expr_is_yes(struct expr *e)
{ {
return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes); return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes);
...@@ -238,7 +181,6 @@ static inline int expr_is_no(struct expr *e) ...@@ -238,7 +181,6 @@ static inline int expr_is_no(struct expr *e)
return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no);
} }
#endif #endif
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -51,7 +51,7 @@ void menu_add_entry(struct symbol *sym); ...@@ -51,7 +51,7 @@ void menu_add_entry(struct symbol *sym);
void menu_end_entry(void); void menu_end_entry(void);
struct property *create_prop(enum prop_type type); struct property *create_prop(enum prop_type type);
void menu_add_dep(struct expr *dep); void menu_add_dep(struct expr *dep);
struct property *menu_add_prop(int token, char *prompt, struct symbol *def, struct expr *dep); struct property *menu_add_prop(enum prop_type type, char *prompt, struct symbol *def, struct expr *dep);
void menu_finalize(struct menu *parent); void menu_finalize(struct menu *parent);
void menu_set_type(int type); void menu_set_type(int type);
struct file *file_lookup(const char *name); struct file *file_lookup(const char *name);
...@@ -67,13 +67,13 @@ void sym_set_changed(struct symbol *sym); ...@@ -67,13 +67,13 @@ void sym_set_changed(struct symbol *sym);
static inline tristate sym_get_tristate_value(struct symbol *sym) static inline tristate sym_get_tristate_value(struct symbol *sym)
{ {
return S_TRI(sym->curr); return sym->curr.tri;
} }
static inline struct symbol *sym_get_choice_value(struct symbol *sym) static inline struct symbol *sym_get_choice_value(struct symbol *sym)
{ {
return (struct symbol *)S_VAL(sym->curr); return (struct symbol *)sym->curr.val;
} }
static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval) static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval)
...@@ -98,7 +98,6 @@ static inline bool sym_is_optional(struct symbol *sym) ...@@ -98,7 +98,6 @@ static inline bool sym_is_optional(struct symbol *sym)
static inline bool sym_has_value(struct symbol *sym) static inline bool sym_has_value(struct symbol *sym)
{ {
//return S_VAL(sym->def) != NULL;
return sym->flags & SYMBOL_NEW ? false : true; return sym->flags & SYMBOL_NEW ? false : true;
} }
......
...@@ -18,9 +18,9 @@ P(sym_change_count,int,); ...@@ -18,9 +18,9 @@ P(sym_change_count,int,);
P(sym_lookup,struct symbol *,(const char *name, int isconst)); P(sym_lookup,struct symbol *,(const char *name, int isconst));
P(sym_find,struct symbol *,(const char *name)); P(sym_find,struct symbol *,(const char *name));
P(sym_type_name,const char *,(int type)); P(sym_type_name,const char *,(enum symbol_type type));
P(sym_calc_value,void,(struct symbol *sym)); P(sym_calc_value,void,(struct symbol *sym));
P(sym_get_type,int,(struct symbol *sym)); P(sym_get_type,enum symbol_type,(struct symbol *sym));
P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri)); P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri));
P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri)); P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri));
P(sym_toggle_tristate_value,tristate,(struct symbol *sym)); P(sym_toggle_tristate_value,tristate,(struct symbol *sym));
......
...@@ -112,16 +112,16 @@ struct property *create_prop(enum prop_type type) ...@@ -112,16 +112,16 @@ struct property *create_prop(enum prop_type type)
return prop; return prop;
} }
struct property *menu_add_prop(int token, char *prompt, struct symbol *def, struct expr *dep) struct property *menu_add_prop(enum prop_type type, char *prompt, struct symbol *def, struct expr *dep)
{ {
struct property *prop = create_prop(token); struct property *prop = create_prop(type);
struct property **propp; struct property **propp;
prop->sym = current_entry->sym; prop->sym = current_entry->sym;
prop->menu = current_entry; prop->menu = current_entry;
prop->text = prompt; prop->text = prompt;
prop->def = def; prop->def = def;
E_EXPR(prop->visible) = menu_check_dep(dep); prop->visible.expr = menu_check_dep(dep);
if (prompt) if (prompt)
current_entry->prompt = prop; current_entry->prompt = prop;
...@@ -136,14 +136,14 @@ struct property *menu_add_prop(int token, char *prompt, struct symbol *def, stru ...@@ -136,14 +136,14 @@ struct property *menu_add_prop(int token, char *prompt, struct symbol *def, stru
return prop; return prop;
} }
void menu_add_prompt(int token, char *prompt, struct expr *dep) void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep)
{ {
current_entry->prompt = menu_add_prop(token, prompt, NULL, dep); current_entry->prompt = menu_add_prop(type, prompt, NULL, dep);
} }
void menu_add_default(int token, struct symbol *def, struct expr *dep) void menu_add_default(enum prop_type type, struct symbol *def, struct expr *dep)
{ {
current_entry->prompt = menu_add_prop(token, NULL, def, dep); current_entry->prompt = menu_add_prop(type, NULL, def, dep);
} }
void menu_finalize(struct menu *parent) void menu_finalize(struct menu *parent)
...@@ -168,7 +168,7 @@ void menu_finalize(struct menu *parent) ...@@ -168,7 +168,7 @@ void menu_finalize(struct menu *parent)
} }
parentdep = expr_alloc_symbol(sym); parentdep = expr_alloc_symbol(sym);
} else if (parent->prompt) } else if (parent->prompt)
parentdep = E_EXPR(parent->prompt->visible); parentdep = parent->prompt->visible.expr;
else else
parentdep = parent->dep; parentdep = parent->dep;
...@@ -184,23 +184,23 @@ void menu_finalize(struct menu *parent) ...@@ -184,23 +184,23 @@ void menu_finalize(struct menu *parent)
for (; prop; prop = prop->next) { for (; prop; prop = prop->next) {
if (prop->menu != menu) if (prop->menu != menu)
continue; continue;
dep = expr_transform(E_EXPR(prop->visible)); dep = expr_transform(prop->visible.expr);
dep = expr_alloc_and(expr_copy(basedep), dep); dep = expr_alloc_and(expr_copy(basedep), dep);
dep = expr_eliminate_dups(dep); dep = expr_eliminate_dups(dep);
if (menu->sym && menu->sym->type != S_TRISTATE) if (menu->sym && menu->sym->type != S_TRISTATE)
dep = expr_trans_bool(dep); dep = expr_trans_bool(dep);
E_EXPR(prop->visible) = dep; prop->visible.expr = dep;
} }
} }
for (menu = parent->list; menu; menu = menu->next) for (menu = parent->list; menu; menu = menu->next)
menu_finalize(menu); menu_finalize(menu);
} else if (sym) { } else if (sym) {
basedep = parent->prompt ? E_EXPR(parent->prompt->visible) : NULL; basedep = parent->prompt ? parent->prompt->visible.expr : NULL;
basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
basedep = expr_eliminate_dups(expr_transform(basedep)); basedep = expr_eliminate_dups(expr_transform(basedep));
last_menu = NULL; last_menu = NULL;
for (menu = parent->next; menu; menu = menu->next) { for (menu = parent->next; menu; menu = menu->next) {
dep = menu->prompt ? E_EXPR(menu->prompt->visible) : menu->dep; dep = menu->prompt ? menu->prompt->visible.expr : menu->dep;
if (!expr_contains_symbol(dep, sym)) if (!expr_contains_symbol(dep, sym))
break; break;
if (expr_depends_symbol(dep, sym)) if (expr_depends_symbol(dep, sym))
...@@ -233,10 +233,8 @@ void menu_finalize(struct menu *parent) ...@@ -233,10 +233,8 @@ void menu_finalize(struct menu *parent)
menu_set_type(sym->type); menu_set_type(sym->type);
menu_add_prop(P_CHOICE, NULL, parent->sym, NULL); menu_add_prop(P_CHOICE, NULL, parent->sym, NULL);
prop = sym_get_choice_prop(parent->sym); prop = sym_get_choice_prop(parent->sym);
//dep = expr_alloc_one(E_CHOICE, dep); prop->expr = expr_alloc_one(E_CHOICE, prop->expr);
//dep->right.sym = menu->sym; prop->expr->right.sym = menu->sym;
prop->dep = expr_alloc_one(E_CHOICE, prop->dep);
prop->dep->right.sym = menu->sym;
} }
if (menu->list && (!menu->prompt || !menu->prompt->text)) { if (menu->list && (!menu->prompt || !menu->prompt->text)) {
for (last_menu = menu->list; ; last_menu = last_menu->next) { for (last_menu = menu->list; ; last_menu = last_menu->next) {
...@@ -259,9 +257,9 @@ bool menu_is_visible(struct menu *menu) ...@@ -259,9 +257,9 @@ bool menu_is_visible(struct menu *menu)
return false; return false;
if (menu->sym) { if (menu->sym) {
sym_calc_value(menu->sym); sym_calc_value(menu->sym);
visible = E_TRI(menu->prompt->visible); visible = menu->prompt->visible.tri;
} else } else
visible = E_CALC(menu->prompt->visible); visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr);
return visible != no; return visible != no;
} }
......
...@@ -81,22 +81,23 @@ void sym_init(void) ...@@ -81,22 +81,23 @@ void sym_init(void)
sym_add_default(sym, uts.release); sym_add_default(sym, uts.release);
} }
int sym_get_type(struct symbol *sym) enum symbol_type sym_get_type(struct symbol *sym)
{ {
int type = sym->type; enum symbol_type type = sym->type;
if (type == S_TRISTATE) { if (type == S_TRISTATE) {
if (sym_is_choice_value(sym) && sym->visible == yes) if (sym_is_choice_value(sym) && sym->visible == yes)
type = S_BOOLEAN; type = S_BOOLEAN;
else { else {
sym_calc_value(modules_sym); sym_calc_value(modules_sym);
if (S_TRI(modules_sym->curr) == no) if (modules_sym->curr.tri == no)
type = S_BOOLEAN; type = S_BOOLEAN;
} }
} }
return type; return type;
} }
const char *sym_type_name(int type) const char *sym_type_name(enum symbol_type type)
{ {
switch (type) { switch (type) {
case S_BOOLEAN: case S_BOOLEAN:
...@@ -111,6 +112,8 @@ const char *sym_type_name(int type) ...@@ -111,6 +112,8 @@ const char *sym_type_name(int type)
return "string"; return "string";
case S_UNKNOWN: case S_UNKNOWN:
return "unknown"; return "unknown";
case S_OTHER:
break;
} }
return "???"; return "???";
} }
...@@ -127,11 +130,10 @@ struct property *sym_get_choice_prop(struct symbol *sym) ...@@ -127,11 +130,10 @@ struct property *sym_get_choice_prop(struct symbol *sym)
struct property *sym_get_default_prop(struct symbol *sym) struct property *sym_get_default_prop(struct symbol *sym)
{ {
struct property *prop; struct property *prop;
tristate visible;
for_all_defaults(sym, prop) { for_all_defaults(sym, prop) {
visible = E_CALC(prop->visible); prop->visible.tri = expr_calc_value(prop->visible.expr);
if (visible != no) if (prop->visible.tri != no)
return prop; return prop;
} }
return NULL; return NULL;
...@@ -145,8 +147,10 @@ void sym_calc_visibility(struct symbol *sym) ...@@ -145,8 +147,10 @@ void sym_calc_visibility(struct symbol *sym)
/* any prompt visible? */ /* any prompt visible? */
oldvisible = sym->visible; oldvisible = sym->visible;
visible = no; visible = no;
for_all_prompts(sym, prop) for_all_prompts(sym, prop) {
visible = E_OR(visible, E_CALC(prop->visible)); prop->visible.tri = expr_calc_value(prop->visible.expr);
visible = E_OR(visible, prop->visible.tri);
}
if (oldvisible != visible) { if (oldvisible != visible) {
sym->visible = visible; sym->visible = visible;
sym_set_changed(sym); sym_set_changed(sym);
...@@ -179,14 +183,8 @@ void sym_calc_value(struct symbol *sym) ...@@ -179,14 +183,8 @@ void sym_calc_value(struct symbol *sym)
newval = symbol_no.curr; newval = symbol_no.curr;
break; break;
default: default:
S_VAL(newval) = sym->name; newval.val = sym->name;
S_TRI(newval) = no; newval.tri = no;
if (sym->flags & SYMBOL_CONST) {
goto out;
}
//newval = symbol_empty.curr;
// generate warning somewhere here later
//S_TRI(newval) = yes;
goto out; goto out;
} }
sym->flags |= SYMBOL_VALID; sym->flags |= SYMBOL_VALID;
...@@ -208,18 +206,18 @@ void sym_calc_value(struct symbol *sym) ...@@ -208,18 +206,18 @@ void sym_calc_value(struct symbol *sym)
newval = prop->def->curr; newval = prop->def->curr;
} }
} else } else
S_TRI(newval) = S_TRI(sym->def); newval.tri = sym->user.tri;
} else } else
newval = sym->def; newval = sym->user;
S_TRI(newval) = E_AND(S_TRI(newval), sym->visible); newval.tri = E_AND(newval.tri, sym->visible);
/* if the symbol is visible and not optionial, /* if the symbol is visible and not optionial,
* possibly ignore old user choice. */ * possibly ignore old user choice. */
if (!sym_is_optional(sym) && S_TRI(newval) == no) if (!sym_is_optional(sym) && newval.tri == no)
S_TRI(newval) = sym->visible; newval.tri = sym->visible;
if (sym_is_choice_value(sym) && sym->visible == yes) { if (sym_is_choice_value(sym) && sym->visible == yes) {
prop = sym_get_choice_prop(sym); prop = sym_get_choice_prop(sym);
S_TRI(newval) = (S_VAL(prop->def->curr) == sym) ? yes : no; newval.tri = (prop->def->curr.val == sym) ? yes : no;
} }
} else { } else {
prop = sym_get_default_prop(sym); prop = sym_get_default_prop(sym);
...@@ -232,22 +230,25 @@ void sym_calc_value(struct symbol *sym) ...@@ -232,22 +230,25 @@ void sym_calc_value(struct symbol *sym)
switch (sym_get_type(sym)) { switch (sym_get_type(sym)) {
case S_TRISTATE: case S_TRISTATE:
if (S_TRI(newval) != mod) if (newval.tri != mod)
break; break;
sym_calc_value(modules_sym); sym_calc_value(modules_sym);
if (S_TRI(modules_sym->curr) == no) if (modules_sym->curr.tri == no)
S_TRI(newval) = yes; newval.tri = yes;
break; break;
case S_BOOLEAN: case S_BOOLEAN:
if (S_TRI(newval) == mod) if (newval.tri == mod)
S_TRI(newval) = yes; newval.tri = yes;
break;
default:
break;
} }
out: out:
sym->curr = newval; sym->curr = newval;
if (sym_is_choice(sym) && S_TRI(newval) == yes) { if (sym_is_choice(sym) && newval.tri == yes) {
def_sym = S_VAL(sym->def); def_sym = sym->user.val;
if (def_sym) { if (def_sym) {
sym_calc_visibility(def_sym); sym_calc_visibility(def_sym);
if (def_sym->visible == no) if (def_sym->visible == no)
...@@ -255,7 +256,8 @@ void sym_calc_value(struct symbol *sym) ...@@ -255,7 +256,8 @@ void sym_calc_value(struct symbol *sym)
} }
if (!def_sym) { if (!def_sym) {
for_all_defaults(sym, def_prop) { for_all_defaults(sym, def_prop) {
if (E_CALC(def_prop->visible) == no) def_prop->visible.tri = expr_calc_value(def_prop->visible.expr);
if (def_prop->visible.tri == no)
continue; continue;
sym_calc_visibility(def_prop->def); sym_calc_visibility(def_prop->def);
if (def_prop->def->visible != no) { if (def_prop->def->visible != no) {
...@@ -267,7 +269,7 @@ void sym_calc_value(struct symbol *sym) ...@@ -267,7 +269,7 @@ void sym_calc_value(struct symbol *sym)
if (!def_sym) { if (!def_sym) {
prop = sym_get_choice_prop(sym); prop = sym_get_choice_prop(sym);
for (e = prop->dep; e; e = e->left.expr) { for (e = prop->expr; e; e = e->left.expr) {
sym_calc_visibility(e->right.sym); sym_calc_visibility(e->right.sym);
if (e->right.sym->visible != no) { if (e->right.sym->visible != no) {
def_sym = e->right.sym; def_sym = e->right.sym;
...@@ -276,7 +278,7 @@ void sym_calc_value(struct symbol *sym) ...@@ -276,7 +278,7 @@ void sym_calc_value(struct symbol *sym)
} }
} }
S_VAL(newval) = def_sym; newval.val = def_sym;
} }
if (memcmp(&oldval, &newval, sizeof(newval))) if (memcmp(&oldval, &newval, sizeof(newval)))
...@@ -286,7 +288,7 @@ void sym_calc_value(struct symbol *sym) ...@@ -286,7 +288,7 @@ void sym_calc_value(struct symbol *sym)
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);
prop = sym_get_choice_prop(sym); prop = sym_get_choice_prop(sym);
for (e = prop->dep; e; e = e->left.expr) { for (e = prop->expr; e; e = e->left.expr) {
e->right.sym->flags |= flags; e->right.sym->flags |= flags;
if (flags & SYMBOL_CHANGED) if (flags & SYMBOL_CHANGED)
sym_set_changed(e->right.sym); sym_set_changed(e->right.sym);
...@@ -363,11 +365,11 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val) ...@@ -363,11 +365,11 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val)
if (sym_is_choice_value(sym) && val == yes) { if (sym_is_choice_value(sym) && val == yes) {
struct property *prop = sym_get_choice_prop(sym); struct property *prop = sym_get_choice_prop(sym);
S_VAL(prop->def->def) = sym; prop->def->user.val = sym;
prop->def->flags &= ~SYMBOL_NEW; prop->def->flags &= ~SYMBOL_NEW;
} }
S_TRI(sym->def) = val; sym->user.tri = val;
if (oldval != val) { if (oldval != val) {
sym_clear_all_valid(); sym_clear_all_valid();
if (sym == modules_sym) if (sym == modules_sym)
...@@ -432,14 +434,11 @@ bool sym_string_valid(struct symbol *sym, const char *str) ...@@ -432,14 +434,11 @@ bool sym_string_valid(struct symbol *sym, const char *str)
case S_BOOLEAN: case S_BOOLEAN:
case S_TRISTATE: case S_TRISTATE:
switch (str[0]) { switch (str[0]) {
case 'y': case 'y': case 'Y':
case 'Y':
return sym_tristate_within_range(sym, yes); return sym_tristate_within_range(sym, yes);
case 'm': case 'm': case 'M':
case 'M':
return sym_tristate_within_range(sym, mod); return sym_tristate_within_range(sym, mod);
case 'n': case 'n': case 'N':
case 'N':
return sym_tristate_within_range(sym, no); return sym_tristate_within_range(sym, no);
} }
return false; return false;
...@@ -458,14 +457,11 @@ bool sym_set_string_value(struct symbol *sym, const char *newval) ...@@ -458,14 +457,11 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
case S_BOOLEAN: case S_BOOLEAN:
case S_TRISTATE: case S_TRISTATE:
switch (newval[0]) { switch (newval[0]) {
case 'y': case 'y': case 'Y':
case 'Y':
return sym_set_tristate_value(sym, yes); return sym_set_tristate_value(sym, yes);
case 'm': case 'm': case 'M':
case 'M':
return sym_set_tristate_value(sym, mod); return sym_set_tristate_value(sym, mod);
case 'n': case 'n': case 'N':
case 'N':
return sym_set_tristate_value(sym, no); return sym_set_tristate_value(sym, no);
} }
return false; return false;
...@@ -481,15 +477,15 @@ bool sym_set_string_value(struct symbol *sym, const char *newval) ...@@ -481,15 +477,15 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
sym_set_changed(sym); sym_set_changed(sym);
} }
oldval = S_VAL(sym->def); oldval = sym->user.val;
size = strlen(newval) + 1; size = strlen(newval) + 1;
if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) { if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
size += 2; size += 2;
S_VAL(sym->def) = val = malloc(size); sym->user.val = val = malloc(size);
*val++ = '0'; *val++ = '0';
*val++ = 'x'; *val++ = 'x';
} else if (!oldval || strcmp(oldval, newval)) } else if (!oldval || strcmp(oldval, newval))
S_VAL(sym->def) = val = malloc(size); sym->user.val = val = malloc(size);
else else
return true; return true;
...@@ -520,7 +516,7 @@ const char *sym_get_string_value(struct symbol *sym) ...@@ -520,7 +516,7 @@ const char *sym_get_string_value(struct symbol *sym)
default: default:
; ;
} }
return (const char *)S_VAL(sym->curr); return (const char *)sym->curr.val;
} }
bool sym_is_changable(struct symbol *sym) bool sym_is_changable(struct symbol *sym)
......
...@@ -1931,8 +1931,6 @@ void print_symbol(FILE *out, struct menu *menu) ...@@ -1931,8 +1931,6 @@ void print_symbol(FILE *out, struct menu *menu)
struct symbol *sym = menu->sym; struct symbol *sym = menu->sym;
struct property *prop; struct property *prop;
//sym->flags |= SYMBOL_PRINTED;
if (sym_is_choice(sym)) if (sym_is_choice(sym))
fprintf(out, "choice\n"); fprintf(out, "choice\n");
else else
...@@ -1957,13 +1955,6 @@ void print_symbol(FILE *out, struct menu *menu) ...@@ -1957,13 +1955,6 @@ void print_symbol(FILE *out, struct menu *menu)
fputs(" ???\n", out); fputs(" ???\n", out);
break; break;
} }
#if 0
if (!expr_is_yes(sym->dep)) {
fputs(" depends ", out);
expr_fprint(sym->dep, out);
fputc('\n', out);
}
#endif
for (prop = sym->prop; prop; prop = prop->next) { for (prop = sym->prop; prop; prop = prop->next) {
if (prop->menu != menu) if (prop->menu != menu)
continue; continue;
...@@ -1971,25 +1962,18 @@ void print_symbol(FILE *out, struct menu *menu) ...@@ -1971,25 +1962,18 @@ void print_symbol(FILE *out, struct menu *menu)
case P_PROMPT: case P_PROMPT:
fputs(" prompt ", out); fputs(" prompt ", out);
print_quoted_string(out, prop->text); print_quoted_string(out, prop->text);
if (prop->def) { if (!expr_is_yes(prop->visible.expr)) {
fputc(' ', out);
if (prop->def->flags & SYMBOL_CONST)
print_quoted_string(out, prop->def->name);
else
fputs(prop->def->name, out);
}
if (!expr_is_yes(E_EXPR(prop->visible))) {
fputs(" if ", out); fputs(" if ", out);
expr_fprint(E_EXPR(prop->visible), out); expr_fprint(prop->visible.expr, out);
} }
fputc('\n', out); fputc('\n', out);
break; break;
case P_DEFAULT: case P_DEFAULT:
fputs( " default ", out); fputs( " default ", out);
print_quoted_string(out, prop->def->name); print_quoted_string(out, prop->def->name);
if (!expr_is_yes(E_EXPR(prop->visible))) { if (!expr_is_yes(prop->visible.expr)) {
fputs(" if ", out); fputs(" if ", out);
expr_fprint(E_EXPR(prop->visible), out); expr_fprint(prop->visible.expr, out);
} }
fputc('\n', out); fputc('\n', out);
break; break;
...@@ -2012,7 +1996,6 @@ void print_symbol(FILE *out, struct menu *menu) ...@@ -2012,7 +1996,6 @@ void print_symbol(FILE *out, struct menu *menu)
void zconfdump(FILE *out) void zconfdump(FILE *out)
{ {
//struct file *file;
struct property *prop; struct property *prop;
struct symbol *sym; struct symbol *sym;
struct menu *menu; struct menu *menu;
...@@ -2023,11 +2006,6 @@ void zconfdump(FILE *out) ...@@ -2023,11 +2006,6 @@ void zconfdump(FILE *out)
print_symbol(out, menu); print_symbol(out, menu);
else if ((prop = menu->prompt)) { else if ((prop = menu->prompt)) {
switch (prop->type) { switch (prop->type) {
//case T_MAINMENU:
// fputs("\nmainmenu ", out);
// print_quoted_string(out, prop->text);
// fputs("\n", out);
// break;
case P_COMMENT: case P_COMMENT:
fputs("\ncomment ", out); fputs("\ncomment ", out);
print_quoted_string(out, prop->text); print_quoted_string(out, prop->text);
...@@ -2038,19 +2016,12 @@ void zconfdump(FILE *out) ...@@ -2038,19 +2016,12 @@ void zconfdump(FILE *out)
print_quoted_string(out, prop->text); print_quoted_string(out, prop->text);
fputs("\n", out); fputs("\n", out);
break; break;
//case T_SOURCE:
// fputs("\nsource ", out);
// print_quoted_string(out, prop->text);
// fputs("\n", out);
// break;
//case T_IF:
// fputs("\nif\n", out);
default: default:
; ;
} }
if (!expr_is_yes(E_EXPR(prop->visible))) { if (!expr_is_yes(prop->visible.expr)) {
fputs(" depends ", out); fputs(" depends ", out);
expr_fprint(E_EXPR(prop->visible), out); expr_fprint(prop->visible.expr, out);
fputc('\n', out); fputc('\n', out);
} }
fputs("\n", out); fputs("\n", out);
......
...@@ -522,8 +522,6 @@ void print_symbol(FILE *out, struct menu *menu) ...@@ -522,8 +522,6 @@ void print_symbol(FILE *out, struct menu *menu)
struct symbol *sym = menu->sym; struct symbol *sym = menu->sym;
struct property *prop; struct property *prop;
//sym->flags |= SYMBOL_PRINTED;
if (sym_is_choice(sym)) if (sym_is_choice(sym))
fprintf(out, "choice\n"); fprintf(out, "choice\n");
else else
...@@ -548,13 +546,6 @@ void print_symbol(FILE *out, struct menu *menu) ...@@ -548,13 +546,6 @@ void print_symbol(FILE *out, struct menu *menu)
fputs(" ???\n", out); fputs(" ???\n", out);
break; break;
} }
#if 0
if (!expr_is_yes(sym->dep)) {
fputs(" depends ", out);
expr_fprint(sym->dep, out);
fputc('\n', out);
}
#endif
for (prop = sym->prop; prop; prop = prop->next) { for (prop = sym->prop; prop; prop = prop->next) {
if (prop->menu != menu) if (prop->menu != menu)
continue; continue;
...@@ -562,25 +553,18 @@ void print_symbol(FILE *out, struct menu *menu) ...@@ -562,25 +553,18 @@ void print_symbol(FILE *out, struct menu *menu)
case P_PROMPT: case P_PROMPT:
fputs(" prompt ", out); fputs(" prompt ", out);
print_quoted_string(out, prop->text); print_quoted_string(out, prop->text);
if (prop->def) { if (!expr_is_yes(prop->visible.expr)) {
fputc(' ', out);
if (prop->def->flags & SYMBOL_CONST)
print_quoted_string(out, prop->def->name);
else
fputs(prop->def->name, out);
}
if (!expr_is_yes(E_EXPR(prop->visible))) {
fputs(" if ", out); fputs(" if ", out);
expr_fprint(E_EXPR(prop->visible), out); expr_fprint(prop->visible.expr, out);
} }
fputc('\n', out); fputc('\n', out);
break; break;
case P_DEFAULT: case P_DEFAULT:
fputs( " default ", out); fputs( " default ", out);
print_quoted_string(out, prop->def->name); print_quoted_string(out, prop->def->name);
if (!expr_is_yes(E_EXPR(prop->visible))) { if (!expr_is_yes(prop->visible.expr)) {
fputs(" if ", out); fputs(" if ", out);
expr_fprint(E_EXPR(prop->visible), out); expr_fprint(prop->visible.expr, out);
} }
fputc('\n', out); fputc('\n', out);
break; break;
...@@ -603,7 +587,6 @@ void print_symbol(FILE *out, struct menu *menu) ...@@ -603,7 +587,6 @@ void print_symbol(FILE *out, struct menu *menu)
void zconfdump(FILE *out) void zconfdump(FILE *out)
{ {
//struct file *file;
struct property *prop; struct property *prop;
struct symbol *sym; struct symbol *sym;
struct menu *menu; struct menu *menu;
...@@ -614,11 +597,6 @@ void zconfdump(FILE *out) ...@@ -614,11 +597,6 @@ void zconfdump(FILE *out)
print_symbol(out, menu); print_symbol(out, menu);
else if ((prop = menu->prompt)) { else if ((prop = menu->prompt)) {
switch (prop->type) { switch (prop->type) {
//case T_MAINMENU:
// fputs("\nmainmenu ", out);
// print_quoted_string(out, prop->text);
// fputs("\n", out);
// break;
case P_COMMENT: case P_COMMENT:
fputs("\ncomment ", out); fputs("\ncomment ", out);
print_quoted_string(out, prop->text); print_quoted_string(out, prop->text);
...@@ -629,19 +607,12 @@ void zconfdump(FILE *out) ...@@ -629,19 +607,12 @@ void zconfdump(FILE *out)
print_quoted_string(out, prop->text); print_quoted_string(out, prop->text);
fputs("\n", out); fputs("\n", out);
break; break;
//case T_SOURCE:
// fputs("\nsource ", out);
// print_quoted_string(out, prop->text);
// fputs("\n", out);
// break;
//case T_IF:
// fputs("\nif\n", out);
default: default:
; ;
} }
if (!expr_is_yes(E_EXPR(prop->visible))) { if (!expr_is_yes(prop->visible.expr)) {
fputs(" depends ", out); fputs(" depends ", out);
expr_fprint(E_EXPR(prop->visible), out); expr_fprint(prop->visible.expr, out);
fputc('\n', out); fputc('\n', out);
} }
fputs("\n", out); fputs("\n", out);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment