diff options
author | Roman Zippel <zippel@linux-m68k.org> | 2006-06-09 01:12:42 -0400 |
---|---|---|
committer | Sam Ravnborg <sam@mars.ravnborg.org> | 2006-06-09 01:31:30 -0400 |
commit | 669bfad906522e74ee8d962801552a8c224c0d63 (patch) | |
tree | 84b7e85d7d731b7f188c38d83139f9b6d4acaa56 | |
parent | 0c1822e6991a10da6dc391f0a2e2cf5fb2e31238 (diff) |
kconfig: allow loading multiple configurations
Extend conf_read_simple() so it can load multiple configurations.
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
-rw-r--r-- | scripts/kconfig/conf.c | 6 | ||||
-rw-r--r-- | scripts/kconfig/confdata.c | 111 | ||||
-rw-r--r-- | scripts/kconfig/expr.h | 6 | ||||
-rw-r--r-- | scripts/kconfig/gconf.c | 6 | ||||
-rw-r--r-- | scripts/kconfig/lkc.h | 2 | ||||
-rw-r--r-- | scripts/kconfig/lkc_proto.h | 2 | ||||
-rw-r--r-- | scripts/kconfig/symbol.c | 13 |
7 files changed, 84 insertions, 62 deletions
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 9334da65f36..ded5ffe184b 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c | |||
@@ -573,7 +573,7 @@ int main(int ac, char **av) | |||
573 | case set_random: | 573 | case set_random: |
574 | name = getenv("KCONFIG_ALLCONFIG"); | 574 | name = getenv("KCONFIG_ALLCONFIG"); |
575 | if (name && !stat(name, &tmpstat)) { | 575 | if (name && !stat(name, &tmpstat)) { |
576 | conf_read_simple(name); | 576 | conf_read_simple(name, S_DEF_USER); |
577 | break; | 577 | break; |
578 | } | 578 | } |
579 | switch (input_mode) { | 579 | switch (input_mode) { |
@@ -584,9 +584,9 @@ int main(int ac, char **av) | |||
584 | default: break; | 584 | default: break; |
585 | } | 585 | } |
586 | if (!stat(name, &tmpstat)) | 586 | if (!stat(name, &tmpstat)) |
587 | conf_read_simple(name); | 587 | conf_read_simple(name, S_DEF_USER); |
588 | else if (!stat("all.config", &tmpstat)) | 588 | else if (!stat("all.config", &tmpstat)) |
589 | conf_read_simple("all.config"); | 589 | conf_read_simple("all.config", S_DEF_USER); |
590 | break; | 590 | break; |
591 | default: | 591 | default: |
592 | break; | 592 | break; |
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 54ca1a786d2..ca693fcd023 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
@@ -86,13 +86,13 @@ char *conf_get_default_confname(void) | |||
86 | return name; | 86 | return name; |
87 | } | 87 | } |
88 | 88 | ||
89 | int conf_read_simple(const char *name) | 89 | int conf_read_simple(const char *name, int def) |
90 | { | 90 | { |
91 | FILE *in = NULL; | 91 | FILE *in = NULL; |
92 | char line[1024]; | 92 | char line[1024]; |
93 | char *p, *p2; | 93 | char *p, *p2; |
94 | struct symbol *sym; | 94 | struct symbol *sym; |
95 | int i; | 95 | int i, def_flags; |
96 | 96 | ||
97 | if (name) { | 97 | if (name) { |
98 | in = zconf_fopen(name); | 98 | in = zconf_fopen(name); |
@@ -125,20 +125,21 @@ load: | |||
125 | conf_warnings = 0; | 125 | conf_warnings = 0; |
126 | conf_unsaved = 0; | 126 | conf_unsaved = 0; |
127 | 127 | ||
128 | def_flags = SYMBOL_DEF << def; | ||
128 | for_all_symbols(i, sym) { | 129 | for_all_symbols(i, sym) { |
129 | sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED; | 130 | sym->flags |= SYMBOL_CHANGED; |
131 | sym->flags &= ~(def_flags|SYMBOL_VALID); | ||
130 | if (sym_is_choice(sym)) | 132 | if (sym_is_choice(sym)) |
131 | sym->flags &= ~SYMBOL_NEW; | 133 | sym->flags |= def_flags; |
132 | sym->flags &= ~SYMBOL_VALID; | ||
133 | switch (sym->type) { | 134 | switch (sym->type) { |
134 | case S_INT: | 135 | case S_INT: |
135 | case S_HEX: | 136 | case S_HEX: |
136 | case S_STRING: | 137 | case S_STRING: |
137 | if (sym->def[S_DEF_USER].val) | 138 | if (sym->def[def].val) |
138 | free(sym->def[S_DEF_USER].val); | 139 | free(sym->def[def].val); |
139 | default: | 140 | default: |
140 | sym->def[S_DEF_USER].val = NULL; | 141 | sym->def[def].val = NULL; |
141 | sym->def[S_DEF_USER].tri = no; | 142 | sym->def[def].tri = no; |
142 | } | 143 | } |
143 | } | 144 | } |
144 | 145 | ||
@@ -155,19 +156,26 @@ load: | |||
155 | *p++ = 0; | 156 | *p++ = 0; |
156 | if (strncmp(p, "is not set", 10)) | 157 | if (strncmp(p, "is not set", 10)) |
157 | continue; | 158 | continue; |
158 | sym = sym_find(line + 9); | 159 | if (def == S_DEF_USER) { |
159 | if (!sym) { | 160 | sym = sym_find(line + 9); |
160 | conf_warning("trying to assign nonexistent symbol %s", line + 9); | 161 | if (!sym) { |
161 | break; | 162 | conf_warning("trying to assign nonexistent symbol %s", line + 9); |
162 | } else if (!(sym->flags & SYMBOL_NEW)) { | 163 | break; |
164 | } | ||
165 | } else { | ||
166 | sym = sym_lookup(line + 9, 0); | ||
167 | if (sym->type == S_UNKNOWN) | ||
168 | sym->type = S_BOOLEAN; | ||
169 | } | ||
170 | if (sym->flags & def_flags) { | ||
163 | conf_warning("trying to reassign symbol %s", sym->name); | 171 | conf_warning("trying to reassign symbol %s", sym->name); |
164 | break; | 172 | break; |
165 | } | 173 | } |
166 | switch (sym->type) { | 174 | switch (sym->type) { |
167 | case S_BOOLEAN: | 175 | case S_BOOLEAN: |
168 | case S_TRISTATE: | 176 | case S_TRISTATE: |
169 | sym->def[S_DEF_USER].tri = no; | 177 | sym->def[def].tri = no; |
170 | sym->flags &= ~SYMBOL_NEW; | 178 | sym->flags |= def_flags; |
171 | break; | 179 | break; |
172 | default: | 180 | default: |
173 | ; | 181 | ; |
@@ -185,34 +193,48 @@ load: | |||
185 | p2 = strchr(p, '\n'); | 193 | p2 = strchr(p, '\n'); |
186 | if (p2) | 194 | if (p2) |
187 | *p2 = 0; | 195 | *p2 = 0; |
188 | sym = sym_find(line + 7); | 196 | if (def == S_DEF_USER) { |
189 | if (!sym) { | 197 | sym = sym_find(line + 7); |
190 | conf_warning("trying to assign nonexistent symbol %s", line + 7); | 198 | if (!sym) { |
191 | break; | 199 | conf_warning("trying to assign nonexistent symbol %s", line + 7); |
192 | } else if (!(sym->flags & SYMBOL_NEW)) { | 200 | break; |
201 | } | ||
202 | } else { | ||
203 | sym = sym_lookup(line + 7, 0); | ||
204 | if (sym->type == S_UNKNOWN) | ||
205 | sym->type = S_OTHER; | ||
206 | } | ||
207 | if (sym->flags & def_flags) { | ||
193 | conf_warning("trying to reassign symbol %s", sym->name); | 208 | conf_warning("trying to reassign symbol %s", sym->name); |
194 | break; | 209 | break; |
195 | } | 210 | } |
196 | switch (sym->type) { | 211 | switch (sym->type) { |
197 | case S_TRISTATE: | 212 | case S_TRISTATE: |
198 | if (p[0] == 'm') { | 213 | if (p[0] == 'm') { |
199 | sym->def[S_DEF_USER].tri = mod; | 214 | sym->def[def].tri = mod; |
200 | sym->flags &= ~SYMBOL_NEW; | 215 | sym->flags |= def_flags; |
201 | break; | 216 | break; |
202 | } | 217 | } |
203 | case S_BOOLEAN: | 218 | case S_BOOLEAN: |
204 | if (p[0] == 'y') { | 219 | if (p[0] == 'y') { |
205 | sym->def[S_DEF_USER].tri = yes; | 220 | sym->def[def].tri = yes; |
206 | sym->flags &= ~SYMBOL_NEW; | 221 | sym->flags |= def_flags; |
207 | break; | 222 | break; |
208 | } | 223 | } |
209 | if (p[0] == 'n') { | 224 | if (p[0] == 'n') { |
210 | sym->def[S_DEF_USER].tri = no; | 225 | sym->def[def].tri = no; |
211 | sym->flags &= ~SYMBOL_NEW; | 226 | sym->flags |= def_flags; |
212 | break; | 227 | break; |
213 | } | 228 | } |
214 | conf_warning("symbol value '%s' invalid for %s", p, sym->name); | 229 | conf_warning("symbol value '%s' invalid for %s", p, sym->name); |
215 | break; | 230 | break; |
231 | case S_OTHER: | ||
232 | if (*p != '"') { | ||
233 | for (p2 = p; *p2 && !isspace(*p2); p2++) | ||
234 | ; | ||
235 | sym->type = S_STRING; | ||
236 | goto done; | ||
237 | } | ||
216 | case S_STRING: | 238 | case S_STRING: |
217 | if (*p++ != '"') | 239 | if (*p++ != '"') |
218 | break; | 240 | break; |
@@ -229,9 +251,10 @@ load: | |||
229 | } | 251 | } |
230 | case S_INT: | 252 | case S_INT: |
231 | case S_HEX: | 253 | case S_HEX: |
254 | done: | ||
232 | if (sym_string_valid(sym, p)) { | 255 | if (sym_string_valid(sym, p)) { |
233 | sym->def[S_DEF_USER].val = strdup(p); | 256 | sym->def[def].val = strdup(p); |
234 | sym->flags &= ~SYMBOL_NEW; | 257 | sym->flags |= def_flags; |
235 | } else { | 258 | } else { |
236 | conf_warning("symbol value '%s' invalid for %s", p, sym->name); | 259 | conf_warning("symbol value '%s' invalid for %s", p, sym->name); |
237 | continue; | 260 | continue; |
@@ -249,24 +272,24 @@ load: | |||
249 | } | 272 | } |
250 | if (sym && sym_is_choice_value(sym)) { | 273 | if (sym && sym_is_choice_value(sym)) { |
251 | struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); | 274 | struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); |
252 | switch (sym->def[S_DEF_USER].tri) { | 275 | switch (sym->def[def].tri) { |
253 | case no: | 276 | case no: |
254 | break; | 277 | break; |
255 | case mod: | 278 | case mod: |
256 | if (cs->def[S_DEF_USER].tri == yes) { | 279 | if (cs->def[def].tri == yes) { |
257 | conf_warning("%s creates inconsistent choice state", sym->name); | 280 | conf_warning("%s creates inconsistent choice state", sym->name); |
258 | cs->flags |= SYMBOL_NEW; | 281 | cs->flags &= ~def_flags; |
259 | } | 282 | } |
260 | break; | 283 | break; |
261 | case yes: | 284 | case yes: |
262 | if (cs->def[S_DEF_USER].tri != no) { | 285 | if (cs->def[def].tri != no) { |
263 | conf_warning("%s creates inconsistent choice state", sym->name); | 286 | conf_warning("%s creates inconsistent choice state", sym->name); |
264 | cs->flags |= SYMBOL_NEW; | 287 | cs->flags &= ~def_flags; |
265 | } else | 288 | } else |
266 | cs->def[S_DEF_USER].val = sym; | 289 | cs->def[def].val = sym; |
267 | break; | 290 | break; |
268 | } | 291 | } |
269 | cs->def[S_DEF_USER].tri = E_OR(cs->def[S_DEF_USER].tri, sym->def[S_DEF_USER].tri); | 292 | cs->def[def].tri = E_OR(cs->def[def].tri, sym->def[def].tri); |
270 | } | 293 | } |
271 | } | 294 | } |
272 | fclose(in); | 295 | fclose(in); |
@@ -281,11 +304,11 @@ int conf_read(const char *name) | |||
281 | struct symbol *sym; | 304 | struct symbol *sym; |
282 | struct property *prop; | 305 | struct property *prop; |
283 | struct expr *e; | 306 | struct expr *e; |
284 | int i; | 307 | int i, flags; |
285 | 308 | ||
286 | sym_change_count = 0; | 309 | sym_change_count = 0; |
287 | 310 | ||
288 | if (conf_read_simple(name)) | 311 | if (conf_read_simple(name, S_DEF_USER)) |
289 | return 1; | 312 | return 1; |
290 | 313 | ||
291 | for_all_symbols(i, sym) { | 314 | for_all_symbols(i, sym) { |
@@ -314,15 +337,13 @@ int conf_read(const char *name) | |||
314 | sym_ok: | 337 | sym_ok: |
315 | if (sym_has_value(sym) && !sym_is_choice_value(sym)) { | 338 | if (sym_has_value(sym) && !sym_is_choice_value(sym)) { |
316 | if (sym->visible == no) | 339 | if (sym->visible == no) |
317 | sym->flags |= SYMBOL_NEW; | 340 | sym->flags &= ~SYMBOL_DEF_USER; |
318 | switch (sym->type) { | 341 | switch (sym->type) { |
319 | case S_STRING: | 342 | case S_STRING: |
320 | case S_INT: | 343 | case S_INT: |
321 | case S_HEX: | 344 | case S_HEX: |
322 | if (!sym_string_within_range(sym, sym->def[S_DEF_USER].val)) { | 345 | if (!sym_string_within_range(sym, sym->def[S_DEF_USER].val)) |
323 | sym->flags |= SYMBOL_NEW; | 346 | sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER); |
324 | sym->flags &= ~SYMBOL_VALID; | ||
325 | } | ||
326 | default: | 347 | default: |
327 | break; | 348 | break; |
328 | } | 349 | } |
@@ -330,9 +351,11 @@ int conf_read(const char *name) | |||
330 | if (!sym_is_choice(sym)) | 351 | if (!sym_is_choice(sym)) |
331 | continue; | 352 | continue; |
332 | prop = sym_get_choice_prop(sym); | 353 | prop = sym_get_choice_prop(sym); |
354 | flags = sym->flags; | ||
333 | for (e = prop->expr; e; e = e->left.expr) | 355 | for (e = prop->expr; e; e = e->left.expr) |
334 | if (e->right.sym->visible != no) | 356 | if (e->right.sym->visible != no) |
335 | sym->flags |= e->right.sym->flags & SYMBOL_NEW; | 357 | flags &= e->right.sym->flags; |
358 | sym->flags |= flags & SYMBOL_DEF_USER; | ||
336 | } | 359 | } |
337 | 360 | ||
338 | sym_change_count += conf_warnings || conf_unsaved; | 361 | sym_change_count += conf_warnings || conf_unsaved; |
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 043859d426d..998cf4f656b 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h | |||
@@ -92,10 +92,14 @@ struct symbol { | |||
92 | #define SYMBOL_OPTIONAL 0x0100 | 92 | #define SYMBOL_OPTIONAL 0x0100 |
93 | #define SYMBOL_WRITE 0x0200 | 93 | #define SYMBOL_WRITE 0x0200 |
94 | #define SYMBOL_CHANGED 0x0400 | 94 | #define SYMBOL_CHANGED 0x0400 |
95 | #define SYMBOL_NEW 0x0800 | ||
96 | #define SYMBOL_AUTO 0x1000 | 95 | #define SYMBOL_AUTO 0x1000 |
97 | #define SYMBOL_CHECKED 0x2000 | 96 | #define SYMBOL_CHECKED 0x2000 |
98 | #define SYMBOL_WARNED 0x8000 | 97 | #define SYMBOL_WARNED 0x8000 |
98 | #define SYMBOL_DEF 0x10000 | ||
99 | #define SYMBOL_DEF_USER 0x10000 | ||
100 | #define SYMBOL_DEF2 0x20000 | ||
101 | #define SYMBOL_DEF3 0x40000 | ||
102 | #define SYMBOL_DEF4 0x80000 | ||
99 | 103 | ||
100 | #define SYMBOL_MAXLENGTH 256 | 104 | #define SYMBOL_MAXLENGTH 256 |
101 | #define SYMBOL_HASHSIZE 257 | 105 | #define SYMBOL_HASHSIZE 257 |
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 9cb3e6a4755..7b0d3a93d5c 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c | |||
@@ -132,8 +132,6 @@ const char *dbg_print_flags(int val) | |||
132 | strcat(buf, "write/"); | 132 | strcat(buf, "write/"); |
133 | if (val & SYMBOL_CHANGED) | 133 | if (val & SYMBOL_CHANGED) |
134 | strcat(buf, "changed/"); | 134 | strcat(buf, "changed/"); |
135 | if (val & SYMBOL_NEW) | ||
136 | strcat(buf, "new/"); | ||
137 | if (val & SYMBOL_AUTO) | 135 | if (val & SYMBOL_AUTO) |
138 | strcat(buf, "auto/"); | 136 | strcat(buf, "auto/"); |
139 | 137 | ||
@@ -1186,9 +1184,7 @@ static gchar **fill_row(struct menu *menu) | |||
1186 | 1184 | ||
1187 | row[COL_OPTION] = | 1185 | row[COL_OPTION] = |
1188 | g_strdup_printf("%s %s", menu_get_prompt(menu), | 1186 | g_strdup_printf("%s %s", menu_get_prompt(menu), |
1189 | sym ? (sym-> | 1187 | sym && sym_has_value(sym) ? "(NEW)" : ""); |
1190 | flags & SYMBOL_NEW ? "(NEW)" : "") : | ||
1191 | ""); | ||
1192 | 1188 | ||
1193 | if (show_all && !menu_is_visible(menu)) | 1189 | if (show_all && !menu_is_visible(menu)) |
1194 | row[COL_COLOR] = g_strdup("DarkGray"); | 1190 | row[COL_COLOR] = g_strdup("DarkGray"); |
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 527f60c99c5..52c296e0440 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
@@ -137,7 +137,7 @@ static inline bool sym_is_optional(struct symbol *sym) | |||
137 | 137 | ||
138 | static inline bool sym_has_value(struct symbol *sym) | 138 | static inline bool sym_has_value(struct symbol *sym) |
139 | { | 139 | { |
140 | return sym->flags & SYMBOL_NEW ? false : true; | 140 | return sym->flags & SYMBOL_DEF_USER ? true : false; |
141 | } | 141 | } |
142 | 142 | ||
143 | #ifdef __cplusplus | 143 | #ifdef __cplusplus |
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index bd0fb1dc132..e195c455bfe 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h | |||
@@ -2,7 +2,7 @@ | |||
2 | /* confdata.c */ | 2 | /* confdata.c */ |
3 | P(conf_parse,void,(const char *name)); | 3 | P(conf_parse,void,(const char *name)); |
4 | P(conf_read,int,(const char *name)); | 4 | P(conf_read,int,(const char *name)); |
5 | P(conf_read_simple,int,(const char *name)); | 5 | P(conf_read_simple,int,(const char *name, int)); |
6 | P(conf_write,int,(const char *name)); | 6 | P(conf_write,int,(const char *name)); |
7 | P(conf_write_autoconf,int,(void)); | 7 | P(conf_write_autoconf,int,(void)); |
8 | 8 | ||
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 4ea0050dcb1..78a60ba39e5 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
@@ -426,8 +426,8 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val) | |||
426 | if (oldval != val && !sym_tristate_within_range(sym, val)) | 426 | if (oldval != val && !sym_tristate_within_range(sym, val)) |
427 | return false; | 427 | return false; |
428 | 428 | ||
429 | if (sym->flags & SYMBOL_NEW) { | 429 | if (!(sym->flags & SYMBOL_DEF_USER)) { |
430 | sym->flags &= ~SYMBOL_NEW; | 430 | sym->flags |= SYMBOL_DEF_USER; |
431 | sym_set_changed(sym); | 431 | sym_set_changed(sym); |
432 | } | 432 | } |
433 | /* | 433 | /* |
@@ -440,11 +440,11 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val) | |||
440 | struct expr *e; | 440 | struct expr *e; |
441 | 441 | ||
442 | cs->def[S_DEF_USER].val = sym; | 442 | cs->def[S_DEF_USER].val = sym; |
443 | cs->flags &= ~SYMBOL_NEW; | 443 | cs->flags |= SYMBOL_DEF_USER; |
444 | prop = sym_get_choice_prop(cs); | 444 | prop = sym_get_choice_prop(cs); |
445 | for (e = prop->expr; e; e = e->left.expr) { | 445 | for (e = prop->expr; e; e = e->left.expr) { |
446 | if (e->right.sym->visible != no) | 446 | if (e->right.sym->visible != no) |
447 | e->right.sym->flags &= ~SYMBOL_NEW; | 447 | e->right.sym->flags |= SYMBOL_DEF_USER; |
448 | } | 448 | } |
449 | } | 449 | } |
450 | 450 | ||
@@ -591,8 +591,8 @@ bool sym_set_string_value(struct symbol *sym, const char *newval) | |||
591 | if (!sym_string_within_range(sym, newval)) | 591 | if (!sym_string_within_range(sym, newval)) |
592 | return false; | 592 | return false; |
593 | 593 | ||
594 | if (sym->flags & SYMBOL_NEW) { | 594 | if (!(sym->flags & SYMBOL_DEF_USER)) { |
595 | sym->flags &= ~SYMBOL_NEW; | 595 | sym->flags |= SYMBOL_DEF_USER; |
596 | sym_set_changed(sym); | 596 | sym_set_changed(sym); |
597 | } | 597 | } |
598 | 598 | ||
@@ -679,7 +679,6 @@ struct symbol *sym_lookup(const char *name, int isconst) | |||
679 | memset(symbol, 0, sizeof(*symbol)); | 679 | memset(symbol, 0, sizeof(*symbol)); |
680 | symbol->name = new_name; | 680 | symbol->name = new_name; |
681 | symbol->type = S_UNKNOWN; | 681 | symbol->type = S_UNKNOWN; |
682 | symbol->flags = SYMBOL_NEW; | ||
683 | if (isconst) | 682 | if (isconst) |
684 | symbol->flags |= SYMBOL_CONST; | 683 | symbol->flags |= SYMBOL_CONST; |
685 | 684 | ||