summaryrefslogtreecommitdiff
path: root/scripts/kconfig/zconf.l
diff options
context:
space:
mode:
authorRoman Zippel <zippel@linux-m68k.org>2005-11-08 21:34:53 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 07:55:54 -0800
commita02f0570ae201c495ee991b959bb974af18f35cc (patch)
tree363e06307b7355caa2435a006c5385a1149bb7cc /scripts/kconfig/zconf.l
parent3370f9f0d9c7d14bf71aab27fa45c0537f130614 (diff)
downloadlinux-stable-a02f0570ae201c495ee991b959bb974af18f35cc.tar.gz
linux-stable-a02f0570ae201c495ee991b959bb974af18f35cc.tar.bz2
linux-stable-a02f0570ae201c495ee991b959bb974af18f35cc.zip
[PATCH] kconfig: improve error handling in the parser
Add a few error tokens to the parser to catch common errors and print more descriptive error messages. Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Cc: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'scripts/kconfig/zconf.l')
-rw-r--r--scripts/kconfig/zconf.l42
1 files changed, 24 insertions, 18 deletions
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index cfcfabd7a069..cfa46077c6b4 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -18,6 +18,11 @@
#define START_STRSIZE 16
+static struct {
+ struct file *file;
+ int lineno;
+} current_pos;
+
static char *text;
static int text_size, text_asize;
@@ -31,7 +36,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 +75,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 +96,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 +108,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>{
@@ -214,9 +228,9 @@ n [A-Za-z0-9_]
}
<<EOF>> {
- if (current_buf) {
+ if (current_file) {
zconf_endfile();
- return T_EOF;
+ return T_EOL;
}
fclose(yyin);
yyterminate();
@@ -307,7 +321,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 +337,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>";
}