diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2014-12-12 12:29:58 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2014-12-12 12:29:58 +0000 |
commit | 2f39014a4843f801e6fdc2ebd77b5523cb38f4b3 (patch) | |
tree | b90945e205d34d3edfb7fe47995b43b8b83aa2a0 /scripts | |
parent | f34dfaf2495d9585210303265af572576553e954 (diff) | |
download | upstream-2f39014a4843f801e6fdc2ebd77b5523cb38f4b3.tar.gz upstream-2f39014a4843f801e6fdc2ebd77b5523cb38f4b3.tar.bz2 upstream-2f39014a4843f801e6fdc2ebd77b5523cb38f4b3.zip |
scripts/config: support includes relative to the currently processed file
When the initial glob() attempt on a path specified with "source" statement
yields no result, then retry the globbing on the same path with the directory
part of the currently processed file prepended.
This allows us to reference Config.in files relative to their parent instead
of relative to the top dir.
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
SVN-Revision: 43652
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/config/zconf.l | 10 | ||||
-rw-r--r-- | scripts/config/zconf.lex.c_shipped | 11 |
2 files changed, 21 insertions, 0 deletions
diff --git a/scripts/config/zconf.l b/scripts/config/zconf.l index 3aef45983a..1dd765817a 100644 --- a/scripts/config/zconf.l +++ b/scripts/config/zconf.l @@ -343,6 +343,7 @@ void zconf_nextfile(const char *name) glob_t gl; int err; int i; + char path[PATH_MAX], *p; err = glob(name, GLOB_ERR | GLOB_MARK, NULL, &gl); @@ -352,6 +353,15 @@ void zconf_nextfile(const char *name) gl.gl_pathc = 0; } + if (err == GLOB_NOMATCH) { + p = strdup(current_file->name); + if (p) { + snprintf(path, sizeof(path), "%s/%s", dirname(p), name); + err = glob(path, GLOB_ERR | GLOB_MARK, NULL, &gl); + free(p); + } + } + if (err) { const char *reason = "unknown error"; diff --git a/scripts/config/zconf.lex.c_shipped b/scripts/config/zconf.lex.c_shipped index 766549fbfe..c938b2fae6 100644 --- a/scripts/config/zconf.lex.c_shipped +++ b/scripts/config/zconf.lex.c_shipped @@ -2399,6 +2399,7 @@ void zconf_nextfile(const char *name) glob_t gl; int err; int i; + char path[PATH_MAX], *p; err = glob(name, GLOB_ERR | GLOB_MARK, NULL, &gl); @@ -2408,6 +2409,16 @@ void zconf_nextfile(const char *name) gl.gl_pathc = 0; } + if (err == GLOB_NOMATCH) { + p = strdup(current_file->name); + if (p) { + snprintf(path, sizeof(path), "%s/%s", dirname(p), name); + fprintf(stderr, "TRY:%s\n", path); + err = glob(path, GLOB_ERR | GLOB_MARK, NULL, &gl); + free(p); + } + } + if (err) { const char *reason = "unknown error"; |