diff options
author | Roman Zippel <zippel@linux-m68k.org> | 2005-11-08 21:34:51 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-09 07:55:53 -0800 |
commit | 7a88488bbc231e48a4a88ee2569bc0cc5d706f0a (patch) | |
tree | 2fd6b51b5cf76dd37a2a369a29c50b5121c12a92 /scripts/kconfig/zconf.l | |
parent | 491d711035dc08071ed58cf470f15efadb67cb1c (diff) | |
download | kernel_samsung_tuna-7a88488bbc231e48a4a88ee2569bc0cc5d706f0a.zip kernel_samsung_tuna-7a88488bbc231e48a4a88ee2569bc0cc5d706f0a.tar.gz kernel_samsung_tuna-7a88488bbc231e48a4a88ee2569bc0cc5d706f0a.tar.bz2 |
[PATCH] kconfig: use gperf for kconfig keywords
Use gperf to generate a hash for the kconfig keywords. This greatly reduces
the size of the generated scanner and makes it easier to extend kconfig.
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.l | 53 |
1 files changed, 14 insertions, 39 deletions
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 55517b2..ec90209 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -18,8 +18,7 @@ #define START_STRSIZE 16 -char *text; -static char *text_ptr; +static char *text; static int text_size, text_asize; struct buffer { @@ -38,23 +37,22 @@ void new_string(void) { text = malloc(START_STRSIZE); text_asize = START_STRSIZE; - text_ptr = text; text_size = 0; - *text_ptr = 0; + *text = 0; } void append_string(const char *str, int size) { int new_size = text_size + size + 1; if (new_size > text_asize) { + new_size += START_STRSIZE - 1; + new_size &= -START_STRSIZE; text = realloc(text, new_size); text_asize = new_size; - text_ptr = text + text_size; } - memcpy(text_ptr, str, size); - text_ptr += size; + memcpy(text + text_size, str, size); text_size += size; - *text_ptr = 0; + text[text_size] = 0; } void alloc_string(const char *str, int size) @@ -88,36 +86,12 @@ n [A-Za-z0-9_] <COMMAND>{ - "mainmenu" BEGIN(PARAM); return T_MAINMENU; - "menu" BEGIN(PARAM); return T_MENU; - "endmenu" BEGIN(PARAM); return T_ENDMENU; - "source" BEGIN(PARAM); return T_SOURCE; - "choice" BEGIN(PARAM); return T_CHOICE; - "endchoice" BEGIN(PARAM); return T_ENDCHOICE; - "comment" BEGIN(PARAM); return T_COMMENT; - "config" BEGIN(PARAM); return T_CONFIG; - "menuconfig" BEGIN(PARAM); return T_MENUCONFIG; - "help" BEGIN(PARAM); return T_HELP; - "if" BEGIN(PARAM); return T_IF; - "endif" BEGIN(PARAM); return T_ENDIF; - "depends" BEGIN(PARAM); return T_DEPENDS; - "requires" BEGIN(PARAM); return T_REQUIRES; - "optional" BEGIN(PARAM); return T_OPTIONAL; - "default" BEGIN(PARAM); return T_DEFAULT; - "prompt" BEGIN(PARAM); return T_PROMPT; - "tristate" BEGIN(PARAM); return T_TRISTATE; - "def_tristate" BEGIN(PARAM); return T_DEF_TRISTATE; - "bool" BEGIN(PARAM); return T_BOOLEAN; - "boolean" BEGIN(PARAM); return T_BOOLEAN; - "def_bool" BEGIN(PARAM); return T_DEF_BOOLEAN; - "def_boolean" BEGIN(PARAM); return T_DEF_BOOLEAN; - "int" BEGIN(PARAM); return T_INT; - "hex" BEGIN(PARAM); return T_HEX; - "string" BEGIN(PARAM); return T_STRING; - "select" BEGIN(PARAM); return T_SELECT; - "enable" BEGIN(PARAM); return T_SELECT; - "range" BEGIN(PARAM); return T_RANGE; {n}+ { + struct kconf_id *id = kconf_id_lookup(yytext, yyleng); + if (id && id->flags & TF_COMMAND) { + BEGIN(PARAM); + return id->token; + } alloc_string(yytext, yyleng); zconflval.string = text; return T_WORD; @@ -134,8 +108,6 @@ n [A-Za-z0-9_] "!" return T_NOT; "=" return T_EQUAL; "!=" return T_UNEQUAL; - "if" return T_IF; - "on" return T_ON; \"|\' { str = yytext[0]; new_string(); @@ -144,6 +116,9 @@ n [A-Za-z0-9_] \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; --- /* ignore */ ({n}|[-/.])+ { + struct kconf_id *id = kconf_id_lookup(yytext, yyleng); + if (id && id->flags & TF_PARAM) + return id->token; alloc_string(yytext, yyleng); zconflval.string = text; return T_WORD; |