-rw-r--r-- | scripts/kconfig/zconf.l | 72 |
1 files changed, 54 insertions, 18 deletions
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 6d81e5e..1471630 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -1,4 +1,4 @@ | |||
1 | %option backup nostdinit noyywrap full ecs | 1 | %option backup nostdinit noyywrap never-interactive full ecs |
2 | %option 8bit backup nodefault perf-report perf-report | 2 | %option 8bit backup nodefault perf-report perf-report |
3 | %x COMMAND HELP STRING PARAM | 3 | %x COMMAND HELP STRING PARAM |
4 | %{ | 4 | %{ |
@@ -7,6 +7,7 @@ | |||
7 | * Released under the terms of the GNU GPL v2.0. | 7 | * Released under the terms of the GNU GPL v2.0. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <limits.h> | ||
10 | #include <stdio.h> | 11 | #include <stdio.h> |
11 | #include <stdlib.h> | 12 | #include <stdlib.h> |
12 | #include <string.h> | 13 | #include <string.h> |
@@ -14,7 +15,6 @@ | |||
14 | 15 | ||
15 | #define LKC_DIRECT_LINK | 16 | #define LKC_DIRECT_LINK |
16 | #include "lkc.h" | 17 | #include "lkc.h" |
17 | #include "zconf.tab.h" | ||
18 | 18 | ||
19 | #define START_STRSIZE16 | 19 | #define START_STRSIZE16 |
20 | 20 | ||
@@ -83,8 +83,6 @@ n [A-Za-z0-9_] | |||
83 | 83 | ||
84 | .{ | 84 | .{ |
85 | unput(yytext[0]); | 85 | unput(yytext[0]); |
86 | //printf("new config: "); | ||
87 | //symbol_end(NULL); | ||
88 | BEGIN(COMMAND); | 86 | BEGIN(COMMAND); |
89 | } | 87 | } |
90 | 88 | ||
@@ -143,32 +141,46 @@ n [A-Za-z0-9_] | |||
143 | zconflval.string = text; | 141 | zconflval.string = text; |
144 | return T_WORD; | 142 | return T_WORD; |
145 | } | 143 | } |
144 | \\\ncurrent_file->lineno++; | ||
146 | . | 145 | . |
146 | <<EOF>> { | ||
147 | BEGIN(INITIAL); | ||
148 | } | ||
147 | } | 149 | } |
148 | 150 | ||
149 | <STRING>{ | 151 | <STRING>{ |
150 | [^'"\n\\]+{ | 152 | [^'"\\\n]+/\n{ |
153 | append_string(yytext, yyleng); | ||
154 | zconflval.string = text; | ||
155 | return T_STRING; | ||
156 | } | ||
157 | [^'"\\\n]+{ | ||
151 | append_string(yytext, yyleng); | 158 | append_string(yytext, yyleng); |
152 | } | 159 | } |
160 | \\.?/\n{ | ||
161 | append_string(yytext + 1, yyleng - 1); | ||
162 | zconflval.string = text; | ||
163 | return T_STRING; | ||
164 | } | ||
165 | \\.?{ | ||
166 | append_string(yytext + 1, yyleng - 1); | ||
167 | } | ||
153 | \'|\"{ | 168 | \'|\"{ |
154 | if (str == yytext[0]) { | 169 | if (str == yytext[0]) { |
155 | BEGIN(PARAM); | 170 | BEGIN(PARAM); |
156 | zconflval.string = text; | 171 | zconflval.string = text; |
157 | //printf("s:%s\n", text); | ||
158 | return T_STRING; | 172 | return T_STRING; |
159 | } else | 173 | } else |
160 | append_string(yytext, 1); | 174 | append_string(yytext, 1); |
161 | } | 175 | } |
162 | \\[ \t]*\nappend_string(yytext+yyleng-1, 1); current_file->lineno++; | ||
163 | \\[ \t]*append_string(yytext+1, yyleng-1); | ||
164 | \\. append_string(yytext+1, 1); | ||
165 | \n{ | 176 | \n{ |
166 | //printf(":%d: open string!\n", current_file->lineno+1); | 177 | printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); |
167 | exit(0); | 178 | current_file->lineno++; |
179 | BEGIN(INITIAL); | ||
180 | return T_EOL; | ||
168 | } | 181 | } |
169 | <<EOF>>{ | 182 | <<EOF>>{ |
170 | //printf(":%d: open string!\n", current_file->lineno+1); | 183 | BEGIN(INITIAL); |
171 | exit(0); | ||
172 | } | 184 | } |
173 | } | 185 | } |
174 | 186 | ||
@@ -221,6 +233,7 @@ n [A-Za-z0-9_] | |||
221 | zconf_endfile(); | 233 | zconf_endfile(); |
222 | return T_EOF; | 234 | return T_EOF; |
223 | } | 235 | } |
236 | fclose(yyin); | ||
224 | yyterminate(); | 237 | yyterminate(); |
225 | } | 238 | } |
226 | 239 | ||
@@ -238,14 +251,38 @@ static void zconf_endhelp(void) | |||
238 | BEGIN(INITIAL); | 251 | BEGIN(INITIAL); |
239 | } | 252 | } |
240 | 253 | ||
254 | |||
255 | /* | ||
256 | * Try to open specified file with following names: | ||
257 | * ./name | ||
258 | * $(srctree)/name | ||
259 | * The latter is used when srctree is separate from objtree | ||
260 | * when compiling the kernel. | ||
261 | * Return NULL if file is not found. | ||
262 | */ | ||
263 | FILE *zconf_fopen(const char *name) | ||
264 | { | ||
265 | char *env, fullname[PATH_MAX+1]; | ||
266 | FILE *f; | ||
267 | |||
268 | f = fopen(name, "r"); | ||
269 | if (!f && name[0] != '/') { | ||
270 | env = getenv(SRCTREE); | ||
271 | if (env) { | ||
272 | sprintf(fullname, "%s/%s", env, name); | ||
273 | f = fopen(fullname, "r"); | ||
274 | } | ||
275 | } | ||
276 | return f; | ||
277 | } | ||
278 | |||
241 | void zconf_initscan(const char *name) | 279 | void zconf_initscan(const char *name) |
242 | { | 280 | { |
243 | yyin = fopen(name, "r"); | 281 | yyin = zconf_fopen(name); |
244 | if (!yyin) { | 282 | if (!yyin) { |
245 | printf("can't find file %s\n", name); | 283 | printf("can't find file %s\n", name); |
246 | exit(1); | 284 | exit(1); |
247 | } | 285 | } |
248 | //fprintf(stderr, "zconf_initscan: %s\n", name); | ||
249 | 286 | ||
250 | current_buf = malloc(sizeof(*current_buf)); | 287 | current_buf = malloc(sizeof(*current_buf)); |
251 | memset(current_buf, 0, sizeof(*current_buf)); | 288 | memset(current_buf, 0, sizeof(*current_buf)); |
@@ -262,7 +299,7 @@ void zconf_nextfile(const char *name) | |||
262 | memset(buf, 0, sizeof(*buf)); | 299 | memset(buf, 0, sizeof(*buf)); |
263 | 300 | ||
264 | current_buf->state = YY_CURRENT_BUFFER; | 301 | current_buf->state = YY_CURRENT_BUFFER; |
265 | yyin = fopen(name, "r"); | 302 | yyin = zconf_fopen(name); |
266 | if (!yyin) { | 303 | if (!yyin) { |
267 | printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); | 304 | printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); |
268 | exit(1); | 305 | exit(1); |
@@ -271,8 +308,6 @@ void zconf_nextfile(const char *name) | |||
271 | buf->parent = current_buf; | 308 | buf->parent = current_buf; |
272 | current_buf = buf; | 309 | current_buf = buf; |
273 | 310 | ||
274 | //fprintf(stderr, "zconf_nextfile: %s\n", name); | ||
275 | |||
276 | if (file->flags & FILE_BUSY) { | 311 | if (file->flags & FILE_BUSY) { |
277 | printf("recursive scan (%s)?\n", name); | 312 | printf("recursive scan (%s)?\n", name); |
278 | exit(1); | 313 | exit(1); |
@@ -297,6 +332,7 @@ static struct buffer *zconf_endfile(void) | |||
297 | 332 | ||
298 | parent = current_buf->parent; | 333 | parent = current_buf->parent; |
299 | if (parent) { | 334 | if (parent) { |
335 | fclose(yyin); | ||
300 | yy_delete_buffer(YY_CURRENT_BUFFER); | 336 | yy_delete_buffer(YY_CURRENT_BUFFER); |
301 | yy_switch_to_buffer(parent->state); | 337 | yy_switch_to_buffer(parent->state); |
302 | } | 338 | } |