cpqarray: switch to seq_file
[safe/jmp/linux-2.6] / scripts / kconfig / zconf.l
index cfcfabd..21ff69c 100644 (file)
@@ -1,5 +1,6 @@
 %option backup nostdinit noyywrap never-interactive full ecs
 %option 8bit backup nodefault perf-report perf-report
+%option noinput
 %x COMMAND HELP STRING PARAM
 %{
 /*
 
 #define START_STRSIZE  16
 
+static struct {
+       struct file *file;
+       int lineno;
+} current_pos;
+
 static char *text;
 static int text_size, text_asize;
 
@@ -31,7 +37,7 @@ struct buffer *current_buf;
 static int last_ts, first_ts;
 
 static void zconf_endhelp(void);
-static struct buffer *zconf_endfile(void);
+static void zconf_endfile(void);
 
 void new_string(void)
 {
@@ -70,10 +76,13 @@ n   [A-Za-z0-9_]
        int str = 0;
        int ts, i;
 
-[ \t]*#.*\n    current_file->lineno++;
+[ \t]*#.*\n    |
+[ \t]*\n       {
+       current_file->lineno++;
+       return T_EOL;
+}
 [ \t]*#.*
 
-[ \t]*\n       current_file->lineno++; return T_EOL;
 
 [ \t]+ {
        BEGIN(COMMAND);
@@ -88,8 +97,10 @@ n    [A-Za-z0-9_]
 <COMMAND>{
        {n}+    {
                struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
+               BEGIN(PARAM);
+               current_pos.file = current_file;
+               current_pos.lineno = current_file->lineno;
                if (id && id->flags & TF_COMMAND) {
-                       BEGIN(PARAM);
                        zconflval.id = id;
                        return id->token;
                }
@@ -98,7 +109,11 @@ n   [A-Za-z0-9_]
                return T_WORD;
        }
        .
-       \n      current_file->lineno++; BEGIN(INITIAL);
+       \n      {
+               BEGIN(INITIAL);
+               current_file->lineno++;
+               return T_EOL;
+       }
 }
 
 <PARAM>{
@@ -203,6 +218,11 @@ n  [A-Za-z0-9_]
                append_string("\n", 1);
        }
        [^ \t\n].* {
+               while (yyleng) {
+                       if ((yytext[yyleng-1] != ' ') && (yytext[yyleng-1] != '\t'))
+                               break;
+                       yyleng--;
+               }
                append_string(yytext, yyleng);
                if (!first_ts)
                        first_ts = last_ts;
@@ -214,9 +234,9 @@ n   [A-Za-z0-9_]
 }
 
 <<EOF>>        {
-       if (current_buf) {
+       if (current_file) {
                zconf_endfile();
-               return T_EOF;
+               return T_EOL;
        }
        fclose(yyin);
        yyterminate();
@@ -251,7 +271,7 @@ FILE *zconf_fopen(const char *name)
        FILE *f;
 
        f = fopen(name, "r");
-       if (!f && name[0] != '/') {
+       if (!f && name != NULL && name[0] != '/') {
                env = getenv(SRCTREE);
                if (env) {
                        sprintf(fullname, "%s/%s", env, name);
@@ -294,11 +314,14 @@ void zconf_nextfile(const char *name)
        current_buf = buf;
 
        if (file->flags & FILE_BUSY) {
-               printf("recursive scan (%s)?\n", name);
+               printf("%s:%d: do not source '%s' from itself\n",
+                      zconf_curname(), zconf_lineno(), name);
                exit(1);
        }
        if (file->flags & FILE_SCANNED) {
-               printf("file %s already scanned?\n", name);
+               printf("%s:%d: file '%s' is already sourced from '%s'\n",
+                      zconf_curname(), zconf_lineno(), name,
+                      file->parent->name);
                exit(1);
        }
        file->flags |= FILE_BUSY;
@@ -307,7 +330,7 @@ void zconf_nextfile(const char *name)
        current_file = file;
 }
 
-static struct buffer *zconf_endfile(void)
+static void zconf_endfile(void)
 {
        struct buffer *parent;
 
@@ -323,22 +346,14 @@ static struct buffer *zconf_endfile(void)
        }
        free(current_buf);
        current_buf = parent;
-
-       return parent;
 }
 
 int zconf_lineno(void)
 {
-       if (current_buf)
-               return current_file->lineno - 1;
-       else
-               return 0;
+       return current_pos.lineno;
 }
 
 char *zconf_curname(void)
 {
-       if (current_buf)
-               return current_file->name;
-       else
-               return "<none>";
+       return current_pos.file ? current_pos.file->name : "<none>";
 }