summaryrefslogtreecommitdiff
authorkergoth <kergoth>2002-11-06 03:54:26 (UTC)
committer kergoth <kergoth>2002-11-06 03:54:26 (UTC)
commit6b7d5deabe1d2da336fbe6c8409e437cbb8a1c89 (patch) (unidiff)
tree9df959827ec4e404d91d3838dde7853c32abe33f
parent2129e9cd500a7755062c93f3b9ea325b9368ea37 (diff)
downloadopie-6b7d5deabe1d2da336fbe6c8409e437cbb8a1c89.zip
opie-6b7d5deabe1d2da336fbe6c8409e437cbb8a1c89.tar.gz
opie-6b7d5deabe1d2da336fbe6c8409e437cbb8a1c89.tar.bz2
Remove kernel references
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--scripts/kconfig/mconf.c8
-rw-r--r--scripts/kconfig/zconf.y2
2 files changed, 5 insertions, 5 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 84699be..dec8603 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -1,452 +1,452 @@
1/* 1/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
4 */ 4 */
5 5
6#include <sys/ioctl.h> 6#include <sys/ioctl.h>
7#include <sys/wait.h> 7#include <sys/wait.h>
8#include <ctype.h> 8#include <ctype.h>
9#include <errno.h> 9#include <errno.h>
10#include <fcntl.h> 10#include <fcntl.h>
11#include <signal.h> 11#include <signal.h>
12#include <stdarg.h> 12#include <stdarg.h>
13#include <stdlib.h> 13#include <stdlib.h>
14#include <string.h> 14#include <string.h>
15#include <unistd.h> 15#include <unistd.h>
16 16
17#define LKC_DIRECT_LINK 17#define LKC_DIRECT_LINK
18#include "lkc.h" 18#include "lkc.h"
19 19
20static char menu_backtitle[128]; 20static char menu_backtitle[128];
21static const char menu_instructions[] = 21static const char menu_instructions[] =
22 "Arrow keys navigate the menu. " 22 "Arrow keys navigate the menu. "
23 "<Enter> selects submenus --->. " 23 "<Enter> selects submenus --->. "
24 "Highlighted letters are hotkeys. " 24 "Highlighted letters are hotkeys. "
25 "Pressing <Y> includes, <N> excludes, <M> modularizes features. " 25 "Pressing <Y> includes, <N> excludes, <M> modularizes features. "
26 "Press <Esc><Esc> to exit, <?> for Help. " 26 "Press <Esc><Esc> to exit, <?> for Help. "
27 "Legend: [*] built-in [ ] excluded <M> module < > module capable", 27 "Legend: [*] built-in [ ] excluded <M> module < > module capable",
28radiolist_instructions[] = 28radiolist_instructions[] =
29 "Use the arrow keys to navigate this window or " 29 "Use the arrow keys to navigate this window or "
30 "press the hotkey of the item you wish to select " 30 "press the hotkey of the item you wish to select "
31 "followed by the <SPACE BAR>. " 31 "followed by the <SPACE BAR>. "
32 "Press <?> for additional information about this option.", 32 "Press <?> for additional information about this option.",
33inputbox_instructions_int[] = 33inputbox_instructions_int[] =
34 "Please enter a decimal value. " 34 "Please enter a decimal value. "
35 "Fractions will not be accepted. " 35 "Fractions will not be accepted. "
36 "Use the <TAB> key to move from the input field to the buttons below it.", 36 "Use the <TAB> key to move from the input field to the buttons below it.",
37inputbox_instructions_hex[] = 37inputbox_instructions_hex[] =
38 "Please enter a hexadecimal value. " 38 "Please enter a hexadecimal value. "
39 "Use the <TAB> key to move from the input field to the buttons below it.", 39 "Use the <TAB> key to move from the input field to the buttons below it.",
40inputbox_instructions_string[] = 40inputbox_instructions_string[] =
41 "Please enter a string value. " 41 "Please enter a string value. "
42 "Use the <TAB> key to move from the input field to the buttons below it.", 42 "Use the <TAB> key to move from the input field to the buttons below it.",
43setmod_text[] = 43setmod_text[] =
44 "This feature depends on another which has been configured as a module.\n" 44 "This feature depends on another which has been configured as a module.\n"
45 "As a result, this feature will be built as a module.", 45 "As a result, this feature will be built as a module.",
46nohelp_text[] = 46nohelp_text[] =
47 "There is no help available for this kernel option.\n", 47 "There is no help available for this option.\n",
48load_config_text[] = 48load_config_text[] =
49 "Enter the name of the configuration file you wish to load. " 49 "Enter the name of the configuration file you wish to load. "
50 "Accept the name shown to restore the configuration you " 50 "Accept the name shown to restore the configuration you "
51 "last retrieved. Leave blank to abort.", 51 "last retrieved. Leave blank to abort.",
52load_config_help[] = 52load_config_help[] =
53 "\n" 53 "\n"
54 "For various reasons, one may wish to keep several different kernel\n" 54 "For various reasons, one may wish to keep several different\n"
55 "configurations available on a single machine.\n" 55 "configurations available on a single machine.\n"
56 "\n" 56 "\n"
57 "If you have saved a previous configuration in a file other than the\n" 57 "If you have saved a previous configuration in a file other than the\n"
58 "kernel's default, entering the name of the file here will allow you\n" 58 "default, entering the name of the file here will allow you\n"
59 "to modify that configuration.\n" 59 "to modify that configuration.\n"
60 "\n" 60 "\n"
61 "If you are uncertain, then you have probably never used alternate\n" 61 "If you are uncertain, then you have probably never used alternate\n"
62 "configuration files. You should therefor leave this blank to abort.\n", 62 "configuration files. You should therefor leave this blank to abort.\n",
63save_config_text[] = 63save_config_text[] =
64 "Enter a filename to which this configuration should be saved " 64 "Enter a filename to which this configuration should be saved "
65 "as an alternate. Leave blank to abort.", 65 "as an alternate. Leave blank to abort.",
66save_config_help[] = 66save_config_help[] =
67 "\n" 67 "\n"
68 "For various reasons, one may wish to keep different kernel\n" 68 "For various reasons, one may wish to keep different\n"
69 "configurations available on a single machine.\n" 69 "configurations available on a single machine.\n"
70 "\n" 70 "\n"
71 "Entering a file name here will allow you to later retrieve, modify\n" 71 "Entering a file name here will allow you to later retrieve, modify\n"
72 "and use the current configuration as an alternate to whatever\n" 72 "and use the current configuration as an alternate to whatever\n"
73 "configuration options you have selected at that time.\n" 73 "configuration options you have selected at that time.\n"
74 "\n" 74 "\n"
75 "If you are uncertain what all this means then you should probably\n" 75 "If you are uncertain what all this means then you should probably\n"
76 "leave this blank.\n" 76 "leave this blank.\n"
77; 77;
78 78
79static char buf[4096], *bufptr = buf; 79static char buf[4096], *bufptr = buf;
80static char input_buf[4096]; 80static char input_buf[4096];
81static char *args[1024], **argptr = args; 81static char *args[1024], **argptr = args;
82static int indent = 0; 82static int indent = 0;
83static int rows, cols; 83static int rows, cols;
84static struct menu *current_menu; 84static struct menu *current_menu;
85static int child_count; 85static int child_count;
86static int do_resize; 86static int do_resize;
87 87
88static void conf(struct menu *menu); 88static void conf(struct menu *menu);
89static void conf_choice(struct menu *menu); 89static void conf_choice(struct menu *menu);
90static void conf_string(struct menu *menu); 90static void conf_string(struct menu *menu);
91static void conf_load(void); 91static void conf_load(void);
92static void conf_save(void); 92static void conf_save(void);
93static void show_textbox(const char *title, const char *text, int r, int c); 93static void show_textbox(const char *title, const char *text, int r, int c);
94static void show_helptext(const char *title, const char *text); 94static void show_helptext(const char *title, const char *text);
95static void show_help(struct menu *menu); 95static void show_help(struct menu *menu);
96static void show_readme(void); 96static void show_readme(void);
97 97
98static void cprint_init(void); 98static void cprint_init(void);
99static int cprint1(const char *fmt, ...); 99static int cprint1(const char *fmt, ...);
100static void cprint_done(void); 100static void cprint_done(void);
101static int cprint(const char *fmt, ...); 101static int cprint(const char *fmt, ...);
102 102
103static void init_wsize(void) 103static void init_wsize(void)
104{ 104{
105 struct winsize ws; 105 struct winsize ws;
106 106
107 if (ioctl(1, TIOCGWINSZ, &ws) == -1) { 107 if (ioctl(1, TIOCGWINSZ, &ws) == -1) {
108 rows = 24; 108 rows = 24;
109 cols = 80; 109 cols = 80;
110 } else { 110 } else {
111 rows = ws.ws_row; 111 rows = ws.ws_row;
112 cols = ws.ws_col; 112 cols = ws.ws_col;
113 } 113 }
114 114
115 if (rows < 19 || cols < 80) { 115 if (rows < 19 || cols < 80) {
116 fprintf(stderr, "Your display is too small to run Menuconfig!\n"); 116 fprintf(stderr, "Your display is too small to run Menuconfig!\n");
117 fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); 117 fprintf(stderr, "It must be at least 19 lines by 80 columns.\n");
118 exit(1); 118 exit(1);
119 } 119 }
120 120
121 rows -= 4; 121 rows -= 4;
122 cols -= 5; 122 cols -= 5;
123} 123}
124 124
125static void cprint_init(void) 125static void cprint_init(void)
126{ 126{
127 bufptr = buf; 127 bufptr = buf;
128 argptr = args; 128 argptr = args;
129 memset(args, 0, sizeof(args)); 129 memset(args, 0, sizeof(args));
130 indent = 0; 130 indent = 0;
131 child_count = 0; 131 child_count = 0;
132 cprint("./scripts/lxdialog/lxdialog"); 132 cprint("./scripts/lxdialog/lxdialog");
133 cprint("--backtitle"); 133 cprint("--backtitle");
134 cprint(menu_backtitle); 134 cprint(menu_backtitle);
135} 135}
136 136
137static int cprint1(const char *fmt, ...) 137static int cprint1(const char *fmt, ...)
138{ 138{
139 va_list ap; 139 va_list ap;
140 int res; 140 int res;
141 141
142 if (!*argptr) 142 if (!*argptr)
143 *argptr = bufptr; 143 *argptr = bufptr;
144 va_start(ap, fmt); 144 va_start(ap, fmt);
145 res = vsprintf(bufptr, fmt, ap); 145 res = vsprintf(bufptr, fmt, ap);
146 va_end(ap); 146 va_end(ap);
147 bufptr += res; 147 bufptr += res;
148 148
149 return res; 149 return res;
150} 150}
151 151
152static void cprint_done(void) 152static void cprint_done(void)
153{ 153{
154 *bufptr++ = 0; 154 *bufptr++ = 0;
155 argptr++; 155 argptr++;
156} 156}
157 157
158static int cprint(const char *fmt, ...) 158static int cprint(const char *fmt, ...)
159{ 159{
160 va_list ap; 160 va_list ap;
161 int res; 161 int res;
162 162
163 *argptr++ = bufptr; 163 *argptr++ = bufptr;
164 va_start(ap, fmt); 164 va_start(ap, fmt);
165 res = vsprintf(bufptr, fmt, ap); 165 res = vsprintf(bufptr, fmt, ap);
166 va_end(ap); 166 va_end(ap);
167 bufptr += res; 167 bufptr += res;
168 *bufptr++ = 0; 168 *bufptr++ = 0;
169 169
170 return res; 170 return res;
171} 171}
172 172
173pid_t pid; 173pid_t pid;
174 174
175static void winch_handler(int sig) 175static void winch_handler(int sig)
176{ 176{
177 if (!do_resize) { 177 if (!do_resize) {
178 kill(pid, SIGINT); 178 kill(pid, SIGINT);
179 do_resize = 1; 179 do_resize = 1;
180 } 180 }
181} 181}
182 182
183static int exec_conf(void) 183static int exec_conf(void)
184{ 184{
185 int pipefd[2], stat, size; 185 int pipefd[2], stat, size;
186 struct sigaction sa; 186 struct sigaction sa;
187 sigset_t sset, osset; 187 sigset_t sset, osset;
188 188
189 sigemptyset(&sset); 189 sigemptyset(&sset);
190 sigaddset(&sset, SIGINT); 190 sigaddset(&sset, SIGINT);
191 sigprocmask(SIG_BLOCK, &sset, &osset); 191 sigprocmask(SIG_BLOCK, &sset, &osset);
192 192
193 signal(SIGINT, SIG_DFL); 193 signal(SIGINT, SIG_DFL);
194 194
195 sa.sa_handler = winch_handler; 195 sa.sa_handler = winch_handler;
196 sigemptyset(&sa.sa_mask); 196 sigemptyset(&sa.sa_mask);
197 sa.sa_flags = SA_RESTART; 197 sa.sa_flags = SA_RESTART;
198 sigaction(SIGWINCH, &sa, NULL); 198 sigaction(SIGWINCH, &sa, NULL);
199 199
200 *argptr++ = NULL; 200 *argptr++ = NULL;
201 201
202 pipe(pipefd); 202 pipe(pipefd);
203 pid = fork(); 203 pid = fork();
204 if (pid == 0) { 204 if (pid == 0) {
205 sigprocmask(SIG_SETMASK, &osset, NULL); 205 sigprocmask(SIG_SETMASK, &osset, NULL);
206 dup2(pipefd[1], 2); 206 dup2(pipefd[1], 2);
207 close(pipefd[0]); 207 close(pipefd[0]);
208 close(pipefd[1]); 208 close(pipefd[1]);
209 execv(args[0], args); 209 execv(args[0], args);
210 _exit(EXIT_FAILURE); 210 _exit(EXIT_FAILURE);
211 } 211 }
212 212
213 close(pipefd[1]); 213 close(pipefd[1]);
214 bufptr = input_buf; 214 bufptr = input_buf;
215 while (1) { 215 while (1) {
216 size = input_buf + sizeof(input_buf) - bufptr; 216 size = input_buf + sizeof(input_buf) - bufptr;
217 size = read(pipefd[0], bufptr, size); 217 size = read(pipefd[0], bufptr, size);
218 if (size <= 0) { 218 if (size <= 0) {
219 if (size < 0) { 219 if (size < 0) {
220 if (errno == EINTR || errno == EAGAIN) 220 if (errno == EINTR || errno == EAGAIN)
221 continue; 221 continue;
222 perror("read"); 222 perror("read");
223 } 223 }
224 break; 224 break;
225 } 225 }
226 bufptr += size; 226 bufptr += size;
227 } 227 }
228 *bufptr++ = 0; 228 *bufptr++ = 0;
229 close(pipefd[0]); 229 close(pipefd[0]);
230 waitpid(pid, &stat, 0); 230 waitpid(pid, &stat, 0);
231 231
232 if (do_resize) { 232 if (do_resize) {
233 init_wsize(); 233 init_wsize();
234 do_resize = 0; 234 do_resize = 0;
235 sigprocmask(SIG_SETMASK, &osset, NULL); 235 sigprocmask(SIG_SETMASK, &osset, NULL);
236 return -1; 236 return -1;
237 } 237 }
238 if (WIFSIGNALED(stat)) { 238 if (WIFSIGNALED(stat)) {
239 printf("\finterrupted(%d)\n", WTERMSIG(stat)); 239 printf("\finterrupted(%d)\n", WTERMSIG(stat));
240 exit(1); 240 exit(1);
241 } 241 }
242#if 0 242#if 0
243 printf("\fexit state: %d\nexit data: '%s'\n", WEXITSTATUS(stat), input_buf); 243 printf("\fexit state: %d\nexit data: '%s'\n", WEXITSTATUS(stat), input_buf);
244 sleep(1); 244 sleep(1);
245#endif 245#endif
246 sigpending(&sset); 246 sigpending(&sset);
247 if (sigismember(&sset, SIGINT)) { 247 if (sigismember(&sset, SIGINT)) {
248 printf("\finterrupted\n"); 248 printf("\finterrupted\n");
249 exit(1); 249 exit(1);
250 } 250 }
251 sigprocmask(SIG_SETMASK, &osset, NULL); 251 sigprocmask(SIG_SETMASK, &osset, NULL);
252 252
253 return WEXITSTATUS(stat); 253 return WEXITSTATUS(stat);
254} 254}
255 255
256static void build_conf(struct menu *menu) 256static void build_conf(struct menu *menu)
257{ 257{
258 struct symbol *sym; 258 struct symbol *sym;
259 struct property *prop; 259 struct property *prop;
260 struct menu *child; 260 struct menu *child;
261 int type, tmp, doint = 2; 261 int type, tmp, doint = 2;
262 tristate val; 262 tristate val;
263 char ch; 263 char ch;
264 264
265 if (!menu_is_visible(menu)) 265 if (!menu_is_visible(menu))
266 return; 266 return;
267 267
268 sym = menu->sym; 268 sym = menu->sym;
269 prop = menu->prompt; 269 prop = menu->prompt;
270 if (!sym) { 270 if (!sym) {
271 if (prop && menu != current_menu) { 271 if (prop && menu != current_menu) {
272 const char *prompt = menu_get_prompt(menu); 272 const char *prompt = menu_get_prompt(menu);
273 switch (prop->type) { 273 switch (prop->type) {
274 case P_MENU: 274 case P_MENU:
275 child_count++; 275 child_count++;
276 cprint("m%p", menu); 276 cprint("m%p", menu);
277 if (menu->parent != &rootmenu) 277 if (menu->parent != &rootmenu)
278 cprint1(" %*c", indent + 1, ' '); 278 cprint1(" %*c", indent + 1, ' ');
279 cprint1("%s --->", prompt); 279 cprint1("%s --->", prompt);
280 cprint_done(); 280 cprint_done();
281 return; 281 return;
282 default: 282 default:
283 if (prompt) { 283 if (prompt) {
284 child_count++; 284 child_count++;
285 cprint(":%p", menu); 285 cprint(":%p", menu);
286 cprint("---%*c%s", indent + 1, ' ', prompt); 286 cprint("---%*c%s", indent + 1, ' ', prompt);
287 } 287 }
288 } 288 }
289 } else 289 } else
290 doint = 0; 290 doint = 0;
291 goto conf_childs; 291 goto conf_childs;
292 } 292 }
293 293
294 type = sym_get_type(sym); 294 type = sym_get_type(sym);
295 if (sym_is_choice(sym)) { 295 if (sym_is_choice(sym)) {
296 struct symbol *def_sym = sym_get_choice_value(sym); 296 struct symbol *def_sym = sym_get_choice_value(sym);
297 struct menu *def_menu = NULL; 297 struct menu *def_menu = NULL;
298 298
299 child_count++; 299 child_count++;
300 for (child = menu->list; child; child = child->next) { 300 for (child = menu->list; child; child = child->next) {
301 if (menu_is_visible(child) && child->sym == def_sym) 301 if (menu_is_visible(child) && child->sym == def_sym)
302 def_menu = child; 302 def_menu = child;
303 } 303 }
304 304
305 val = sym_get_tristate_value(sym); 305 val = sym_get_tristate_value(sym);
306 if (sym_is_changable(sym)) { 306 if (sym_is_changable(sym)) {
307 cprint("t%p", menu); 307 cprint("t%p", menu);
308 switch (type) { 308 switch (type) {
309 case S_BOOLEAN: 309 case S_BOOLEAN:
310 cprint1("[%c]", val == no ? ' ' : '*'); 310 cprint1("[%c]", val == no ? ' ' : '*');
311 break; 311 break;
312 case S_TRISTATE: 312 case S_TRISTATE:
313 switch (val) { 313 switch (val) {
314 case yes: ch = '*'; break; 314 case yes: ch = '*'; break;
315 case mod: ch = 'M'; break; 315 case mod: ch = 'M'; break;
316 default: ch = ' '; break; 316 default: ch = ' '; break;
317 } 317 }
318 cprint1("<%c>", ch); 318 cprint1("<%c>", ch);
319 break; 319 break;
320 } 320 }
321 } else { 321 } else {
322 cprint("%c%p", def_menu ? 't' : ':', menu); 322 cprint("%c%p", def_menu ? 't' : ':', menu);
323 cprint1(" "); 323 cprint1(" ");
324 } 324 }
325 325
326 cprint1("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); 326 cprint1("%*c%s", indent + 1, ' ', menu_get_prompt(menu));
327 if (val == yes) { 327 if (val == yes) {
328 if (def_menu) { 328 if (def_menu) {
329 cprint1(" (%s)", menu_get_prompt(def_menu)); 329 cprint1(" (%s)", menu_get_prompt(def_menu));
330 cprint1(" --->"); 330 cprint1(" --->");
331 cprint_done(); 331 cprint_done();
332 if (def_menu->list) { 332 if (def_menu->list) {
333 indent += 2; 333 indent += 2;
334 build_conf(def_menu); 334 build_conf(def_menu);
335 indent -= 2; 335 indent -= 2;
336 } 336 }
337 } else 337 } else
338 cprint_done(); 338 cprint_done();
339 return; 339 return;
340 } 340 }
341 cprint_done(); 341 cprint_done();
342 } else { 342 } else {
343 child_count++; 343 child_count++;
344 val = sym_get_tristate_value(sym); 344 val = sym_get_tristate_value(sym);
345 if (sym_is_choice_value(sym) && val == yes) { 345 if (sym_is_choice_value(sym) && val == yes) {
346 cprint(":%p", menu); 346 cprint(":%p", menu);
347 cprint1(" "); 347 cprint1(" ");
348 } else { 348 } else {
349 switch (type) { 349 switch (type) {
350 case S_BOOLEAN: 350 case S_BOOLEAN:
351 cprint("t%p", menu); 351 cprint("t%p", menu);
352 cprint1("[%c]", val == no ? ' ' : '*'); 352 cprint1("[%c]", val == no ? ' ' : '*');
353 break; 353 break;
354 case S_TRISTATE: 354 case S_TRISTATE:
355 cprint("t%p", menu); 355 cprint("t%p", menu);
356 switch (val) { 356 switch (val) {
357 case yes: ch = '*'; break; 357 case yes: ch = '*'; break;
358 case mod: ch = 'M'; break; 358 case mod: ch = 'M'; break;
359 default: ch = ' '; break; 359 default: ch = ' '; break;
360 } 360 }
361 cprint1("<%c>", ch); 361 cprint1("<%c>", ch);
362 break; 362 break;
363 default: 363 default:
364 cprint("s%p", menu); 364 cprint("s%p", menu);
365 tmp = cprint1("(%s)", sym_get_string_value(sym)); 365 tmp = cprint1("(%s)", sym_get_string_value(sym));
366 tmp = indent - tmp + 4; 366 tmp = indent - tmp + 4;
367 if (tmp < 0) 367 if (tmp < 0)
368 tmp = 0; 368 tmp = 0;
369 cprint1("%*c%s%s", tmp, ' ', menu_get_prompt(menu), 369 cprint1("%*c%s%s", tmp, ' ', menu_get_prompt(menu),
370 sym_has_value(sym) ? "" : " (NEW)"); 370 sym_has_value(sym) ? "" : " (NEW)");
371 cprint_done(); 371 cprint_done();
372 goto conf_childs; 372 goto conf_childs;
373 } 373 }
374 } 374 }
375 cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), 375 cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu),
376 sym_has_value(sym) ? "" : " (NEW)"); 376 sym_has_value(sym) ? "" : " (NEW)");
377 cprint_done(); 377 cprint_done();
378 } 378 }
379 379
380conf_childs: 380conf_childs:
381 indent += doint; 381 indent += doint;
382 for (child = menu->list; child; child = child->next) 382 for (child = menu->list; child; child = child->next)
383 build_conf(child); 383 build_conf(child);
384 indent -= doint; 384 indent -= doint;
385} 385}
386 386
387static void conf(struct menu *menu) 387static void conf(struct menu *menu)
388{ 388{
389 struct menu *submenu; 389 struct menu *submenu;
390 const char *prompt = menu_get_prompt(menu); 390 const char *prompt = menu_get_prompt(menu);
391 struct symbol *sym; 391 struct symbol *sym;
392 char active_entry[40]; 392 char active_entry[40];
393 int stat, type, i; 393 int stat, type, i;
394 394
395 active_entry[0] = 0; 395 active_entry[0] = 0;
396 while (1) { 396 while (1) {
397 cprint_init(); 397 cprint_init();
398 cprint("--title"); 398 cprint("--title");
399 cprint("%s", prompt ? prompt : "Main Menu"); 399 cprint("%s", prompt ? prompt : "Main Menu");
400 cprint("--menu"); 400 cprint("--menu");
401 cprint(menu_instructions); 401 cprint(menu_instructions);
402 cprint("%d", rows); 402 cprint("%d", rows);
403 cprint("%d", cols); 403 cprint("%d", cols);
404 cprint("%d", rows - 10); 404 cprint("%d", rows - 10);
405 cprint("%s", active_entry); 405 cprint("%s", active_entry);
406 current_menu = menu; 406 current_menu = menu;
407 build_conf(menu); 407 build_conf(menu);
408 if (!child_count) 408 if (!child_count)
409 break; 409 break;
410 if (menu == &rootmenu) { 410 if (menu == &rootmenu) {
411 cprint(":"); 411 cprint(":");
412 cprint("--- "); 412 cprint("--- ");
413 cprint("L"); 413 cprint("L");
414 cprint("Load an Alternate Configuration File"); 414 cprint("Load an Alternate Configuration File");
415 cprint("S"); 415 cprint("S");
416 cprint("Save Configuration to an Alternate File"); 416 cprint("Save Configuration to an Alternate File");
417 } 417 }
418 stat = exec_conf(); 418 stat = exec_conf();
419 if (stat < 0) 419 if (stat < 0)
420 continue; 420 continue;
421 421
422 if (stat == 1 || stat == 255) 422 if (stat == 1 || stat == 255)
423 break; 423 break;
424 424
425 type = input_buf[0]; 425 type = input_buf[0];
426 if (!type) 426 if (!type)
427 continue; 427 continue;
428 428
429 for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++) 429 for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++)
430 ; 430 ;
431 if (i >= sizeof(active_entry)) 431 if (i >= sizeof(active_entry))
432 i = sizeof(active_entry) - 1; 432 i = sizeof(active_entry) - 1;
433 input_buf[i] = 0; 433 input_buf[i] = 0;
434 strcpy(active_entry, input_buf); 434 strcpy(active_entry, input_buf);
435 435
436 sym = NULL; 436 sym = NULL;
437 submenu = NULL; 437 submenu = NULL;
438 if (sscanf(input_buf + 1, "%p", &submenu) == 1) 438 if (sscanf(input_buf + 1, "%p", &submenu) == 1)
439 sym = submenu->sym; 439 sym = submenu->sym;
440 440
441 switch (stat) { 441 switch (stat) {
442 case 0: 442 case 0:
443 switch (type) { 443 switch (type) {
444 case 'm': 444 case 'm':
445 conf(submenu); 445 conf(submenu);
446 break; 446 break;
447 case 't': 447 case 't':
448 if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) 448 if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
449 conf_choice(submenu); 449 conf_choice(submenu);
450 break; 450 break;
451 case 's': 451 case 's':
452 conf_string(submenu); 452 conf_string(submenu);
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 79cb983..c3f1bd0 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -43,609 +43,609 @@ struct symbol *symbol_hash[257];
43%token T_ENDMENU 43%token T_ENDMENU
44%token T_SOURCE 44%token T_SOURCE
45%token T_CHOICE 45%token T_CHOICE
46%token T_ENDCHOICE 46%token T_ENDCHOICE
47%token T_COMMENT 47%token T_COMMENT
48%token T_CONFIG 48%token T_CONFIG
49%token T_HELP 49%token T_HELP
50%token <string> T_HELPTEXT 50%token <string> T_HELPTEXT
51%token T_IF 51%token T_IF
52%token T_ENDIF 52%token T_ENDIF
53%token T_DEPENDS 53%token T_DEPENDS
54%token T_REQUIRES 54%token T_REQUIRES
55%token T_OPTIONAL 55%token T_OPTIONAL
56%token T_PROMPT 56%token T_PROMPT
57%token T_DEFAULT 57%token T_DEFAULT
58%token T_TRISTATE 58%token T_TRISTATE
59%token T_BOOLEAN 59%token T_BOOLEAN
60%token T_INT 60%token T_INT
61%token T_HEX 61%token T_HEX
62%token <string> T_WORD 62%token <string> T_WORD
63%token <string> T_STRING 63%token <string> T_STRING
64%token T_UNEQUAL 64%token T_UNEQUAL
65%token T_EOF 65%token T_EOF
66%token T_EOL 66%token T_EOL
67%token T_CLOSE_PAREN 67%token T_CLOSE_PAREN
68%token T_OPEN_PAREN 68%token T_OPEN_PAREN
69%token T_ON 69%token T_ON
70 70
71%left T_OR 71%left T_OR
72%left T_AND 72%left T_AND
73%left T_EQUAL T_UNEQUAL 73%left T_EQUAL T_UNEQUAL
74%nonassoc T_NOT 74%nonassoc T_NOT
75 75
76%type <string> prompt 76%type <string> prompt
77%type <string> source 77%type <string> source
78%type <symbol> symbol 78%type <symbol> symbol
79%type <expr> expr 79%type <expr> expr
80%type <expr> if_expr 80%type <expr> if_expr
81%type <token> end 81%type <token> end
82 82
83%{ 83%{
84#define LKC_DIRECT_LINK 84#define LKC_DIRECT_LINK
85#include "lkc.h" 85#include "lkc.h"
86%} 86%}
87%% 87%%
88 input: /* empty */ 88 input: /* empty */
89 | input block 89 | input block
90; 90;
91 91
92 block: common_block 92 block: common_block
93 | choice_stmt 93 | choice_stmt
94 | menu_stmt 94 | menu_stmt
95 | T_MAINMENU prompt nl_or_eof 95 | T_MAINMENU prompt nl_or_eof
96 | T_ENDMENU { zconfprint("unexpected 'endmenu' statement"); } 96 | T_ENDMENU { zconfprint("unexpected 'endmenu' statement"); }
97 | T_ENDIF { zconfprint("unexpected 'endif' statement"); } 97 | T_ENDIF { zconfprint("unexpected 'endif' statement"); }
98 | T_ENDCHOICE { zconfprint("unexpected 'endchoice' statement"); } 98 | T_ENDCHOICE { zconfprint("unexpected 'endchoice' statement"); }
99 | error nl_or_eof{ zconfprint("syntax error"); yyerrok; } 99 | error nl_or_eof{ zconfprint("syntax error"); yyerrok; }
100; 100;
101 101
102common_block: 102common_block:
103 if_stmt 103 if_stmt
104 | comment_stmt 104 | comment_stmt
105 | config_stmt 105 | config_stmt
106 | source_stmt 106 | source_stmt
107 | nl_or_eof 107 | nl_or_eof
108; 108;
109 109
110 110
111/* config entry */ 111/* config entry */
112 112
113config_entry_start: T_CONFIG T_WORD 113config_entry_start: T_CONFIG T_WORD
114{ 114{
115 struct symbol *sym = sym_lookup($2, 0); 115 struct symbol *sym = sym_lookup($2, 0);
116 sym->flags |= SYMBOL_OPTIONAL; 116 sym->flags |= SYMBOL_OPTIONAL;
117 menu_add_entry(sym); 117 menu_add_entry(sym);
118 printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2); 118 printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2);
119}; 119};
120 120
121config_stmt: config_entry_start T_EOL config_option_list 121config_stmt: config_entry_start T_EOL config_option_list
122{ 122{
123 menu_end_entry(); 123 menu_end_entry();
124 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); 124 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
125}; 125};
126 126
127config_option_list: 127config_option_list:
128 /* empty */ 128 /* empty */
129 | config_option_list config_option T_EOL 129 | config_option_list config_option T_EOL
130 | config_option_list depends T_EOL 130 | config_option_list depends T_EOL
131 | config_option_list help 131 | config_option_list help
132 | config_option_list T_EOL 132 | config_option_list T_EOL
133{ }; 133{ };
134 134
135config_option: T_TRISTATE prompt_stmt_opt 135config_option: T_TRISTATE prompt_stmt_opt
136{ 136{
137 menu_set_type(S_TRISTATE); 137 menu_set_type(S_TRISTATE);
138 printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); 138 printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno());
139}; 139};
140 140
141config_option: T_BOOLEAN prompt_stmt_opt 141config_option: T_BOOLEAN prompt_stmt_opt
142{ 142{
143 menu_set_type(S_BOOLEAN); 143 menu_set_type(S_BOOLEAN);
144 printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); 144 printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno());
145}; 145};
146 146
147config_option: T_INT prompt_stmt_opt 147config_option: T_INT prompt_stmt_opt
148{ 148{
149 menu_set_type(S_INT); 149 menu_set_type(S_INT);
150 printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno()); 150 printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno());
151}; 151};
152 152
153config_option: T_HEX prompt_stmt_opt 153config_option: T_HEX prompt_stmt_opt
154{ 154{
155 menu_set_type(S_HEX); 155 menu_set_type(S_HEX);
156 printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno()); 156 printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno());
157}; 157};
158 158
159config_option: T_STRING prompt_stmt_opt 159config_option: T_STRING prompt_stmt_opt
160{ 160{
161 menu_set_type(S_STRING); 161 menu_set_type(S_STRING);
162 printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno()); 162 printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno());
163}; 163};
164 164
165config_option: T_PROMPT prompt if_expr 165config_option: T_PROMPT prompt if_expr
166{ 166{
167 menu_add_prop(P_PROMPT, $2, NULL, $3); 167 menu_add_prop(P_PROMPT, $2, NULL, $3);
168 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); 168 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
169}; 169};
170 170
171config_option: T_DEFAULT symbol if_expr 171config_option: T_DEFAULT symbol if_expr
172{ 172{
173 menu_add_prop(P_DEFAULT, NULL, $2, $3); 173 menu_add_prop(P_DEFAULT, NULL, $2, $3);
174 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); 174 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno());
175}; 175};
176 176
177/* choice entry */ 177/* choice entry */
178 178
179choice: T_CHOICE 179choice: T_CHOICE
180{ 180{
181 struct symbol *sym = sym_lookup(NULL, 0); 181 struct symbol *sym = sym_lookup(NULL, 0);
182 sym->flags |= SYMBOL_CHOICE; 182 sym->flags |= SYMBOL_CHOICE;
183 menu_add_entry(sym); 183 menu_add_entry(sym);
184 menu_add_prop(P_CHOICE, NULL, NULL, NULL); 184 menu_add_prop(P_CHOICE, NULL, NULL, NULL);
185 printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); 185 printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
186}; 186};
187 187
188choice_entry: choice T_EOL choice_option_list 188choice_entry: choice T_EOL choice_option_list
189{ 189{
190 menu_end_entry(); 190 menu_end_entry();
191 menu_add_menu(); 191 menu_add_menu();
192}; 192};
193 193
194choice_end: end 194choice_end: end
195{ 195{
196 if (zconf_endtoken($1, T_CHOICE, T_ENDCHOICE)) { 196 if (zconf_endtoken($1, T_CHOICE, T_ENDCHOICE)) {
197 menu_end_menu(); 197 menu_end_menu();
198 printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); 198 printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
199 } 199 }
200}; 200};
201 201
202choice_stmt: 202choice_stmt:
203 choice_entry choice_block choice_end T_EOL 203 choice_entry choice_block choice_end T_EOL
204 | choice_entry choice_block 204 | choice_entry choice_block
205{ 205{
206 printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno); 206 printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno);
207 zconfnerrs++; 207 zconfnerrs++;
208}; 208};
209 209
210choice_option_list: 210choice_option_list:
211 /* empty */ 211 /* empty */
212 | choice_option_list choice_option T_EOL 212 | choice_option_list choice_option T_EOL
213 | choice_option_list depends T_EOL 213 | choice_option_list depends T_EOL
214 | choice_option_list help 214 | choice_option_list help
215 | choice_option_list T_EOL 215 | choice_option_list T_EOL
216; 216;
217 217
218choice_option: T_PROMPT prompt if_expr 218choice_option: T_PROMPT prompt if_expr
219{ 219{
220 menu_add_prop(P_PROMPT, $2, NULL, $3); 220 menu_add_prop(P_PROMPT, $2, NULL, $3);
221 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); 221 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
222}; 222};
223 223
224choice_option: T_OPTIONAL 224choice_option: T_OPTIONAL
225{ 225{
226 current_entry->sym->flags |= SYMBOL_OPTIONAL; 226 current_entry->sym->flags |= SYMBOL_OPTIONAL;
227 printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); 227 printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
228}; 228};
229 229
230choice_option: T_DEFAULT symbol 230choice_option: T_DEFAULT symbol
231{ 231{
232 menu_add_prop(P_DEFAULT, NULL, $2, NULL); 232 menu_add_prop(P_DEFAULT, NULL, $2, NULL);
233 //current_choice->prop->def = $2; 233 //current_choice->prop->def = $2;
234 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); 234 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno());
235}; 235};
236 236
237choice_block: 237choice_block:
238 /* empty */ 238 /* empty */
239 | choice_block common_block 239 | choice_block common_block
240; 240;
241 241
242/* if entry */ 242/* if entry */
243 243
244if: T_IF expr 244if: T_IF expr
245{ 245{
246 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); 246 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
247 menu_add_entry(NULL); 247 menu_add_entry(NULL);
248 //current_entry->prompt = menu_add_prop(T_IF, NULL, NULL, $2); 248 //current_entry->prompt = menu_add_prop(T_IF, NULL, NULL, $2);
249 menu_add_dep($2); 249 menu_add_dep($2);
250 menu_end_entry(); 250 menu_end_entry();
251 menu_add_menu(); 251 menu_add_menu();
252}; 252};
253 253
254if_end: end 254if_end: end
255{ 255{
256 if (zconf_endtoken($1, T_IF, T_ENDIF)) { 256 if (zconf_endtoken($1, T_IF, T_ENDIF)) {
257 menu_end_menu(); 257 menu_end_menu();
258 printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); 258 printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
259 } 259 }
260}; 260};
261 261
262if_stmt: 262if_stmt:
263 if T_EOL if_block if_end T_EOL 263 if T_EOL if_block if_end T_EOL
264 | if T_EOL if_block 264 | if T_EOL if_block
265{ 265{
266 printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno); 266 printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno);
267 zconfnerrs++; 267 zconfnerrs++;
268}; 268};
269 269
270if_block: 270if_block:
271 /* empty */ 271 /* empty */
272 | if_block common_block 272 | if_block common_block
273 | if_block menu_stmt 273 | if_block menu_stmt
274 | if_block choice_stmt 274 | if_block choice_stmt
275; 275;
276 276
277/* menu entry */ 277/* menu entry */
278 278
279menu: T_MENU prompt 279menu: T_MENU prompt
280{ 280{
281 menu_add_entry(NULL); 281 menu_add_entry(NULL);
282 menu_add_prop(P_MENU, $2, NULL, NULL); 282 menu_add_prop(P_MENU, $2, NULL, NULL);
283 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); 283 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
284}; 284};
285 285
286menu_entry: menu T_EOL depends_list 286menu_entry: menu T_EOL depends_list
287{ 287{
288 menu_end_entry(); 288 menu_end_entry();
289 menu_add_menu(); 289 menu_add_menu();
290}; 290};
291 291
292menu_end: end 292menu_end: end
293{ 293{
294 if (zconf_endtoken($1, T_MENU, T_ENDMENU)) { 294 if (zconf_endtoken($1, T_MENU, T_ENDMENU)) {
295 menu_end_menu(); 295 menu_end_menu();
296 printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); 296 printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
297 } 297 }
298}; 298};
299 299
300menu_stmt: 300menu_stmt:
301 menu_entry menu_block menu_end T_EOL 301 menu_entry menu_block menu_end T_EOL
302 | menu_entry menu_block 302 | menu_entry menu_block
303{ 303{
304 printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno); 304 printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno);
305 zconfnerrs++; 305 zconfnerrs++;
306}; 306};
307 307
308menu_block: 308menu_block:
309 /* empty */ 309 /* empty */
310 | menu_block common_block 310 | menu_block common_block
311 | menu_block menu_stmt 311 | menu_block menu_stmt
312 | menu_block choice_stmt 312 | menu_block choice_stmt
313 | menu_block error T_EOL { zconfprint("invalid menu option"); yyerrok; } 313 | menu_block error T_EOL { zconfprint("invalid menu option"); yyerrok; }
314; 314;
315 315
316source: T_SOURCE prompt 316source: T_SOURCE prompt
317{ 317{
318 $$ = $2; 318 $$ = $2;
319 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); 319 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2);
320}; 320};
321 321
322source_stmt: source T_EOL 322source_stmt: source T_EOL
323{ 323{
324 zconf_nextfile($1); 324 zconf_nextfile($1);
325}; 325};
326 326
327/* comment entry */ 327/* comment entry */
328 328
329comment: T_COMMENT prompt 329comment: T_COMMENT prompt
330{ 330{
331 menu_add_entry(NULL); 331 menu_add_entry(NULL);
332 menu_add_prop(P_COMMENT, $2, NULL, NULL); 332 menu_add_prop(P_COMMENT, $2, NULL, NULL);
333 printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); 333 printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
334}; 334};
335 335
336comment_stmt: comment T_EOL depends_list 336comment_stmt: comment T_EOL depends_list
337{ 337{
338 menu_end_entry(); 338 menu_end_entry();
339}; 339};
340 340
341/* help option */ 341/* help option */
342 342
343help_start: T_HELP T_EOL 343help_start: T_HELP T_EOL
344{ 344{
345 printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); 345 printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
346 zconf_starthelp(); 346 zconf_starthelp();
347}; 347};
348 348
349help: help_start T_HELPTEXT 349help: help_start T_HELPTEXT
350{ 350{
351 current_entry->sym->help = $2; 351 current_entry->sym->help = $2;
352}; 352};
353 353
354/* depends option */ 354/* depends option */
355 355
356 depends_list: /* empty */ 356 depends_list: /* empty */
357 | depends_list depends T_EOL 357 | depends_list depends T_EOL
358 | depends_list T_EOL 358 | depends_list T_EOL
359{ }; 359{ };
360 360
361depends: T_DEPENDS T_ON expr 361depends: T_DEPENDS T_ON expr
362{ 362{
363 menu_add_dep($3); 363 menu_add_dep($3);
364 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); 364 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
365} 365}
366 | T_DEPENDS expr 366 | T_DEPENDS expr
367{ 367{
368 menu_add_dep($2); 368 menu_add_dep($2);
369 printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); 369 printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno());
370} 370}
371 | T_REQUIRES expr 371 | T_REQUIRES expr
372{ 372{
373 menu_add_dep($2); 373 menu_add_dep($2);
374 printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); 374 printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno());
375}; 375};
376 376
377/* prompt statement */ 377/* prompt statement */
378 378
379prompt_stmt_opt: 379prompt_stmt_opt:
380 /* empty */ 380 /* empty */
381 | prompt 381 | prompt
382{ 382{
383 menu_add_prop(P_PROMPT, $1, NULL, NULL); 383 menu_add_prop(P_PROMPT, $1, NULL, NULL);
384} 384}
385 | prompt T_IF expr 385 | prompt T_IF expr
386{ 386{
387 menu_add_prop(P_PROMPT, $1, NULL, $3); 387 menu_add_prop(P_PROMPT, $1, NULL, $3);
388}; 388};
389 389
390 prompt: T_WORD 390 prompt: T_WORD
391 | T_STRING 391 | T_STRING
392; 392;
393 393
394 end: T_ENDMENU { $$ = T_ENDMENU; } 394 end: T_ENDMENU { $$ = T_ENDMENU; }
395 | T_ENDCHOICE { $$ = T_ENDCHOICE; } 395 | T_ENDCHOICE { $$ = T_ENDCHOICE; }
396 | T_ENDIF { $$ = T_ENDIF; } 396 | T_ENDIF { $$ = T_ENDIF; }
397; 397;
398 398
399nl_or_eof: 399nl_or_eof:
400 T_EOL | T_EOF; 400 T_EOL | T_EOF;
401 401
402 if_expr: /* empty */ { $$ = NULL; } 402 if_expr: /* empty */ { $$ = NULL; }
403 | T_IF expr { $$ = $2; } 403 | T_IF expr { $$ = $2; }
404; 404;
405 405
406 expr: symbol { $$ = expr_alloc_symbol($1); } 406 expr: symbol { $$ = expr_alloc_symbol($1); }
407 | symbol T_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); } 407 | symbol T_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); }
408 | symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); } 408 | symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); }
409 | T_OPEN_PAREN expr T_CLOSE_PAREN{ $$ = $2; } 409 | T_OPEN_PAREN expr T_CLOSE_PAREN{ $$ = $2; }
410 | T_NOT expr { $$ = expr_alloc_one(E_NOT, $2); } 410 | T_NOT expr { $$ = expr_alloc_one(E_NOT, $2); }
411 | expr T_OR expr { $$ = expr_alloc_two(E_OR, $1, $3); } 411 | expr T_OR expr { $$ = expr_alloc_two(E_OR, $1, $3); }
412 | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); } 412 | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); }
413; 413;
414 414
415 symbol: T_WORD{ $$ = sym_lookup($1, 0); free($1); } 415 symbol: T_WORD{ $$ = sym_lookup($1, 0); free($1); }
416 | T_STRING{ $$ = sym_lookup($1, 1); free($1); } 416 | T_STRING{ $$ = sym_lookup($1, 1); free($1); }
417; 417;
418 418
419%% 419%%
420 420
421void conf_parse(const char *name) 421void conf_parse(const char *name)
422{ 422{
423 zconf_initscan(name); 423 zconf_initscan(name);
424 424
425 sym_init(); 425 sym_init();
426 menu_init(); 426 menu_init();
427 rootmenu.prompt = menu_add_prop(P_MENU, "Linux Kernel Configuration", NULL, NULL); 427 rootmenu.prompt = menu_add_prop(P_MENU, "Configuration", NULL, NULL);
428 428
429 //zconfdebug = 1; 429 //zconfdebug = 1;
430 zconfparse(); 430 zconfparse();
431 if (zconfnerrs) 431 if (zconfnerrs)
432 exit(1); 432 exit(1);
433 menu_finalize(&rootmenu); 433 menu_finalize(&rootmenu);
434 434
435 modules_sym = sym_lookup("MODULES", 0); 435 modules_sym = sym_lookup("MODULES", 0);
436 436
437 sym_change_count = 1; 437 sym_change_count = 1;
438} 438}
439 439
440const char *zconf_tokenname(int token) 440const char *zconf_tokenname(int token)
441{ 441{
442 switch (token) { 442 switch (token) {
443 case T_MENU: return "menu"; 443 case T_MENU: return "menu";
444 case T_ENDMENU: return "endmenu"; 444 case T_ENDMENU: return "endmenu";
445 case T_CHOICE: return "choice"; 445 case T_CHOICE: return "choice";
446 case T_ENDCHOICE:return "endchoice"; 446 case T_ENDCHOICE:return "endchoice";
447 case T_IF: return "if"; 447 case T_IF: return "if";
448 case T_ENDIF: return "endif"; 448 case T_ENDIF: return "endif";
449 } 449 }
450 return "<token>"; 450 return "<token>";
451} 451}
452 452
453static bool zconf_endtoken(int token, int starttoken, int endtoken) 453static bool zconf_endtoken(int token, int starttoken, int endtoken)
454{ 454{
455 if (token != endtoken) { 455 if (token != endtoken) {
456 zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken)); 456 zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken));
457 zconfnerrs++; 457 zconfnerrs++;
458 return false; 458 return false;
459 } 459 }
460 if (current_menu->file != current_file) { 460 if (current_menu->file != current_file) {
461 zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken)); 461 zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken));
462 zconfprint("location of the '%s'", zconf_tokenname(starttoken)); 462 zconfprint("location of the '%s'", zconf_tokenname(starttoken));
463 zconfnerrs++; 463 zconfnerrs++;
464 return false; 464 return false;
465 } 465 }
466 return true; 466 return true;
467} 467}
468 468
469static void zconfprint(const char *err, ...) 469static void zconfprint(const char *err, ...)
470{ 470{
471 va_list ap; 471 va_list ap;
472 472
473 fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); 473 fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
474 va_start(ap, err); 474 va_start(ap, err);
475 vfprintf(stderr, err, ap); 475 vfprintf(stderr, err, ap);
476 va_end(ap); 476 va_end(ap);
477 fprintf(stderr, "\n"); 477 fprintf(stderr, "\n");
478} 478}
479 479
480static void zconferror(const char *err) 480static void zconferror(const char *err)
481{ 481{
482 fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno(), err); 482 fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno(), err);
483} 483}
484 484
485void print_quoted_string(FILE *out, const char *str) 485void print_quoted_string(FILE *out, const char *str)
486{ 486{
487 const char *p; 487 const char *p;
488 int len; 488 int len;
489 489
490 putc('"', out); 490 putc('"', out);
491 while ((p = strchr(str, '"'))) { 491 while ((p = strchr(str, '"'))) {
492 len = p - str; 492 len = p - str;
493 if (len) 493 if (len)
494 fprintf(out, "%.*s", len, str); 494 fprintf(out, "%.*s", len, str);
495 fputs("\\\"", out); 495 fputs("\\\"", out);
496 str = p + 1; 496 str = p + 1;
497 } 497 }
498 fputs(str, out); 498 fputs(str, out);
499 putc('"', out); 499 putc('"', out);
500} 500}
501 501
502void print_symbol(FILE *out, struct menu *menu) 502void print_symbol(FILE *out, struct menu *menu)
503{ 503{
504 struct symbol *sym = menu->sym; 504 struct symbol *sym = menu->sym;
505 struct property *prop; 505 struct property *prop;
506 506
507 //sym->flags |= SYMBOL_PRINTED; 507 //sym->flags |= SYMBOL_PRINTED;
508 508
509 if (sym_is_choice(sym)) 509 if (sym_is_choice(sym))
510 fprintf(out, "choice\n"); 510 fprintf(out, "choice\n");
511 else 511 else
512 fprintf(out, "config %s\n", sym->name); 512 fprintf(out, "config %s\n", sym->name);
513 switch (sym->type) { 513 switch (sym->type) {
514 case S_BOOLEAN: 514 case S_BOOLEAN:
515 fputs(" boolean\n", out); 515 fputs(" boolean\n", out);
516 break; 516 break;
517 case S_TRISTATE: 517 case S_TRISTATE:
518 fputs(" tristate\n", out); 518 fputs(" tristate\n", out);
519 break; 519 break;
520 case S_STRING: 520 case S_STRING:
521 fputs(" string\n", out); 521 fputs(" string\n", out);
522 break; 522 break;
523 case S_INT: 523 case S_INT:
524 fputs(" integer\n", out); 524 fputs(" integer\n", out);
525 break; 525 break;
526 case S_HEX: 526 case S_HEX:
527 fputs(" hex\n", out); 527 fputs(" hex\n", out);
528 break; 528 break;
529 default: 529 default:
530 fputs(" ???\n", out); 530 fputs(" ???\n", out);
531 break; 531 break;
532 } 532 }
533#if 0 533#if 0
534 if (!expr_is_yes(sym->dep)) { 534 if (!expr_is_yes(sym->dep)) {
535 fputs(" depends ", out); 535 fputs(" depends ", out);
536 expr_fprint(sym->dep, out); 536 expr_fprint(sym->dep, out);
537 fputc('\n', out); 537 fputc('\n', out);
538 } 538 }
539#endif 539#endif
540 for (prop = sym->prop; prop; prop = prop->next) { 540 for (prop = sym->prop; prop; prop = prop->next) {
541 if (prop->menu != menu) 541 if (prop->menu != menu)
542 continue; 542 continue;
543 switch (prop->type) { 543 switch (prop->type) {
544 case P_PROMPT: 544 case P_PROMPT:
545 fputs(" prompt ", out); 545 fputs(" prompt ", out);
546 print_quoted_string(out, prop->text); 546 print_quoted_string(out, prop->text);
547 if (prop->def) { 547 if (prop->def) {
548 fputc(' ', out); 548 fputc(' ', out);
549 if (prop->def->flags & SYMBOL_CONST) 549 if (prop->def->flags & SYMBOL_CONST)
550 print_quoted_string(out, prop->def->name); 550 print_quoted_string(out, prop->def->name);
551 else 551 else
552 fputs(prop->def->name, out); 552 fputs(prop->def->name, out);
553 } 553 }
554 if (!expr_is_yes(E_EXPR(prop->visible))) { 554 if (!expr_is_yes(E_EXPR(prop->visible))) {
555 fputs(" if ", out); 555 fputs(" if ", out);
556 expr_fprint(E_EXPR(prop->visible), out); 556 expr_fprint(E_EXPR(prop->visible), out);
557 } 557 }
558 fputc('\n', out); 558 fputc('\n', out);
559 break; 559 break;
560 case P_DEFAULT: 560 case P_DEFAULT:
561 fputs( " default ", out); 561 fputs( " default ", out);
562 print_quoted_string(out, prop->def->name); 562 print_quoted_string(out, prop->def->name);
563 if (!expr_is_yes(E_EXPR(prop->visible))) { 563 if (!expr_is_yes(E_EXPR(prop->visible))) {
564 fputs(" if ", out); 564 fputs(" if ", out);
565 expr_fprint(E_EXPR(prop->visible), out); 565 expr_fprint(E_EXPR(prop->visible), out);
566 } 566 }
567 fputc('\n', out); 567 fputc('\n', out);
568 break; 568 break;
569 case P_CHOICE: 569 case P_CHOICE:
570 fputs(" #choice value\n", out); 570 fputs(" #choice value\n", out);
571 break; 571 break;
572 default: 572 default:
573 fprintf(out, " unknown prop %d!\n", prop->type); 573 fprintf(out, " unknown prop %d!\n", prop->type);
574 break; 574 break;
575 } 575 }
576 } 576 }
577 if (sym->help) { 577 if (sym->help) {
578 int len = strlen(sym->help); 578 int len = strlen(sym->help);
579 while (sym->help[--len] == '\n') 579 while (sym->help[--len] == '\n')
580 sym->help[len] = 0; 580 sym->help[len] = 0;
581 fprintf(out, " help\n%s\n", sym->help); 581 fprintf(out, " help\n%s\n", sym->help);
582 } 582 }
583 fputc('\n', out); 583 fputc('\n', out);
584} 584}
585 585
586void zconfdump(FILE *out) 586void zconfdump(FILE *out)
587{ 587{
588 //struct file *file; 588 //struct file *file;
589 struct property *prop; 589 struct property *prop;
590 struct symbol *sym; 590 struct symbol *sym;
591 struct menu *menu; 591 struct menu *menu;
592 592
593 menu = rootmenu.list; 593 menu = rootmenu.list;
594 while (menu) { 594 while (menu) {
595 if ((sym = menu->sym)) 595 if ((sym = menu->sym))
596 print_symbol(out, menu); 596 print_symbol(out, menu);
597 else if ((prop = menu->prompt)) { 597 else if ((prop = menu->prompt)) {
598 switch (prop->type) { 598 switch (prop->type) {
599 //case T_MAINMENU: 599 //case T_MAINMENU:
600 //fputs("\nmainmenu ", out); 600 //fputs("\nmainmenu ", out);
601 //print_quoted_string(out, prop->text); 601 //print_quoted_string(out, prop->text);
602 //fputs("\n", out); 602 //fputs("\n", out);
603 //break; 603 //break;
604 case P_COMMENT: 604 case P_COMMENT:
605 fputs("\ncomment ", out); 605 fputs("\ncomment ", out);
606 print_quoted_string(out, prop->text); 606 print_quoted_string(out, prop->text);
607 fputs("\n", out); 607 fputs("\n", out);
608 break; 608 break;
609 case P_MENU: 609 case P_MENU:
610 fputs("\nmenu ", out); 610 fputs("\nmenu ", out);
611 print_quoted_string(out, prop->text); 611 print_quoted_string(out, prop->text);
612 fputs("\n", out); 612 fputs("\n", out);
613 break; 613 break;
614 //case T_SOURCE: 614 //case T_SOURCE:
615 //fputs("\nsource ", out); 615 //fputs("\nsource ", out);
616 //print_quoted_string(out, prop->text); 616 //print_quoted_string(out, prop->text);
617 //fputs("\n", out); 617 //fputs("\n", out);
618 //break; 618 //break;
619 //case T_IF: 619 //case T_IF:
620 //fputs("\nif\n", out); 620 //fputs("\nif\n", out);
621 default: 621 default:
622 ; 622 ;
623 } 623 }
624 if (!expr_is_yes(E_EXPR(prop->visible))) { 624 if (!expr_is_yes(E_EXPR(prop->visible))) {
625 fputs(" depends ", out); 625 fputs(" depends ", out);
626 expr_fprint(E_EXPR(prop->visible), out); 626 expr_fprint(E_EXPR(prop->visible), out);
627 fputc('\n', out); 627 fputc('\n', out);
628 } 628 }
629 fputs("\n", out); 629 fputs("\n", out);
630 } 630 }
631 631
632 if (menu->list) 632 if (menu->list)
633 menu = menu->list; 633 menu = menu->list;
634 else if (menu->next) 634 else if (menu->next)
635 menu = menu->next; 635 menu = menu->next;
636 else while ((menu = menu->parent)) { 636 else while ((menu = menu->parent)) {
637 if (menu->prompt && menu->prompt->type == P_MENU) 637 if (menu->prompt && menu->prompt->type == P_MENU)
638 fputs("\nendmenu\n", out); 638 fputs("\nendmenu\n", out);
639 if (menu->next) { 639 if (menu->next) {
640 menu = menu->next; 640 menu = menu->next;
641 break; 641 break;
642 } 642 }
643 } 643 }
644 } 644 }
645} 645}
646 646
647#include "lex.zconf.c" 647#include "lex.zconf.c"
648#include "confdata.c" 648#include "confdata.c"
649#include "expr.c" 649#include "expr.c"
650#include "symbol.c" 650#include "symbol.c"
651#include "menu.c" 651#include "menu.c"