aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2007-11-10 14:01:56 -0500
committerSam Ravnborg <sam@ravnborg.org>2007-11-12 15:02:19 -0500
commit9c900a9c9d9351e55ab6a84e12e3a52c474c7c8b (patch)
treeabd705db452aee0ad973e54f35895be4135de114 /scripts
parent506f1d07b310815d11527d3360b09d79d0bd59f1 (diff)
kconfig: factor out code in confdata.c
This patch introduce no functional changes. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Cc: Roman Zippel <zippel@linux-m68k.org>
Diffstat (limited to 'scripts')
-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':