summaryrefslogtreecommitdiffstats
path: root/package/config/expr.c
diff options
context:
space:
mode:
Diffstat (limited to 'package/config/expr.c')
-rw-r--r--package/config/expr.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/package/config/expr.c b/package/config/expr.c
index 30e4f9d69..6f98dbfe7 100644
--- a/package/config/expr.c
+++ b/package/config/expr.c
@@ -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;
@@ -1012,73 +1013,73 @@ 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);
+ fn(data, e->left.sym, e->left.sym->name);
+ 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);
+ fn(data, e->left.sym, e->left.sym->name);
+ 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,7 +1089,7 @@ 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);
}