diff options
author | Yann E. MORIN <yann.morin.1998@anciens.enib.fr> | 2011-02-24 13:36:42 -0500 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2011-04-15 09:12:48 -0400 |
commit | f094f8a1b2737a4f3ca46742ff9aaf460d39285e (patch) | |
tree | 91f1b35efd025cc0a31f78230c8f81ab5a21c78f /scripts | |
parent | 466de9183570fe9fd21ef167951488fc9d513fcb (diff) |
kconfig: allow multiple inclusion of the same file
Allow 'source'ing the same file from multiple places (eg. from
different files, and/or under different conditions).
To avoid circular inclusion, scan the source-ancestry of the
current file, and abort if already sourced in this branch.
Regenerate the pre-parsed lex.zconf.c_shipped file.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/kconfig/lex.zconf.c_shipped | 29 | ||||
-rw-r--r-- | scripts/kconfig/zconf.l | 29 |
2 files changed, 38 insertions, 20 deletions
diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped index 6eb039718259..f4b3b1a15e21 100644 --- a/scripts/kconfig/lex.zconf.c_shipped +++ b/scripts/kconfig/lex.zconf.c_shipped | |||
@@ -2368,6 +2368,7 @@ void zconf_initscan(const char *name) | |||
2368 | 2368 | ||
2369 | void zconf_nextfile(const char *name) | 2369 | void zconf_nextfile(const char *name) |
2370 | { | 2370 | { |
2371 | struct file *iter; | ||
2371 | struct file *file = file_lookup(name); | 2372 | struct file *file = file_lookup(name); |
2372 | struct buffer *buf = malloc(sizeof(*buf)); | 2373 | struct buffer *buf = malloc(sizeof(*buf)); |
2373 | memset(buf, 0, sizeof(*buf)); | 2374 | memset(buf, 0, sizeof(*buf)); |
@@ -2383,16 +2384,24 @@ void zconf_nextfile(const char *name) | |||
2383 | buf->parent = current_buf; | 2384 | buf->parent = current_buf; |
2384 | current_buf = buf; | 2385 | current_buf = buf; |
2385 | 2386 | ||
2386 | if (file->flags & FILE_BUSY) { | 2387 | for (iter = current_file->parent; iter; iter = iter->parent ) { |
2387 | printf("%s:%d: do not source '%s' from itself\n", | 2388 | if (!strcmp(current_file->name,iter->name) ) { |
2388 | zconf_curname(), zconf_lineno(), name); | 2389 | printf("%s:%d: recursive inclusion detected. " |
2389 | exit(1); | 2390 | "Inclusion path:\n current file : '%s'\n", |
2390 | } | 2391 | zconf_curname(), zconf_lineno(), |
2391 | if (file->flags & FILE_SCANNED) { | 2392 | zconf_curname()); |
2392 | printf("%s:%d: file '%s' is already sourced from '%s'\n", | 2393 | iter = current_file->parent; |
2393 | zconf_curname(), zconf_lineno(), name, | 2394 | while (iter && \ |
2394 | file->parent->name); | 2395 | strcmp(iter->name,current_file->name)) { |
2395 | exit(1); | 2396 | printf(" included from: '%s:%d'\n", |
2397 | iter->name, iter->lineno-1); | ||
2398 | iter = iter->parent; | ||
2399 | } | ||
2400 | if (iter) | ||
2401 | printf(" included from: '%s:%d'\n", | ||
2402 | iter->name, iter->lineno+1); | ||
2403 | exit(1); | ||
2404 | } | ||
2396 | } | 2405 | } |
2397 | file->flags |= FILE_BUSY; | 2406 | file->flags |= FILE_BUSY; |
2398 | file->lineno = 1; | 2407 | file->lineno = 1; |
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 3dbaec185cc4..f23e3affa9b5 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -299,6 +299,7 @@ void zconf_initscan(const char *name) | |||
299 | 299 | ||
300 | void zconf_nextfile(const char *name) | 300 | void zconf_nextfile(const char *name) |
301 | { | 301 | { |
302 | struct file *iter; | ||
302 | struct file *file = file_lookup(name); | 303 | struct file *file = file_lookup(name); |
303 | struct buffer *buf = malloc(sizeof(*buf)); | 304 | struct buffer *buf = malloc(sizeof(*buf)); |
304 | memset(buf, 0, sizeof(*buf)); | 305 | memset(buf, 0, sizeof(*buf)); |
@@ -314,16 +315,24 @@ void zconf_nextfile(const char *name) | |||
314 | buf->parent = current_buf; | 315 | buf->parent = current_buf; |
315 | current_buf = buf; | 316 | current_buf = buf; |
316 | 317 | ||
317 | if (file->flags & FILE_BUSY) { | 318 | for (iter = current_file->parent; iter; iter = iter->parent ) { |
318 | printf("%s:%d: do not source '%s' from itself\n", | 319 | if (!strcmp(current_file->name,iter->name) ) { |
319 | zconf_curname(), zconf_lineno(), name); | 320 | printf("%s:%d: recursive inclusion detected. " |
320 | exit(1); | 321 | "Inclusion path:\n current file : '%s'\n", |
321 | } | 322 | zconf_curname(), zconf_lineno(), |
322 | if (file->flags & FILE_SCANNED) { | 323 | zconf_curname()); |
323 | printf("%s:%d: file '%s' is already sourced from '%s'\n", | 324 | iter = current_file->parent; |
324 | zconf_curname(), zconf_lineno(), name, | 325 | while (iter && \ |
325 | file->parent->name); | 326 | strcmp(iter->name,current_file->name)) { |
326 | exit(1); | 327 | printf(" included from: '%s:%d'\n", |
328 | iter->name, iter->lineno-1); | ||
329 | iter = iter->parent; | ||
330 | } | ||
331 | if (iter) | ||
332 | printf(" included from: '%s:%d'\n", | ||
333 | iter->name, iter->lineno+1); | ||
334 | exit(1); | ||
335 | } | ||
327 | } | 336 | } |
328 | file->flags |= FILE_BUSY; | 337 | file->flags |= FILE_BUSY; |
329 | file->lineno = 1; | 338 | file->lineno = 1; |