summaryrefslogtreecommitdiff
path: root/scripts/config/zconf.l
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-08-05 02:18:25 +0000
committerEric Andersen <andersen@codepoet.org>2003-08-05 02:18:25 +0000
commit72d8e444f0e9e002b16328e73464ef9015979048 (patch)
treed1d99e668617e95836a1f767257e1263963feaa5 /scripts/config/zconf.l
parent461c279ac176a28dec40d1e40ebaffe4f0ac688d (diff)
downloadbusybox-w32-72d8e444f0e9e002b16328e73464ef9015979048.tar.gz
busybox-w32-72d8e444f0e9e002b16328e73464ef9015979048.tar.bz2
busybox-w32-72d8e444f0e9e002b16328e73464ef9015979048.zip
Merge/rework config system per the latest from linux-2.6.0-test2.
Fix the config bugs revealed by the updated config system. -Erik
Diffstat (limited to 'scripts/config/zconf.l')
-rw-r--r--scripts/config/zconf.l58
1 files changed, 46 insertions, 12 deletions
diff --git a/scripts/config/zconf.l b/scripts/config/zconf.l
index a412bf411..55517b287 100644
--- a/scripts/config/zconf.l
+++ b/scripts/config/zconf.l
@@ -7,6 +7,7 @@
7 * Released under the terms of the GNU GPL v2.0. 7 * Released under the terms of the GNU GPL v2.0.
8 */ 8 */
9 9
10#include <limits.h>
10#include <stdio.h> 11#include <stdio.h>
11#include <stdlib.h> 12#include <stdlib.h>
12#include <string.h> 13#include <string.h>
@@ -14,7 +15,6 @@
14 15
15#define LKC_DIRECT_LINK 16#define LKC_DIRECT_LINK
16#include "lkc.h" 17#include "lkc.h"
17#include "zconf.tab.h"
18 18
19#define START_STRSIZE 16 19#define START_STRSIZE 16
20 20
@@ -96,6 +96,7 @@ n [A-Za-z0-9_]
96 "endchoice" BEGIN(PARAM); return T_ENDCHOICE; 96 "endchoice" BEGIN(PARAM); return T_ENDCHOICE;
97 "comment" BEGIN(PARAM); return T_COMMENT; 97 "comment" BEGIN(PARAM); return T_COMMENT;
98 "config" BEGIN(PARAM); return T_CONFIG; 98 "config" BEGIN(PARAM); return T_CONFIG;
99 "menuconfig" BEGIN(PARAM); return T_MENUCONFIG;
99 "help" BEGIN(PARAM); return T_HELP; 100 "help" BEGIN(PARAM); return T_HELP;
100 "if" BEGIN(PARAM); return T_IF; 101 "if" BEGIN(PARAM); return T_IF;
101 "endif" BEGIN(PARAM); return T_ENDIF; 102 "endif" BEGIN(PARAM); return T_ENDIF;
@@ -105,11 +106,17 @@ n [A-Za-z0-9_]
105 "default" BEGIN(PARAM); return T_DEFAULT; 106 "default" BEGIN(PARAM); return T_DEFAULT;
106 "prompt" BEGIN(PARAM); return T_PROMPT; 107 "prompt" BEGIN(PARAM); return T_PROMPT;
107 "tristate" BEGIN(PARAM); return T_TRISTATE; 108 "tristate" BEGIN(PARAM); return T_TRISTATE;
109 "def_tristate" BEGIN(PARAM); return T_DEF_TRISTATE;
108 "bool" BEGIN(PARAM); return T_BOOLEAN; 110 "bool" BEGIN(PARAM); return T_BOOLEAN;
109 "boolean" BEGIN(PARAM); return T_BOOLEAN; 111 "boolean" BEGIN(PARAM); return T_BOOLEAN;
112 "def_bool" BEGIN(PARAM); return T_DEF_BOOLEAN;
113 "def_boolean" BEGIN(PARAM); return T_DEF_BOOLEAN;
110 "int" BEGIN(PARAM); return T_INT; 114 "int" BEGIN(PARAM); return T_INT;
111 "hex" BEGIN(PARAM); return T_HEX; 115 "hex" BEGIN(PARAM); return T_HEX;
112 "string" BEGIN(PARAM); return T_STRING; 116 "string" BEGIN(PARAM); return T_STRING;
117 "select" BEGIN(PARAM); return T_SELECT;
118 "enable" BEGIN(PARAM); return T_SELECT;
119 "range" BEGIN(PARAM); return T_RANGE;
113 {n}+ { 120 {n}+ {
114 alloc_string(yytext, yyleng); 121 alloc_string(yytext, yyleng);
115 zconflval.string = text; 122 zconflval.string = text;
@@ -141,6 +148,8 @@ n [A-Za-z0-9_]
141 zconflval.string = text; 148 zconflval.string = text;
142 return T_WORD; 149 return T_WORD;
143 } 150 }
151 #.* /* comment */
152 \\\n current_file->lineno++;
144 . 153 .
145 <<EOF>> { 154 <<EOF>> {
146 BEGIN(INITIAL); 155 BEGIN(INITIAL);
@@ -151,29 +160,30 @@ n [A-Za-z0-9_]
151 [^'"\\\n]+/\n { 160 [^'"\\\n]+/\n {
152 append_string(yytext, yyleng); 161 append_string(yytext, yyleng);
153 zconflval.string = text; 162 zconflval.string = text;
154 return T_STRING; 163 return T_WORD_QUOTE;
155 } 164 }
156 [^'"\\\n]+ { 165 [^'"\\\n]+ {
157 append_string(yytext, yyleng); 166 append_string(yytext, yyleng);
158 } 167 }
159 \\.?/\n { 168 \\.?/\n {
160 append_string(yytext+1, yyleng); 169 append_string(yytext + 1, yyleng - 1);
161 zconflval.string = text; 170 zconflval.string = text;
162 return T_STRING; 171 return T_WORD_QUOTE;
163 } 172 }
164 \\.? { 173 \\.? {
165 append_string(yytext+1, yyleng); 174 append_string(yytext + 1, yyleng - 1);
166 } 175 }
167 \'|\" { 176 \'|\" {
168 if (str == yytext[0]) { 177 if (str == yytext[0]) {
169 BEGIN(PARAM); 178 BEGIN(PARAM);
170 zconflval.string = text; 179 zconflval.string = text;
171 return T_STRING; 180 return T_WORD_QUOTE;
172 } else 181 } else
173 append_string(yytext, 1); 182 append_string(yytext, 1);
174 } 183 }
175 \n { 184 \n {
176 printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); 185 printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno());
186 current_file->lineno++;
177 BEGIN(INITIAL); 187 BEGIN(INITIAL);
178 return T_EOL; 188 return T_EOL;
179 } 189 }
@@ -204,9 +214,8 @@ n [A-Za-z0-9_]
204 } 214 }
205 append_string(" ", ts); 215 append_string(" ", ts);
206 } 216 }
207
208 } 217 }
209 \n/[^ \t\n] { 218 [ \t]*\n/[^ \t\n] {
210 current_file->lineno++; 219 current_file->lineno++;
211 zconf_endhelp(); 220 zconf_endhelp();
212 return T_HELPTEXT; 221 return T_HELPTEXT;
@@ -246,12 +255,37 @@ void zconf_starthelp(void)
246static void zconf_endhelp(void) 255static void zconf_endhelp(void)
247{ 256{
248 zconflval.string = text; 257 zconflval.string = text;
249 BEGIN(INITIAL); 258 BEGIN(INITIAL);
259}
260
261
262/*
263 * Try to open specified file with following names:
264 * ./name
265 * $(srctree)/name
266 * The latter is used when srctree is separate from objtree
267 * when compiling the kernel.
268 * Return NULL if file is not found.
269 */
270FILE *zconf_fopen(const char *name)
271{
272 char *env, fullname[PATH_MAX+1];
273 FILE *f;
274
275 f = fopen(name, "r");
276 if (!f && name[0] != '/') {
277 env = getenv(SRCTREE);
278 if (env) {
279 sprintf(fullname, "%s/%s", env, name);
280 f = fopen(fullname, "r");
281 }
282 }
283 return f;
250} 284}
251 285
252void zconf_initscan(const char *name) 286void zconf_initscan(const char *name)
253{ 287{
254 yyin = fopen(name, "r"); 288 yyin = zconf_fopen(name);
255 if (!yyin) { 289 if (!yyin) {
256 printf("can't find file %s\n", name); 290 printf("can't find file %s\n", name);
257 exit(1); 291 exit(1);
@@ -272,7 +306,7 @@ void zconf_nextfile(const char *name)
272 memset(buf, 0, sizeof(*buf)); 306 memset(buf, 0, sizeof(*buf));
273 307
274 current_buf->state = YY_CURRENT_BUFFER; 308 current_buf->state = YY_CURRENT_BUFFER;
275 yyin = fopen(name, "r"); 309 yyin = zconf_fopen(name);
276 if (!yyin) { 310 if (!yyin) {
277 printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); 311 printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name);
278 exit(1); 312 exit(1);
@@ -318,7 +352,7 @@ static struct buffer *zconf_endfile(void)
318int zconf_lineno(void) 352int zconf_lineno(void)
319{ 353{
320 if (current_buf) 354 if (current_buf)
321 return current_file->lineno; 355 return current_file->lineno - 1;
322 else 356 else
323 return 0; 357 return 0;
324} 358}