aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig')
-rw-r--r--scripts/kconfig/confdata.c119
1 files changed, 64 insertions, 55 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index b2913e9da495..e0f402f3b75d 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -83,6 +83,68 @@ char *conf_get_default_confname(void)
83 return name; 83 return name;
84} 84}
85 85
86static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
87{
88 char *p2;
89
90 switch (sym->type) {
91 case S_TRISTATE:
92 if (p[0] == 'm') {
93 sym->def[def].tri = mod;
94 sym->flags |= def_flags;
95 break;
96 }
97 case S_BOOLEAN:
98 if (p[0] == 'y') {
99 sym->def[def].tri = yes;
100 sym->flags |= def_flags;
101 break;
102 }
103 if (p[0] == 'n') {
104 sym->def[def].tri = no;
105 sym->flags |= def_flags;
106 break;
107 }
108 conf_warning("symbol value '%s' invalid for %s", p, sym->name);
109 break;
110 case S_OTHER:
111 if (*p != '"') {
112 for (p2 = p; *p2 && !isspace(*p2); p2++)
113 ;
114 sym->type = S_STRING;
115 goto done;
116 }
117 case S_STRING:
118 if (*p++ != '"')
119 break;
120 for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) {
121 if (*p2 == '"') {
122 *p2 = 0;
123 break;
124 }
125 memmove(p2, p2 + 1, strlen(p2));
126 }
127 if (!p2) {
128 conf_warning("invalid string found");
129 return 1;
130 }
131 case S_INT:
132 case S_HEX:
133 done:
134 if (sym_string_valid(sym, p)) {
135 sym->def[def].val = strdup(p);
136 sym->flags |= def_flags;
137 } else {
138 conf_warning("symbol value '%s' invalid for %s", p, sym->name);
139 return 1;
140 }
141 break;
142 default:
143 ;
144 }
145 return 0;
146}
147
86int conf_read_simple(const char *name, int def) 148int conf_read_simple(const char *name, int def)
87{ 149{
88 FILE *in = NULL; 150 FILE *in = NULL;
@@ -213,61 +275,8 @@ load:
213 conf_warning("trying to reassign symbol %s", sym->name); 275 conf_warning("trying to reassign symbol %s", sym->name);
214 break; 276 break;
215 } 277 }
216 switch (sym->type) { 278 if (conf_set_sym_val(sym, def, def_flags, p))
217 case S_TRISTATE: 279 continue;
218 if (p[0] == 'm') {
219 sym->def[def].tri = mod;
220 sym->flags |= def_flags;
221 break;
222 }
223 case S_BOOLEAN:
224 if (p[0] == 'y') {
225 sym->def[def].tri = yes;
226 sym->flags |= def_flags;
227 break;
228 }
229 if (p[0] == 'n') {
230 sym->def[def].tri = no;
231 sym->flags |= def_flags;
232 break;
233 }
234 conf_warning("symbol value '%s' invalid for %s", p, sym->name);
235 break;
236 case S_OTHER:
237 if (*p != '"') {
238 for (p2 = p; *p2 && !isspace(*p2); p2++)
239 ;
240 sym->type = S_STRING;
241 goto done;
242 }
243 case S_STRING:
244 if (*p++ != '"')
245 break;
246 for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) {
247 if (*p2 == '"') {
248 *p2 = 0;
249 break;
250 }
251 memmove(p2, p2 + 1, strlen(p2));
252 }
253 if (!p2) {
254 conf_warning("invalid string found");
255 continue;
256 }
257 case S_INT:
258 case S_HEX:
259 done:
260 if (sym_string_valid(sym, p)) {
261 sym->def[def].val = strdup(p);
262 sym->flags |= def_flags;
263 } else {
264 conf_warning("symbol value '%s' invalid for %s", p, sym->name);
265 continue;
266 }
267 break;
268 default:
269 ;
270 }
271 break; 280 break;
272 case '\r': 281 case '\r':
273 case '\n': 282 case '\n':