diff options
Diffstat (limited to 'scripts/kconfig/zconf.l')
-rw-r--r-- | scripts/kconfig/zconf.l | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index cfcfabd7a069..cfa46077c6b4 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -18,6 +18,11 @@ | |||
18 | 18 | ||
19 | #define START_STRSIZE 16 | 19 | #define START_STRSIZE 16 |
20 | 20 | ||
21 | static struct { | ||
22 | struct file *file; | ||
23 | int lineno; | ||
24 | } current_pos; | ||
25 | |||
21 | static char *text; | 26 | static char *text; |
22 | static int text_size, text_asize; | 27 | static int text_size, text_asize; |
23 | 28 | ||
@@ -31,7 +36,7 @@ struct buffer *current_buf; | |||
31 | static int last_ts, first_ts; | 36 | static int last_ts, first_ts; |
32 | 37 | ||
33 | static void zconf_endhelp(void); | 38 | static void zconf_endhelp(void); |
34 | static struct buffer *zconf_endfile(void); | 39 | static void zconf_endfile(void); |
35 | 40 | ||
36 | void new_string(void) | 41 | void new_string(void) |
37 | { | 42 | { |
@@ -70,10 +75,13 @@ n [A-Za-z0-9_] | |||
70 | int str = 0; | 75 | int str = 0; |
71 | int ts, i; | 76 | int ts, i; |
72 | 77 | ||
73 | [ \t]*#.*\n current_file->lineno++; | 78 | [ \t]*#.*\n | |
79 | [ \t]*\n { | ||
80 | current_file->lineno++; | ||
81 | return T_EOL; | ||
82 | } | ||
74 | [ \t]*#.* | 83 | [ \t]*#.* |
75 | 84 | ||
76 | [ \t]*\n current_file->lineno++; return T_EOL; | ||
77 | 85 | ||
78 | [ \t]+ { | 86 | [ \t]+ { |
79 | BEGIN(COMMAND); | 87 | BEGIN(COMMAND); |
@@ -88,8 +96,10 @@ n [A-Za-z0-9_] | |||
88 | <COMMAND>{ | 96 | <COMMAND>{ |
89 | {n}+ { | 97 | {n}+ { |
90 | struct kconf_id *id = kconf_id_lookup(yytext, yyleng); | 98 | struct kconf_id *id = kconf_id_lookup(yytext, yyleng); |
99 | BEGIN(PARAM); | ||
100 | current_pos.file = current_file; | ||
101 | current_pos.lineno = current_file->lineno; | ||
91 | if (id && id->flags & TF_COMMAND) { | 102 | if (id && id->flags & TF_COMMAND) { |
92 | BEGIN(PARAM); | ||
93 | zconflval.id = id; | 103 | zconflval.id = id; |
94 | return id->token; | 104 | return id->token; |
95 | } | 105 | } |
@@ -98,7 +108,11 @@ n [A-Za-z0-9_] | |||
98 | return T_WORD; | 108 | return T_WORD; |
99 | } | 109 | } |
100 | . | 110 | . |
101 | \n current_file->lineno++; BEGIN(INITIAL); | 111 | \n { |
112 | BEGIN(INITIAL); | ||
113 | current_file->lineno++; | ||
114 | return T_EOL; | ||
115 | } | ||
102 | } | 116 | } |
103 | 117 | ||
104 | <PARAM>{ | 118 | <PARAM>{ |
@@ -214,9 +228,9 @@ n [A-Za-z0-9_] | |||
214 | } | 228 | } |
215 | 229 | ||
216 | <<EOF>> { | 230 | <<EOF>> { |
217 | if (current_buf) { | 231 | if (current_file) { |
218 | zconf_endfile(); | 232 | zconf_endfile(); |
219 | return T_EOF; | 233 | return T_EOL; |
220 | } | 234 | } |
221 | fclose(yyin); | 235 | fclose(yyin); |
222 | yyterminate(); | 236 | yyterminate(); |
@@ -307,7 +321,7 @@ void zconf_nextfile(const char *name) | |||
307 | current_file = file; | 321 | current_file = file; |
308 | } | 322 | } |
309 | 323 | ||
310 | static struct buffer *zconf_endfile(void) | 324 | static void zconf_endfile(void) |
311 | { | 325 | { |
312 | struct buffer *parent; | 326 | struct buffer *parent; |
313 | 327 | ||
@@ -323,22 +337,14 @@ static struct buffer *zconf_endfile(void) | |||
323 | } | 337 | } |
324 | free(current_buf); | 338 | free(current_buf); |
325 | current_buf = parent; | 339 | current_buf = parent; |
326 | |||
327 | return parent; | ||
328 | } | 340 | } |
329 | 341 | ||
330 | int zconf_lineno(void) | 342 | int zconf_lineno(void) |
331 | { | 343 | { |
332 | if (current_buf) | 344 | return current_pos.lineno; |
333 | return current_file->lineno - 1; | ||
334 | else | ||
335 | return 0; | ||
336 | } | 345 | } |
337 | 346 | ||
338 | char *zconf_curname(void) | 347 | char *zconf_curname(void) |
339 | { | 348 | { |
340 | if (current_buf) | 349 | return current_pos.file ? current_pos.file->name : "<none>"; |
341 | return current_file->name; | ||
342 | else | ||
343 | return "<none>"; | ||
344 | } | 350 | } |