aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/expr.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/expr.c')
-rw-r--r--scripts/kconfig/expr.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index 30e4f9d69c2f..6f98dbfe70cf 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -145,7 +145,8 @@ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct e
145 return; 145 return;
146 } 146 }
147 if (e1->type == E_SYMBOL && e2->type == E_SYMBOL && 147 if (e1->type == E_SYMBOL && e2->type == E_SYMBOL &&
148 e1->left.sym == e2->left.sym && (e1->left.sym->flags & (SYMBOL_YES|SYMBOL_NO))) 148 e1->left.sym == e2->left.sym &&
149 (e1->left.sym == &symbol_yes || e1->left.sym == &symbol_no))
149 return; 150 return;
150 if (!expr_eq(e1, e2)) 151 if (!expr_eq(e1, e2))
151 return; 152 return;
@@ -1012,73 +1013,73 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2)
1012#endif 1013#endif
1013} 1014}
1014 1015
1015void expr_print(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken) 1016void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
1016{ 1017{
1017 if (!e) { 1018 if (!e) {
1018 fn(data, "y"); 1019 fn(data, NULL, "y");
1019 return; 1020 return;
1020 } 1021 }
1021 1022
1022 if (expr_compare_type(prevtoken, e->type) > 0) 1023 if (expr_compare_type(prevtoken, e->type) > 0)
1023 fn(data, "("); 1024 fn(data, NULL, "(");
1024 switch (e->type) { 1025 switch (e->type) {
1025 case E_SYMBOL: 1026 case E_SYMBOL:
1026 if (e->left.sym->name) 1027 if (e->left.sym->name)
1027 fn(data, e->left.sym->name); 1028 fn(data, e->left.sym, e->left.sym->name);
1028 else 1029 else
1029 fn(data, "<choice>"); 1030 fn(data, NULL, "<choice>");
1030 break; 1031 break;
1031 case E_NOT: 1032 case E_NOT:
1032 fn(data, "!"); 1033 fn(data, NULL, "!");
1033 expr_print(e->left.expr, fn, data, E_NOT); 1034 expr_print(e->left.expr, fn, data, E_NOT);
1034 break; 1035 break;
1035 case E_EQUAL: 1036 case E_EQUAL:
1036 fn(data, e->left.sym->name); 1037 fn(data, e->left.sym, e->left.sym->name);
1037 fn(data, "="); 1038 fn(data, NULL, "=");
1038 fn(data, e->right.sym->name); 1039 fn(data, e->right.sym, e->right.sym->name);
1039 break; 1040 break;
1040 case E_UNEQUAL: 1041 case E_UNEQUAL:
1041 fn(data, e->left.sym->name); 1042 fn(data, e->left.sym, e->left.sym->name);
1042 fn(data, "!="); 1043 fn(data, NULL, "!=");
1043 fn(data, e->right.sym->name); 1044 fn(data, e->right.sym, e->right.sym->name);
1044 break; 1045 break;
1045 case E_OR: 1046 case E_OR:
1046 expr_print(e->left.expr, fn, data, E_OR); 1047 expr_print(e->left.expr, fn, data, E_OR);
1047 fn(data, " || "); 1048 fn(data, NULL, " || ");
1048 expr_print(e->right.expr, fn, data, E_OR); 1049 expr_print(e->right.expr, fn, data, E_OR);
1049 break; 1050 break;
1050 case E_AND: 1051 case E_AND:
1051 expr_print(e->left.expr, fn, data, E_AND); 1052 expr_print(e->left.expr, fn, data, E_AND);
1052 fn(data, " && "); 1053 fn(data, NULL, " && ");
1053 expr_print(e->right.expr, fn, data, E_AND); 1054 expr_print(e->right.expr, fn, data, E_AND);
1054 break; 1055 break;
1055 case E_CHOICE: 1056 case E_CHOICE:
1056 fn(data, e->right.sym->name); 1057 fn(data, e->right.sym, e->right.sym->name);
1057 if (e->left.expr) { 1058 if (e->left.expr) {
1058 fn(data, " ^ "); 1059 fn(data, NULL, " ^ ");
1059 expr_print(e->left.expr, fn, data, E_CHOICE); 1060 expr_print(e->left.expr, fn, data, E_CHOICE);
1060 } 1061 }
1061 break; 1062 break;
1062 case E_RANGE: 1063 case E_RANGE:
1063 fn(data, "["); 1064 fn(data, NULL, "[");
1064 fn(data, e->left.sym->name); 1065 fn(data, e->left.sym, e->left.sym->name);
1065 fn(data, " "); 1066 fn(data, NULL, " ");
1066 fn(data, e->right.sym->name); 1067 fn(data, e->right.sym, e->right.sym->name);
1067 fn(data, "]"); 1068 fn(data, NULL, "]");
1068 break; 1069 break;
1069 default: 1070 default:
1070 { 1071 {
1071 char buf[32]; 1072 char buf[32];
1072 sprintf(buf, "<unknown type %d>", e->type); 1073 sprintf(buf, "<unknown type %d>", e->type);
1073 fn(data, buf); 1074 fn(data, NULL, buf);
1074 break; 1075 break;
1075 } 1076 }
1076 } 1077 }
1077 if (expr_compare_type(prevtoken, e->type) > 0) 1078 if (expr_compare_type(prevtoken, e->type) > 0)
1078 fn(data, ")"); 1079 fn(data, NULL, ")");
1079} 1080}
1080 1081
1081static void expr_print_file_helper(void *data, const char *str) 1082static void expr_print_file_helper(void *data, struct symbol *sym, const char *str)
1082{ 1083{
1083 fwrite(str, strlen(str), 1, data); 1084 fwrite(str, strlen(str), 1, data);
1084} 1085}
@@ -1088,7 +1089,7 @@ void expr_fprint(struct expr *e, FILE *out)
1088 expr_print(e, expr_print_file_helper, out, E_NONE); 1089 expr_print(e, expr_print_file_helper, out, E_NONE);
1089} 1090}
1090 1091
1091static void expr_print_gstr_helper(void *data, const char *str) 1092static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str)
1092{ 1093{
1093 str_append((struct gstr*)data, str); 1094 str_append((struct gstr*)data, str);
1094} 1095}