Author: jow
Date: 2014-12-12 13:29:58 +0100 (Fri, 12 Dec 2014)
New Revision: 43652

Modified:
   trunk/scripts/config/zconf.l
   trunk/scripts/config/zconf.lex.c_shipped
Log:
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 <[email protected]>

Modified: trunk/scripts/config/zconf.l
===================================================================
--- trunk/scripts/config/zconf.l        2014-12-12 12:14:40 UTC (rev 43651)
+++ trunk/scripts/config/zconf.l        2014-12-12 12:29:58 UTC (rev 43652)
@@ -343,6 +343,7 @@
        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 @@
                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";
 

Modified: trunk/scripts/config/zconf.lex.c_shipped
===================================================================
--- trunk/scripts/config/zconf.lex.c_shipped    2014-12-12 12:14:40 UTC (rev 
43651)
+++ trunk/scripts/config/zconf.lex.c_shipped    2014-12-12 12:29:58 UTC (rev 
43652)
@@ -2399,6 +2399,7 @@
        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 @@
                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";
 
_______________________________________________
openwrt-commits mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-commits

Reply via email to