sdk: add OpenWrt branding to menuconfig & .config
[oweals/openwrt.git] / scripts / config / zconf.l
index 3aef45983aa1f1cc979ad2298ac7de0492cb1dfd..44d895fb24a204a067e2036c515ed42942510ab2 100644 (file)
@@ -14,6 +14,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <glob.h>
+#include <libgen.h>
 
 #include "lkc.h"
 
@@ -28,8 +29,8 @@ static char *text;
 static int text_size, text_asize;
 
 struct buffer {
-        struct buffer *parent;
-        YY_BUFFER_STATE state;
+       struct buffer *parent;
+       YY_BUFFER_STATE state;
 };
 
 struct buffer *current_buf;
@@ -67,10 +68,16 @@ static void alloc_string(const char *str, int size)
        memcpy(text, str, size);
        text[size] = 0;
 }
+
+static void warn_ignored_character(char chr)
+{
+       fprintf(stderr,
+               "%s:%d:warning: ignoring unsupported character '%c'\n",
+               zconf_curname(), zconf_lineno(), chr);
+}
 %}
 
-ws     [ \n\t]
-n      [A-Za-z0-9_]
+n      [A-Za-z0-9_-]
 
 %%
        int str = 0;
@@ -108,7 +115,7 @@ n   [A-Za-z0-9_]
                zconflval.string = text;
                return T_WORD;
        }
-       .
+       .       warn_ignored_character(*yytext);
        \n      {
                BEGIN(INITIAL);
                current_file->lineno++;
@@ -124,14 +131,17 @@ n [A-Za-z0-9_]
        "!"     return T_NOT;
        "="     return T_EQUAL;
        "!="    return T_UNEQUAL;
+       "<="    return T_LESS_EQUAL;
+       ">="    return T_GREATER_EQUAL;
+       "<"     return T_LESS;
+       ">"     return T_GREATER;
        \"|\'   {
                str = yytext[0];
                new_string();
                BEGIN(STRING);
        }
        \n      BEGIN(INITIAL); current_file->lineno++; return T_EOL;
-       ---     /* ignore */
-       ({n}|[-/.])+    {
+       ({n}|[/.])+     {
                const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
                if (id && id->flags & TF_PARAM) {
                        zconflval.id = id;
@@ -143,7 +153,8 @@ n   [A-Za-z0-9_]
        }
        #.*     /* comment */
        \\\n    current_file->lineno++;
-       .
+       [[:blank:]]+
+       .       warn_ignored_character(*yytext);
        <<EOF>> {
                BEGIN(INITIAL);
        }
@@ -343,6 +354,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 +364,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";