aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/confdata.c
diff options
context:
space:
mode:
authorRoman Zippel <zippel@linux-m68k.org>2006-06-09 01:12:42 -0400
committerSam Ravnborg <sam@mars.ravnborg.org>2006-06-09 01:31:30 -0400
commit669bfad906522e74ee8d962801552a8c224c0d63 (patch)
tree84b7e85d7d731b7f188c38d83139f9b6d4acaa56 /scripts/kconfig/confdata.c
parent0c1822e6991a10da6dc391f0a2e2cf5fb2e31238 (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>
Diffstat (limited to 'scripts/kconfig/confdata.c')
-rw-r--r--scripts/kconfig/confdata.c111
1 files changed, 67 insertions, 44 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 54ca1a786d25..ca693fcd023f 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
89int conf_read_simple(const char *name) 89int 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;