aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-06 13:51:04 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-06 13:51:04 +0000
commit4fa499a17b52b299abc3a6ddd289bb6ca74bb84b (patch)
tree17df4dd427d85319857d9b7882585b3db9ad6994
parentc12f53090bd41dbb87279083bc442769cb0610f0 (diff)
downloadbusybox-w32-4fa499a17b52b299abc3a6ddd289bb6ca74bb84b.tar.gz
busybox-w32-4fa499a17b52b299abc3a6ddd289bb6ca74bb84b.tar.bz2
busybox-w32-4fa499a17b52b299abc3a6ddd289bb6ca74bb84b.zip
build system: remove loeftover (two empty dirs)
-rw-r--r--scripts/config/Kconfig-language.txt255
-rw-r--r--scripts/config/Makefile122
-rw-r--r--scripts/config/conf.c584
-rw-r--r--scripts/config/confdata.c485
-rw-r--r--scripts/config/expr.c1100
-rw-r--r--scripts/config/expr.h196
-rw-r--r--scripts/config/lex.zconf.c_shipped3688
-rw-r--r--scripts/config/lkc.h124
-rw-r--r--scripts/config/lkc_proto.h41
-rw-r--r--scripts/config/lxdialog/BIG.FAT.WARNING4
-rw-r--r--scripts/config/lxdialog/checklist.c373
-rw-r--r--scripts/config/lxdialog/colors.h162
-rw-r--r--scripts/config/lxdialog/dialog.h200
-rw-r--r--scripts/config/lxdialog/inputbox.c241
-rw-r--r--scripts/config/lxdialog/menubox.c439
-rw-r--r--scripts/config/lxdialog/msgbox.c86
-rw-r--r--scripts/config/lxdialog/textbox.c557
-rw-r--r--scripts/config/lxdialog/util.c376
-rw-r--r--scripts/config/lxdialog/yesno.c119
-rw-r--r--scripts/config/mconf.c976
-rw-r--r--scripts/config/menu.c391
-rwxr-xr-xscripts/config/mkconfigs51
-rw-r--r--scripts/config/symbol.c810
-rw-r--r--scripts/config/util.c110
-rw-r--r--scripts/config/zconf.l366
-rw-r--r--scripts/config/zconf.tab.c_shipped2130
-rw-r--r--scripts/config/zconf.tab.h_shipped125
-rw-r--r--scripts/config/zconf.y690
28 files changed, 0 insertions, 14801 deletions
diff --git a/scripts/config/Kconfig-language.txt b/scripts/config/Kconfig-language.txt
deleted file mode 100644
index 9b90bc392..000000000
--- a/scripts/config/Kconfig-language.txt
+++ /dev/null
@@ -1,255 +0,0 @@
1Introduction
2------------
3
4The configuration database is collection of configuration options
5organized in a tree structure:
6
7 +- Code maturity level options
8 | +- Prompt for development and/or incomplete code/drivers
9 +- General setup
10 | +- Networking support
11 | +- System V IPC
12 | +- BSD Process Accounting
13 | +- Sysctl support
14 +- Loadable module support
15 | +- Enable loadable module support
16 | +- Set version information on all module symbols
17 | +- Kernel module loader
18 +- ...
19
20Every entry has its own dependencies. These dependencies are used
21to determine the visible of an entry. Any child entry is only
22visible if its parent entry is also visible.
23
24Menu entries
25------------
26
27Most entries define a config option, all other entries help to organize
28them. A single configuration option is defined like this:
29
30config MODVERSIONS
31 bool "Set version information on all module symbols"
32 depends MODULES
33 help
34 Usually, modules have to be recompiled whenever you switch to a new
35 kernel. ...
36
37Every line starts with a key word and can be followed by multiple
38arguments. "config" starts a new config entry. The following lines
39define attributes for this config option. Attributes can be the type of
40the config option, input prompt, dependencies, help text and default
41values. A config option can be defined multiple times with the same
42name, but every definition can have only a single input prompt and the
43type must not conflict.
44
45Menu attributes
46---------------
47
48A menu entry can have a number of attributes. Not all of them are
49applicable everywhere (see syntax).
50
51- type definition: "bool"/"tristate"/"string"/"hex"/"integer"
52 Every config option must have a type. There are only two basic types:
53 tristate and string, the other types base on these two. The type
54 definition optionally accepts an input prompt, so these two examples
55 are equivalent:
56
57 bool "Networking support"
58 and
59 bool
60 prompt "Networking support"
61
62- input prompt: "prompt" <prompt> ["if" <expr>]
63 Every menu entry can have at most one prompt, which is used to display
64 to the user. Optionally dependencies only for this prompt can be added
65 with "if".
66
67- default value: "default" <symbol> ["if" <expr>]
68 A config option can have any number of default values. If multiple
69 default values are visible, only the first defined one is active.
70 Default values are not limited to the menu entry, where they are
71 defined, this means the default can be defined somewhere else or be
72 overridden by an earlier definition.
73 The default value is only assigned to the config symbol if no other
74 value was set by the user (via the input prompt above). If an input
75 prompt is visible the default value is presented to the user and can
76 be overridden by him.
77 Optionally dependencies only for this default value can be added with
78 "if".
79
80- dependencies: "depends on"/"requires" <expr>
81 This defines a dependency for this menu entry. If multiple
82 dependencies are defined they are connected with '&&'. Dependencies
83 are applied to all other options within this menu entry (which also
84 accept "if" expression), so these two examples are equivalent:
85
86 bool "foo" if BAR
87 default y if BAR
88 and
89 depends on BAR
90 bool "foo"
91 default y
92
93- help text: "help"
94 This defines a help text. The end of the help text is determined by
95 the level indentation, this means it ends at the first line which has
96 a smaller indentation than the first line of the help text.
97
98
99Menu dependencies
100-----------------
101
102Dependencies define the visibility of a menu entry and can also reduce
103the input range of tristate symbols. The tristate logic used in the
104expressions uses one more state than normal boolean logic to express the
105module state. Dependency expressions have the following syntax:
106
107<expr> ::= <symbol> (1)
108 <symbol> '=' <symbol> (2)
109 <symbol> '!=' <symbol> (3)
110 '(' <expr> ')' (4)
111 '!' <expr> (5)
112 <expr> '||' <expr> (6)
113 <expr> '&&' <expr> (7)
114
115Expressions are listed in decreasing order of precedence.
116
117(1) Convert the symbol into an expression. Boolean and tristate symbols
118 are simply converted into the respective expression values. All
119 other symbol types result in 'n'.
120(2) If the values of both symbols are equal, it returns 'y',
121 otherwise 'n'.
122(3) If the values of both symbols are equal, it returns 'n',
123 otherwise 'y'.
124(4) Returns the value of the expression. Used to override precedence.
125(5) Returns the result of (2-/expr/).
126(6) Returns the result of min(/expr/, /expr/).
127(7) Returns the result of max(/expr/, /expr/).
128
129An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2
130respectively for calculations). A menu entry becomes visible when it's
131expression evaluates to 'm' or 'y'.
132
133There are two type of symbols: constant and nonconstant symbols.
134Nonconstant symbols are the most common ones and are defined with the
135'config' statement. Nonconstant symbols consist entirely of alphanumeric
136characters or underscores.
137Constant symbols are only part of expressions. Constant symbols are
138always surrounded by single or double quotes. Within the quote any
139other character is allowed and the quotes can be escaped using '\'.
140
141Menu structure
142--------------
143
144The position of a menu entry in the tree is determined in two ways. First
145it can be specified explicitely:
146
147menu "Network device support"
148 depends NET
149
150config NETDEVICES
151 ...
152
153endmenu
154
155All entries within the "menu" ... "endmenu" block become a submenu of
156"Network device support". All subentries inherit the dependencies from
157the menu entry, e.g. this means the dependency "NET" is added to the
158dependency list of the config option NETDEVICES.
159
160The other way to generate the menu structure is done by analyzing the
161dependencies. If a menu entry somehow depends on the previous entry, it
162can be made a submenu of it. First the the previous (parent) symbol must
163be part of the dependency list and then one of these two condititions
164must be true:
165- the child entry must become invisible, if the parent is set to 'n'
166- the child entry must only be visible, if the parent is visible
167
168config MODULES
169 bool "Enable loadable module support"
170
171config MODVERSIONS
172 bool "Set version information on all module symbols"
173 depends MODULES
174
175comment "module support disabled"
176 depends !MODULES
177
178MODVERSIONS directly depends on MODULES, this means it's only visible if
179MODULES is different from 'n'. The comment on the other hand is always
180visible when MODULES it's visible (the (empty) dependency of MODULES is
181also part of the comment dependencies).
182
183
184Kconfig syntax
185--------------
186
187The configuration file describes a series of menu entries, where every
188line starts with a keyword (except help texts). The following keywords
189end a menu entry:
190- config
191- choice/endchoice
192- comment
193- menu/endmenu
194- if/endif
195- source
196The first four also start the definition of a menu entry.
197
198config:
199
200 "config" <symbol>
201 <config options>
202
203This defines a config symbol <symbol> and accepts any of above
204attributes as options.
205
206choices:
207
208 "choice"
209 <choice options>
210 <choice block>
211 "endchoice"
212
213This defines a choice group and accepts any of above attributes as
214options. A choice can only be of type bool or tristate, while a boolean
215choice only allows a single config entry to be selected, a tristate
216choice also allows any number of config entries to be set to 'm'. This
217can be used if multiple drivers for a single hardware exists and only a
218single driver can be compiled/loaded into the kernel, but all drivers
219can be compiled as modules.
220A choice accepts another option "optional", which allows to set the
221choice to 'n' and no entry needs to be selected.
222
223comment:
224
225 "comment" <prompt>
226 <comment options>
227
228This defines a comment which is displayed to the user during the
229configuration process and is also echoed to the output files. The only
230possible options are dependencies.
231
232menu:
233
234 "menu" <prompt>
235 <menu options>
236 <menu block>
237 "endmenu"
238
239This defines a menu block, see "Menu structure" above for more
240information. The only possible options are dependencies.
241
242if:
243
244 "if" <expr>
245 <if block>
246 "endif"
247
248This defines an if block. The dependency expression <expr> is appended
249to all enclosed menu entries.
250
251source:
252
253 "source" <prompt>
254
255This reads the specified configuration file. This file is always parsed.
diff --git a/scripts/config/Makefile b/scripts/config/Makefile
deleted file mode 100644
index 4c966f7a6..000000000
--- a/scripts/config/Makefile
+++ /dev/null
@@ -1,122 +0,0 @@
1# Makefile for BusyBox
2#
3# Copyright (C) 2002 Erik Andersen <andersen@codepoet.org>
4
5top_srcdir=../..
6top_builddir=../..
7srcdir=$(top_srcdir)/scripts/config
8include $(top_srcdir)/Rules.mak
9
10all: ncurses conf mconf
11
12ifeq ($(shell uname),SunOS)
13LIBS = -lcurses
14else
15LIBS = -lncurses
16endif
17ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))
18 HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"
19else
20ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h))
21 HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
22else
23ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h))
24 HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses.h>"
25else
26ifeq (/usr/local/include/ncurses/curses.h, $(wildcard /usr/local/include/ncurses/curses.h))
27 HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
28else
29ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h))
30 HOSTNCURSES += -DCURSES_LOC="<ncurses.h>"
31else
32 HOSTNCURSES += -DCURSES_LOC="<curses.h>"
33endif
34endif
35endif
36endif
37endif
38
39CONF_SRC = conf.c
40MCONF_SRC = mconf.c
41LXD_SRC = lxdialog/checklist.c lxdialog/menubox.c lxdialog/textbox.c \
42 lxdialog/yesno.c lxdialog/inputbox.c lxdialog/util.c \
43 lxdialog/msgbox.c
44
45SHARED_SRC = zconf.tab.c
46SHARED_DEPS := $(srcdir)/lkc.h $(srcdir)/lkc_proto.h \
47 lkc_defs.h $(srcdir)/expr.h zconf.tab.h
48CONF_OBJS = $(patsubst %.c,%.o, $(CONF_SRC))
49MCONF_OBJS = $(patsubst %.c,%.o, $(MCONF_SRC) $(LXD_SRC))
50SHARED_OBJS = $(patsubst %.c,%.o, $(SHARED_SRC))
51
52conf: $(CONF_OBJS) $(SHARED_OBJS)
53 $(SECHO) " "HOSTCC $@ ; true
54 $(Q)$(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@
55
56mconf: $(MCONF_OBJS) $(SHARED_OBJS)
57 $(SECHO) " "HOSTCC $@ ; true
58 $(Q)$(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ $(LIBS)
59
60$(CONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS)
61 $(compile.h) -I.
62
63$(MCONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS)
64 @[ -d $(@D) ] || mkdir $(@D)
65 $(compile.h) $(HOSTNCURSES) -I.
66
67lkc_defs.h: $(srcdir)/lkc_proto.h
68 @$(SED) < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
69
70###
71# The following requires flex/bison
72# By default we use the _shipped versions, uncomment the
73# following line if you are modifying the flex/bison src.
74#LKC_GENPARSER := 1
75
76ifdef LKC_GENPARSER
77
78%.tab.c %.tab.h: $(srcdir)/%.y
79 bison -t -d -v -b $* -p $(notdir $*) $<
80
81lex.%.c: $(srcdir)/%.l
82 flex -P$(notdir $*) -o$@ $<
83else
84
85lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
86 $(compile.h) -I$(srcdir)
87
88lex.zconf.c: $(srcdir)/lex.zconf.c_shipped
89 $(Q)cp $< $@
90
91zconf.tab.c: $(srcdir)/zconf.tab.c_shipped
92 $(Q)cp $< $@
93
94zconf.tab.h: $(srcdir)/zconf.tab.h_shipped
95 $(Q)cp $< $@
96endif
97
98zconf.tab.o: zconf.tab.c lex.zconf.c $(srcdir)/confdata.c $(srcdir)/expr.c \
99 $(srcdir)/symbol.c $(srcdir)/menu.c $(SHARED_DEPS)
100 $(compile.h) -I$(srcdir) -I.
101
102.PHONY: ncurses
103
104ncurses:
105 @echo "main() {}" > lxtemp.c
106 @if $(HOSTCC) lxtemp.c $(LIBS) ; then \
107 rm -f lxtemp.c a.out; \
108 else \
109 rm -f lxtemp.c; \
110 echo -e "\007" ;\
111 echo ">> Unable to find the Ncurses libraries." ;\
112 echo ">>" ;\
113 echo ">> You must have Ncurses installed in order" ;\
114 echo ">> to use 'make menuconfig'" ;\
115 echo ;\
116 exit 1 ;\
117 fi
118
119clean:
120 rm -f *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) \
121 conf mconf zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h
122
diff --git a/scripts/config/conf.c b/scripts/config/conf.c
deleted file mode 100644
index 2da5ff7a7..000000000
--- a/scripts/config/conf.c
+++ /dev/null
@@ -1,584 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0.
5 */
6
7#include <ctype.h>
8#include <stdlib.h>
9#include <string.h>
10#include <unistd.h>
11#include <time.h>
12#include <sys/stat.h>
13
14#define LKC_DIRECT_LINK
15#include "lkc.h"
16
17static void conf(struct menu *menu);
18static void check_conf(struct menu *menu);
19
20enum {
21 ask_all,
22 ask_new,
23 ask_silent,
24 set_default,
25 set_yes,
26 set_mod,
27 set_no,
28 set_random
29} input_mode = ask_all;
30char *defconfig_file;
31
32static int indent = 1;
33static int valid_stdin = 1;
34static int conf_cnt;
35static char line[128];
36static struct menu *rootEntry;
37
38static char nohelp_text[] = "Sorry, no help available for this option yet.\n";
39
40static void strip(char *str)
41{
42 char *p = str;
43 int l;
44
45 while ((isspace(*p)))
46 p++;
47 l = strlen(p);
48 if (p != str)
49 memmove(str, p, l + 1);
50 if (!l)
51 return;
52 p = str + l - 1;
53 while ((isspace(*p)))
54 *p-- = 0;
55}
56
57static void check_stdin(void)
58{
59 if (!valid_stdin && input_mode == ask_silent) {
60 printf("aborted!\n\n");
61 printf("Console input/output is redirected. ");
62 printf("Run 'make oldconfig' to update configuration.\n\n");
63 exit(1);
64 }
65}
66
67static void conf_askvalue(struct symbol *sym, const char *def)
68{
69 enum symbol_type type = sym_get_type(sym);
70 tristate val;
71
72 if (!sym_has_value(sym))
73 printf("(NEW) ");
74
75 line[0] = '\n';
76 line[1] = 0;
77
78 if (!sym_is_changable(sym)) {
79 printf("%s\n", def);
80 line[0] = '\n';
81 line[1] = 0;
82 return;
83 }
84
85 switch (input_mode) {
86 case ask_new:
87 case ask_silent:
88 if (sym_has_value(sym)) {
89 printf("%s\n", def);
90 return;
91 }
92 check_stdin();
93 case ask_all:
94 fflush(stdout);
95 fgets(line, 128, stdin);
96 return;
97 case set_default:
98 printf("%s\n", def);
99 return;
100 default:
101 break;
102 }
103
104 switch (type) {
105 case S_INT:
106 case S_HEX:
107 case S_STRING:
108 printf("%s\n", def);
109 return;
110 default:
111 ;
112 }
113 switch (input_mode) {
114 case set_yes:
115 if (sym_tristate_within_range(sym, yes)) {
116 line[0] = 'y';
117 line[1] = '\n';
118 line[2] = 0;
119 break;
120 }
121 case set_mod:
122 if (type == S_TRISTATE) {
123 if (sym_tristate_within_range(sym, mod)) {
124 line[0] = 'm';
125 line[1] = '\n';
126 line[2] = 0;
127 break;
128 }
129 } else {
130 if (sym_tristate_within_range(sym, yes)) {
131 line[0] = 'y';
132 line[1] = '\n';
133 line[2] = 0;
134 break;
135 }
136 }
137 case set_no:
138 if (sym_tristate_within_range(sym, no)) {
139 line[0] = 'n';
140 line[1] = '\n';
141 line[2] = 0;
142 break;
143 }
144 case set_random:
145 do {
146 val = (tristate)(random() % 3);
147 } while (!sym_tristate_within_range(sym, val));
148 switch (val) {
149 case no: line[0] = 'n'; break;
150 case mod: line[0] = 'm'; break;
151 case yes: line[0] = 'y'; break;
152 }
153 line[1] = '\n';
154 line[2] = 0;
155 break;
156 default:
157 break;
158 }
159 printf("%s", line);
160}
161
162int conf_string(struct menu *menu)
163{
164 struct symbol *sym = menu->sym;
165 const char *def, *help;
166
167 while (1) {
168 printf("%*s%s ", indent - 1, "", menu->prompt->text);
169 printf("(%s) ", sym->name);
170 def = sym_get_string_value(sym);
171 if (sym_get_string_value(sym))
172 printf("[%s] ", def);
173 conf_askvalue(sym, def);
174 switch (line[0]) {
175 case '\n':
176 break;
177 case '?':
178 /* print help */
179 if (line[1] == '\n') {
180 help = nohelp_text;
181 if (menu->sym->help)
182 help = menu->sym->help;
183 printf("\n%s\n", menu->sym->help);
184 def = NULL;
185 break;
186 }
187 default:
188 line[strlen(line)-1] = 0;
189 def = line;
190 }
191 if (def && sym_set_string_value(sym, def))
192 return 0;
193 }
194}
195
196static int conf_sym(struct menu *menu)
197{
198 struct symbol *sym = menu->sym;
199 int type;
200 tristate oldval, newval;
201 const char *help;
202
203 while (1) {
204 printf("%*s%s ", indent - 1, "", menu->prompt->text);
205 if (sym->name)
206 printf("(%s) ", sym->name);
207 type = sym_get_type(sym);
208 putchar('[');
209 oldval = sym_get_tristate_value(sym);
210 switch (oldval) {
211 case no:
212 putchar('N');
213 break;
214 case mod:
215 putchar('M');
216 break;
217 case yes:
218 putchar('Y');
219 break;
220 }
221 if (oldval != no && sym_tristate_within_range(sym, no))
222 printf("/n");
223 if (oldval != mod && sym_tristate_within_range(sym, mod))
224 printf("/m");
225 if (oldval != yes && sym_tristate_within_range(sym, yes))
226 printf("/y");
227 if (sym->help)
228 printf("/?");
229 printf("] ");
230 conf_askvalue(sym, sym_get_string_value(sym));
231 strip(line);
232
233 switch (line[0]) {
234 case 'n':
235 case 'N':
236 newval = no;
237 if (!line[1] || !strcmp(&line[1], "o"))
238 break;
239 continue;
240 case 'm':
241 case 'M':
242 newval = mod;
243 if (!line[1])
244 break;
245 continue;
246 case 'y':
247 case 'Y':
248 newval = yes;
249 if (!line[1] || !strcmp(&line[1], "es"))
250 break;
251 continue;
252 case 0:
253 newval = oldval;
254 break;
255 case '?':
256 goto help;
257 default:
258 continue;
259 }
260 if (sym_set_tristate_value(sym, newval))
261 return 0;
262help:
263 help = nohelp_text;
264 if (sym->help)
265 help = sym->help;
266 printf("\n%s\n", help);
267 }
268}
269
270static int conf_choice(struct menu *menu)
271{
272 struct symbol *sym, *def_sym;
273 struct menu *child;
274 int type;
275 bool is_new;
276
277 sym = menu->sym;
278 type = sym_get_type(sym);
279 is_new = !sym_has_value(sym);
280 if (sym_is_changable(sym)) {
281 conf_sym(menu);
282 sym_calc_value(sym);
283 switch (sym_get_tristate_value(sym)) {
284 case no:
285 return 1;
286 case mod:
287 return 0;
288 case yes:
289 break;
290 }
291 } else {
292 switch (sym_get_tristate_value(sym)) {
293 case no:
294 return 1;
295 case mod:
296 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
297 return 0;
298 case yes:
299 break;
300 }
301 }
302
303 while (1) {
304 int cnt, def;
305
306 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
307 def_sym = sym_get_choice_value(sym);
308 cnt = def = 0;
309 line[0] = '0';
310 line[1] = 0;
311 for (child = menu->list; child; child = child->next) {
312 if (!menu_is_visible(child))
313 continue;
314 if (!child->sym) {
315 printf("%*c %s\n", indent, '*', menu_get_prompt(child));
316 continue;
317 }
318 cnt++;
319 if (child->sym == def_sym) {
320 def = cnt;
321 printf("%*c", indent, '>');
322 } else
323 printf("%*c", indent, ' ');
324 printf(" %d. %s", cnt, menu_get_prompt(child));
325 if (child->sym->name)
326 printf(" (%s)", child->sym->name);
327 if (!sym_has_value(child->sym))
328 printf(" (NEW)");
329 printf("\n");
330 }
331 printf("%*schoice", indent - 1, "");
332 if (cnt == 1) {
333 printf("[1]: 1\n");
334 goto conf_childs;
335 }
336 printf("[1-%d", cnt);
337 if (sym->help)
338 printf("?");
339 printf("]: ");
340 switch (input_mode) {
341 case ask_new:
342 case ask_silent:
343 if (!is_new) {
344 cnt = def;
345 printf("%d\n", cnt);
346 break;
347 }
348 check_stdin();
349 case ask_all:
350 fflush(stdout);
351 fgets(line, 128, stdin);
352 strip(line);
353 if (line[0] == '?') {
354 printf("\n%s\n", menu->sym->help ?
355 menu->sym->help : nohelp_text);
356 continue;
357 }
358 if (!line[0])
359 cnt = def;
360 else if (isdigit(line[0]))
361 cnt = atoi(line);
362 else
363 continue;
364 break;
365 case set_random:
366 def = (random() % cnt) + 1;
367 case set_default:
368 case set_yes:
369 case set_mod:
370 case set_no:
371 cnt = def;
372 printf("%d\n", cnt);
373 break;
374 }
375
376 conf_childs:
377 for (child = menu->list; child; child = child->next) {
378 if (!child->sym || !menu_is_visible(child))
379 continue;
380 if (!--cnt)
381 break;
382 }
383 if (!child)
384 continue;
385 if (line[strlen(line) - 1] == '?') {
386 printf("\n%s\n", child->sym->help ?
387 child->sym->help : nohelp_text);
388 continue;
389 }
390 sym_set_choice_value(sym, child->sym);
391 if (child->list) {
392 indent += 2;
393 conf(child->list);
394 indent -= 2;
395 }
396 return 1;
397 }
398}
399
400static void conf(struct menu *menu)
401{
402 struct symbol *sym;
403 struct property *prop;
404 struct menu *child;
405
406 if (!menu_is_visible(menu))
407 return;
408
409 sym = menu->sym;
410 prop = menu->prompt;
411 if (prop) {
412 const char *prompt;
413
414 switch (prop->type) {
415 case P_MENU:
416 if (input_mode == ask_silent && rootEntry != menu) {
417 check_conf(menu);
418 return;
419 }
420 case P_COMMENT:
421 prompt = menu_get_prompt(menu);
422 if (prompt)
423 printf("%*c\n%*c %s\n%*c\n",
424 indent, '*',
425 indent, '*', prompt,
426 indent, '*');
427 default:
428 ;
429 }
430 }
431
432 if (!sym)
433 goto conf_childs;
434
435 if (sym_is_choice(sym)) {
436 conf_choice(menu);
437 if (sym->curr.tri != mod)
438 return;
439 goto conf_childs;
440 }
441
442 switch (sym->type) {
443 case S_INT:
444 case S_HEX:
445 case S_STRING:
446 conf_string(menu);
447 break;
448 default:
449 conf_sym(menu);
450 break;
451 }
452
453conf_childs:
454 if (sym)
455 indent += 2;
456 for (child = menu->list; child; child = child->next)
457 conf(child);
458 if (sym)
459 indent -= 2;
460}
461
462static void check_conf(struct menu *menu)
463{
464 struct symbol *sym;
465 struct menu *child;
466
467 if (!menu_is_visible(menu))
468 return;
469
470 sym = menu->sym;
471 if (sym) {
472 if (sym_is_changable(sym) && !sym_has_value(sym)) {
473 if (!conf_cnt++)
474 printf("*\n* Restart config...\n*\n");
475 rootEntry = menu_get_parent_menu(menu);
476 conf(rootEntry);
477 }
478 if (sym_is_choice(sym) && sym_get_tristate_value(sym) != mod)
479 return;
480 }
481
482 for (child = menu->list; child; child = child->next)
483 check_conf(child);
484}
485
486int main(int ac, char **av)
487{
488 int i = 1;
489 const char *name;
490 struct stat tmpstat;
491
492 if (ac > i && av[i][0] == '-') {
493 switch (av[i++][1]) {
494 case 'o':
495 input_mode = ask_new;
496 break;
497 case 's':
498 input_mode = ask_silent;
499 valid_stdin = isatty(0) && isatty(1) && isatty(2);
500 break;
501 case 'd':
502 input_mode = set_default;
503 break;
504 case 'D':
505 input_mode = set_default;
506 defconfig_file = av[i++];
507 if (!defconfig_file) {
508 printf("%s: No default config file specified\n",
509 av[0]);
510 exit(1);
511 }
512 break;
513 case 'n':
514 input_mode = set_no;
515 break;
516 case 'm':
517 input_mode = set_mod;
518 break;
519 case 'y':
520 input_mode = set_yes;
521 break;
522 case 'r':
523 input_mode = set_random;
524 srandom(time(NULL));
525 break;
526 case 'h':
527 case '?':
528 printf("%s [-o|-s] config\n", av[0]);
529 exit(0);
530 }
531 }
532 name = av[i];
533 if (!name) {
534 printf("%s: configuration file missing\n", av[0]);
535 }
536 conf_parse(name);
537 //zconfdump(stdout);
538 switch (input_mode) {
539 case set_default:
540 if (!defconfig_file)
541 defconfig_file = conf_get_default_confname();
542 if (conf_read(defconfig_file)) {
543 printf("***\n"
544 "*** Can't find default configuration \"%s\"!\n"
545 "***\n", defconfig_file);
546 exit(1);
547 }
548 break;
549 case ask_silent:
550 if (stat(".config", &tmpstat)) {
551 printf("***\n"
552 "*** You have not yet configured BusyBox!\n"
553 "***\n"
554 "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
555 "*** \"make menuconfig\" or \"make config\").\n"
556 "***\n");
557 exit(1);
558 }
559 case ask_all:
560 case ask_new:
561 conf_read(NULL);
562 break;
563 default:
564 break;
565 }
566
567 if (input_mode != ask_silent) {
568 rootEntry = &rootmenu;
569 conf(&rootmenu);
570 if (input_mode == ask_all) {
571 input_mode = ask_silent;
572 valid_stdin = 1;
573 }
574 }
575 do {
576 conf_cnt = 0;
577 check_conf(&rootmenu);
578 } while (conf_cnt);
579 if (conf_write(NULL)) {
580 fprintf(stderr, "\n*** Error during writing of the BusyBox configuration.\n\n");
581 return 1;
582 }
583 return 0;
584}
diff --git a/scripts/config/confdata.c b/scripts/config/confdata.c
deleted file mode 100644
index db3fdcd56..000000000
--- a/scripts/config/confdata.c
+++ /dev/null
@@ -1,485 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0.
5 */
6
7#include <sys/stat.h>
8#include <ctype.h>
9#include <stdio.h>
10#include <stdlib.h>
11#include <string.h>
12#include <unistd.h>
13
14#define LKC_DIRECT_LINK
15#include "lkc.h"
16
17const char conf_def_filename[] = ".config";
18
19const char conf_defname[] = "defconfig";
20
21const char *conf_confnames[] = {
22 ".config",
23 conf_defname,
24 NULL,
25};
26
27static char *conf_expand_value(const char *in)
28{
29 struct symbol *sym;
30 const char *src;
31 static char res_value[SYMBOL_MAXLENGTH];
32 char *dst, name[SYMBOL_MAXLENGTH];
33
34 res_value[0] = 0;
35 dst = name;
36 while ((src = strchr(in, '$'))) {
37 strncat(res_value, in, src - in);
38 src++;
39 dst = name;
40 while (isalnum(*src) || *src == '_')
41 *dst++ = *src++;
42 *dst = 0;
43 sym = sym_lookup(name, 0);
44 sym_calc_value(sym);
45 strcat(res_value, sym_get_string_value(sym));
46 in = src;
47 }
48 strcat(res_value, in);
49
50 return res_value;
51}
52
53char *conf_get_default_confname(void)
54{
55 struct stat buf;
56 static char fullname[PATH_MAX+1];
57 char *env, *name;
58
59 name = conf_expand_value(conf_defname);
60 env = getenv(SRCTREE);
61 if (env) {
62 sprintf(fullname, "%s/%s", env, name);
63 if (!stat(fullname, &buf))
64 return fullname;
65 }
66 return name;
67}
68
69int conf_read(const char *name)
70{
71 FILE *in = NULL;
72 char line[1024];
73 char *p, *p2;
74 int lineno = 0;
75 struct symbol *sym;
76 struct property *prop;
77 struct expr *e;
78 int i;
79
80 if (name) {
81 in = zconf_fopen(name);
82 } else {
83 const char **names = conf_confnames;
84 while ((name = *names++)) {
85 name = conf_expand_value(name);
86 in = zconf_fopen(name);
87 if (in) {
88 printf("#\n"
89 "# using defaults found in %s\n"
90 "#\n", name);
91 break;
92 }
93 }
94 }
95
96 if (!in)
97 return 1;
98
99 for_all_symbols(i, sym) {
100 sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED;
101 sym->flags &= ~SYMBOL_VALID;
102 switch (sym->type) {
103 case S_INT:
104 case S_HEX:
105 case S_STRING:
106 free(sym->user.val);
107 default:
108 sym->user.val = NULL;
109 sym->user.tri = no;
110 }
111 }
112
113 while (fgets(line, sizeof(line), in)) {
114 lineno++;
115 sym = NULL;
116 switch (line[0]) {
117 case '#':
118 if (line[1]!=' ')
119 continue;
120 p = strchr(line + 2, ' ');
121 if (!p)
122 continue;
123 *p++ = 0;
124 if (strncmp(p, "is not set", 10))
125 continue;
126 sym = sym_find(line + 2);
127 if (!sym) {
128 fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 2);
129 break;
130 }
131 switch (sym->type) {
132 case S_BOOLEAN:
133 case S_TRISTATE:
134 sym->user.tri = no;
135 sym->flags &= ~SYMBOL_NEW;
136 break;
137 default:
138 ;
139 }
140 break;
141
142 case 'A' ... 'Z':
143 p = strchr(line, '=');
144 if (!p)
145 continue;
146 *p++ = 0;
147 p2 = strchr(p, '\n');
148 if (p2)
149 *p2 = 0;
150 sym = sym_find(line);
151 if (!sym) {
152 fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line);
153 break;
154 }
155 switch (sym->type) {
156 case S_TRISTATE:
157 if (p[0] == 'm') {
158 sym->user.tri = mod;
159 sym->flags &= ~SYMBOL_NEW;
160 break;
161 }
162 case S_BOOLEAN:
163 if (p[0] == 'y') {
164 sym->user.tri = yes;
165 sym->flags &= ~SYMBOL_NEW;
166 break;
167 }
168 if (p[0] == 'n') {
169 sym->user.tri = no;
170 sym->flags &= ~SYMBOL_NEW;
171 break;
172 }
173 break;
174 case S_STRING:
175 if (*p++ != '"')
176 break;
177 for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) {
178 if (*p2 == '"') {
179 *p2 = 0;
180 break;
181 }
182 memmove(p2, p2 + 1, strlen(p2));
183 }
184 if (!p2) {
185 fprintf(stderr, "%s:%d: invalid string found\n", name, lineno);
186 exit(1);
187 }
188 case S_INT:
189 case S_HEX:
190 if (sym_string_valid(sym, p)) {
191 sym->user.val = strdup(p);
192 sym->flags &= ~SYMBOL_NEW;
193 } else {
194 fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name);
195 exit(1);
196 }
197 break;
198 default:
199 ;
200 }
201 break;
202 case '\n':
203 break;
204 default:
205 continue;
206 }
207 if (sym && sym_is_choice_value(sym)) {
208 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
209 switch (sym->user.tri) {
210 case no:
211 break;
212 case mod:
213 if (cs->user.tri == yes)
214 /* warn? */;
215 break;
216 case yes:
217 if (cs->user.tri != no)
218 /* warn? */;
219 cs->user.val = sym;
220 break;
221 }
222 cs->user.tri = E_OR(cs->user.tri, sym->user.tri);
223 cs->flags &= ~SYMBOL_NEW;
224 }
225 }
226 fclose(in);
227
228 if (modules_sym)
229 sym_calc_value(modules_sym);
230 for_all_symbols(i, sym) {
231 sym_calc_value(sym);
232 if (sym_has_value(sym) && !sym_is_choice_value(sym)) {
233 if (sym->visible == no)
234 sym->flags |= SYMBOL_NEW;
235 switch (sym->type) {
236 case S_STRING:
237 case S_INT:
238 case S_HEX:
239 if (!sym_string_within_range(sym, sym->user.val))
240 sym->flags |= SYMBOL_NEW;
241 default:
242 break;
243 }
244 }
245 if (!sym_is_choice(sym))
246 continue;
247 prop = sym_get_choice_prop(sym);
248 for (e = prop->expr; e; e = e->left.expr)
249 if (e->right.sym->visible != no)
250 sym->flags |= e->right.sym->flags & SYMBOL_NEW;
251 }
252
253 sym_change_count = 1;
254
255 return 0;
256}
257
258struct menu *next_menu(struct menu *menu)
259{
260 if (menu->list) return menu->list;
261 do {
262 if (menu->next) {
263 menu = menu->next;
264 break;
265 }
266 } while ((menu = menu->parent));
267
268 return menu;
269}
270
271#define SYMBOL_FORCEWRITE (1<<31)
272
273int conf_write(const char *name)
274{
275 FILE *out, *out_h;
276 struct symbol *sym;
277 struct menu *menu;
278 const char *basename;
279 char dirname[128], tmpname[128], newname[128];
280 int type, l;
281 const char *str;
282
283 /* busybox`s code */
284 const char *opt_name;
285 int use_flg;
286
287 dirname[0] = 0;
288 if (name && name[0]) {
289 struct stat st;
290 char *slash;
291
292 if (!stat(name, &st) && S_ISDIR(st.st_mode)) {
293 strcpy(dirname, name);
294 strcat(dirname, "/");
295 basename = conf_def_filename;
296 } else if ((slash = strrchr(name, '/'))) {
297 int size = slash - name + 1;
298 memcpy(dirname, name, size);
299 dirname[size] = 0;
300 if (slash[1])
301 basename = slash + 1;
302 else
303 basename = conf_def_filename;
304 } else
305 basename = name;
306 } else
307 basename = conf_def_filename;
308
309 sprintf(newname, "%s.tmpconfig.%d", dirname, (int)getpid());
310 out = fopen(newname, "w");
311 if (!out)
312 return 1;
313 out_h = NULL;
314 if (!name) {
315 out_h = fopen(".tmpconfig.h", "w");
316 if (!out_h)
317 return 1;
318 }
319 fprintf(out, "#\n"
320 "# Automatically generated make config: don't edit\n"
321 "#\n");
322
323 /* busybox`s code */
324 if (out_h) {
325 fprintf(out_h, "#ifndef BB_CONFIG_H\n#define BB_CONFIG_H\n");
326 fprintf(out_h, "/*\n"
327 " * Automatically generated header file: don't edit\n"
328 " */\n\n"
329 "/* Version Number */\n"
330 "#define BB_VER \"%s\"\n"
331 "#define BB_BT \"%s\"\n",
332 getenv("VERSION"),
333 getenv("BUILDTIME"));
334 if (getenv("EXTRA_VERSION"))
335 fprintf(out_h, "#define BB_EXTRA_VERSION \"%s\"\n",
336 getenv("EXTRA_VERSION"));
337 fprintf(out_h, "\n");
338 }
339 /* end busybox`s code */
340
341 if (!sym_change_count)
342 sym_clear_all_valid();
343
344 /* Force write of all non-duplicate symbols. */
345
346 /* Write out everything by default. */
347 for(menu = rootmenu.list; menu; menu = next_menu(menu))
348 if (menu->sym) menu->sym->flags |= SYMBOL_FORCEWRITE;
349
350 menu = rootmenu.list;
351 while (menu) {
352 sym = menu->sym;
353 if (!sym) {
354 if (!menu_is_visible(menu))
355 goto next;
356 str = menu_get_prompt(menu);
357 fprintf(out, "\n"
358 "#\n"
359 "# %s\n"
360 "#\n", str);
361 if (out_h)
362 fprintf(out_h, "\n"
363 "/*\n"
364 " * %s\n"
365 " */\n", str);
366 } else if (!(sym->flags & SYMBOL_CHOICE)) {
367 sym_calc_value(sym);
368 if (!(sym->flags & SYMBOL_FORCEWRITE))
369 goto next;
370
371 sym->flags &= ~SYMBOL_FORCEWRITE;
372 type = sym->type;
373 if (type == S_TRISTATE) {
374 sym_calc_value(modules_sym);
375 if (modules_sym->curr.tri == no)
376 type = S_BOOLEAN;
377 }
378
379 /* busybox`s code */
380 opt_name = strchr(sym->name, '_');
381 if(opt_name == NULL)
382 opt_name = sym->name;
383 else
384 opt_name++;
385 use_flg = 1;
386 /* end busybox`s code */
387
388 switch (type) {
389 case S_BOOLEAN:
390 case S_TRISTATE:
391 switch (sym_get_tristate_value(sym)) {
392 case no:
393 fprintf(out, "# %s is not set\n", sym->name);
394 if (out_h)
395 fprintf(out_h, "#undef %s\n", sym->name);
396 use_flg = 0; /* busybox`s code */
397 break;
398 case mod:
399#if 0 /* busybox`s code */
400 fprintf(out, "%s=m\n", sym->name);
401 if (out_h)
402 fprintf(out_h, "#define %s_MODULE 1\n", sym->name);
403#endif /* busybox`s code */
404 break;
405 case yes:
406 fprintf(out, "%s=y\n", sym->name);
407 if (out_h)
408 fprintf(out_h, "#define %s 1\n", sym->name);
409 break;
410 }
411 break;
412 case S_STRING:
413 // fix me
414 str = sym_get_string_value(sym);
415 fprintf(out, "%s=\"", sym->name);
416 if (out_h)
417 fprintf(out_h, "#define %s \"", sym->name);
418 do {
419 l = strcspn(str, "\"\\");
420 if (l) {
421 fwrite(str, l, 1, out);
422 if (out_h)
423 fwrite(str, l, 1, out_h);
424 }
425 str += l;
426 while (*str == '\\' || *str == '"') {
427 fprintf(out, "\\%c", *str);
428 if (out_h)
429 fprintf(out_h, "\\%c", *str);
430 str++;
431 }
432 } while (*str);
433 fputs("\"\n", out);
434 if (out_h)
435 fputs("\"\n", out_h);
436 break;
437 case S_HEX:
438 str = sym_get_string_value(sym);
439 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
440 fprintf(out, "%s=%s\n", sym->name, *str ? str : "0");
441 if (out_h)
442 fprintf(out_h, "#define %s 0x%s\n", sym->name, str);
443 break;
444 }
445 case S_INT:
446 str = sym_get_string_value(sym);
447 fprintf(out, "%s=%s\n", sym->name, *str ? str : "0");
448 if (out_h)
449 fprintf(out_h, "#define %s %s\n", sym->name, str);
450 break;
451 }
452 /* busybox`s code */
453 if (out_h) {
454 fprintf(out_h, "#define ENABLE_%s %d\n", opt_name, use_flg);
455 fprintf(out_h, "#define USE_%s(...)%s\n", opt_name,
456 (use_flg ? " __VA_ARGS__" : ""));
457 fprintf(out_h, "#define SKIP_%s(...)%s\n\n", opt_name,
458 (use_flg ? "" : " __VA_ARGS__"));
459 }
460 /* end busybox`s code */
461 }
462next:
463 menu = next_menu(menu);
464 }
465 fclose(out);
466 if (out_h) {
467 fprintf(out_h, "#endif /* BB_CONFIG_H */\n"); /* busybox`s code */
468 fclose(out_h);
469 rename(".tmpconfig.h", "include/bb_config.h"); /* busybox`s config name */
470 file_write_dep(NULL);
471 }
472 if (!name || basename != conf_def_filename) {
473 if (!name)
474 name = conf_def_filename;
475 sprintf(tmpname, "%s.old", name);
476 rename(name, tmpname);
477 }
478 sprintf(tmpname, "%s%s", dirname, basename);
479 if (rename(newname, tmpname))
480 return 1;
481
482 sym_change_count = 0;
483
484 return 0;
485}
diff --git a/scripts/config/expr.c b/scripts/config/expr.c
deleted file mode 100644
index 125573e77..000000000
--- a/scripts/config/expr.c
+++ /dev/null
@@ -1,1100 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0.
5 */
6
7#include <stdio.h>
8#include <stdlib.h>
9#include <string.h>
10
11#define LKC_DIRECT_LINK
12#include "lkc.h"
13
14#define DEBUG_EXPR 0
15
16struct expr *expr_alloc_symbol(struct symbol *sym)
17{
18 struct expr *e = malloc(sizeof(*e));
19 memset(e, 0, sizeof(*e));
20 e->type = E_SYMBOL;
21 e->left.sym = sym;
22 return e;
23}
24
25struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)
26{
27 struct expr *e = malloc(sizeof(*e));
28 memset(e, 0, sizeof(*e));
29 e->type = type;
30 e->left.expr = ce;
31 return e;
32}
33
34struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2)
35{
36 struct expr *e = malloc(sizeof(*e));
37 memset(e, 0, sizeof(*e));
38 e->type = type;
39 e->left.expr = e1;
40 e->right.expr = e2;
41 return e;
42}
43
44struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2)
45{
46 struct expr *e = malloc(sizeof(*e));
47 memset(e, 0, sizeof(*e));
48 e->type = type;
49 e->left.sym = s1;
50 e->right.sym = s2;
51 return e;
52}
53
54struct expr *expr_alloc_and(struct expr *e1, struct expr *e2)
55{
56 if (!e1)
57 return e2;
58 return e2 ? expr_alloc_two(E_AND, e1, e2) : e1;
59}
60
61struct expr *expr_alloc_or(struct expr *e1, struct expr *e2)
62{
63 if (!e1)
64 return e2;
65 return e2 ? expr_alloc_two(E_OR, e1, e2) : e1;
66}
67
68struct expr *expr_copy(struct expr *org)
69{
70 struct expr *e;
71
72 if (!org)
73 return NULL;
74
75 e = malloc(sizeof(*org));
76 memcpy(e, org, sizeof(*org));
77 switch (org->type) {
78 case E_SYMBOL:
79 e->left = org->left;
80 break;
81 case E_NOT:
82 e->left.expr = expr_copy(org->left.expr);
83 break;
84 case E_EQUAL:
85 case E_UNEQUAL:
86 e->left.sym = org->left.sym;
87 e->right.sym = org->right.sym;
88 break;
89 case E_AND:
90 case E_OR:
91 case E_CHOICE:
92 e->left.expr = expr_copy(org->left.expr);
93 e->right.expr = expr_copy(org->right.expr);
94 break;
95 default:
96 printf("can't copy type %d\n", e->type);
97 free(e);
98 e = NULL;
99 break;
100 }
101
102 return e;
103}
104
105void expr_free(struct expr *e)
106{
107 if (!e)
108 return;
109
110 switch (e->type) {
111 case E_SYMBOL:
112 break;
113 case E_NOT:
114 expr_free(e->left.expr);
115 return;
116 case E_EQUAL:
117 case E_UNEQUAL:
118 break;
119 case E_OR:
120 case E_AND:
121 expr_free(e->left.expr);
122 expr_free(e->right.expr);
123 break;
124 default:
125 printf("how to free type %d?\n", e->type);
126 break;
127 }
128 free(e);
129}
130
131static int trans_count;
132
133#define e1 (*ep1)
134#define e2 (*ep2)
135
136static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2)
137{
138 if (e1->type == type) {
139 __expr_eliminate_eq(type, &e1->left.expr, &e2);
140 __expr_eliminate_eq(type, &e1->right.expr, &e2);
141 return;
142 }
143 if (e2->type == type) {
144 __expr_eliminate_eq(type, &e1, &e2->left.expr);
145 __expr_eliminate_eq(type, &e1, &e2->right.expr);
146 return;
147 }
148 if (e1->type == E_SYMBOL && e2->type == E_SYMBOL &&
149 e1->left.sym == e2->left.sym && (e1->left.sym->flags & (SYMBOL_YES|SYMBOL_NO)))
150 return;
151 if (!expr_eq(e1, e2))
152 return;
153 trans_count++;
154 expr_free(e1); expr_free(e2);
155 switch (type) {
156 case E_OR:
157 e1 = expr_alloc_symbol(&symbol_no);
158 e2 = expr_alloc_symbol(&symbol_no);
159 break;
160 case E_AND:
161 e1 = expr_alloc_symbol(&symbol_yes);
162 e2 = expr_alloc_symbol(&symbol_yes);
163 break;
164 default:
165 ;
166 }
167}
168
169void expr_eliminate_eq(struct expr **ep1, struct expr **ep2)
170{
171 if (!e1 || !e2)
172 return;
173 switch (e1->type) {
174 case E_OR:
175 case E_AND:
176 __expr_eliminate_eq(e1->type, ep1, ep2);
177 default:
178 ;
179 }
180 if (e1->type != e2->type) switch (e2->type) {
181 case E_OR:
182 case E_AND:
183 __expr_eliminate_eq(e2->type, ep1, ep2);
184 default:
185 ;
186 }
187 e1 = expr_eliminate_yn(e1);
188 e2 = expr_eliminate_yn(e2);
189}
190
191#undef e1
192#undef e2
193
194int expr_eq(struct expr *e1, struct expr *e2)
195{
196 int res, old_count;
197
198 if (e1->type != e2->type)
199 return 0;
200 switch (e1->type) {
201 case E_EQUAL:
202 case E_UNEQUAL:
203 return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym;
204 case E_SYMBOL:
205 return e1->left.sym == e2->left.sym;
206 case E_NOT:
207 return expr_eq(e1->left.expr, e2->left.expr);
208 case E_AND:
209 case E_OR:
210 e1 = expr_copy(e1);
211 e2 = expr_copy(e2);
212 old_count = trans_count;
213 expr_eliminate_eq(&e1, &e2);
214 res = (e1->type == E_SYMBOL && e2->type == E_SYMBOL &&
215 e1->left.sym == e2->left.sym);
216 expr_free(e1);
217 expr_free(e2);
218 trans_count = old_count;
219 return res;
220 case E_CHOICE:
221 case E_RANGE:
222 case E_NONE:
223 /* panic */;
224 }
225
226 if (DEBUG_EXPR) {
227 expr_fprint(e1, stdout);
228 printf(" = ");
229 expr_fprint(e2, stdout);
230 printf(" ?\n");
231 }
232
233 return 0;
234}
235
236struct expr *expr_eliminate_yn(struct expr *e)
237{
238 struct expr *tmp;
239
240 if (e) switch (e->type) {
241 case E_AND:
242 e->left.expr = expr_eliminate_yn(e->left.expr);
243 e->right.expr = expr_eliminate_yn(e->right.expr);
244 if (e->left.expr->type == E_SYMBOL) {
245 if (e->left.expr->left.sym == &symbol_no) {
246 expr_free(e->left.expr);
247 expr_free(e->right.expr);
248 e->type = E_SYMBOL;
249 e->left.sym = &symbol_no;
250 e->right.expr = NULL;
251 return e;
252 } else if (e->left.expr->left.sym == &symbol_yes) {
253 free(e->left.expr);
254 tmp = e->right.expr;
255 *e = *(e->right.expr);
256 free(tmp);
257 return e;
258 }
259 }
260 if (e->right.expr->type == E_SYMBOL) {
261 if (e->right.expr->left.sym == &symbol_no) {
262 expr_free(e->left.expr);
263 expr_free(e->right.expr);
264 e->type = E_SYMBOL;
265 e->left.sym = &symbol_no;
266 e->right.expr = NULL;
267 return e;
268 } else if (e->right.expr->left.sym == &symbol_yes) {
269 free(e->right.expr);
270 tmp = e->left.expr;
271 *e = *(e->left.expr);
272 free(tmp);
273 return e;
274 }
275 }
276 break;
277 case E_OR:
278 e->left.expr = expr_eliminate_yn(e->left.expr);
279 e->right.expr = expr_eliminate_yn(e->right.expr);
280 if (e->left.expr->type == E_SYMBOL) {
281 if (e->left.expr->left.sym == &symbol_no) {
282 free(e->left.expr);
283 tmp = e->right.expr;
284 *e = *(e->right.expr);
285 free(tmp);
286 return e;
287 } else if (e->left.expr->left.sym == &symbol_yes) {
288 expr_free(e->left.expr);
289 expr_free(e->right.expr);
290 e->type = E_SYMBOL;
291 e->left.sym = &symbol_yes;
292 e->right.expr = NULL;
293 return e;
294 }
295 }
296 if (e->right.expr->type == E_SYMBOL) {
297 if (e->right.expr->left.sym == &symbol_no) {
298 free(e->right.expr);
299 tmp = e->left.expr;
300 *e = *(e->left.expr);
301 free(tmp);
302 return e;
303 } else if (e->right.expr->left.sym == &symbol_yes) {
304 expr_free(e->left.expr);
305 expr_free(e->right.expr);
306 e->type = E_SYMBOL;
307 e->left.sym = &symbol_yes;
308 e->right.expr = NULL;
309 return e;
310 }
311 }
312 break;
313 default:
314 ;
315 }
316 return e;
317}
318
319/*
320 * bool FOO!=n => FOO
321 */
322struct expr *expr_trans_bool(struct expr *e)
323{
324 if (!e)
325 return NULL;
326 switch (e->type) {
327 case E_AND:
328 case E_OR:
329 case E_NOT:
330 e->left.expr = expr_trans_bool(e->left.expr);
331 e->right.expr = expr_trans_bool(e->right.expr);
332 break;
333 case E_UNEQUAL:
334 // FOO!=n -> FOO
335 if (e->left.sym->type == S_TRISTATE) {
336 if (e->right.sym == &symbol_no) {
337 e->type = E_SYMBOL;
338 e->right.sym = NULL;
339 }
340 }
341 break;
342 default:
343 ;
344 }
345 return e;
346}
347
348/*
349 * e1 || e2 -> ?
350 */
351struct expr *expr_join_or(struct expr *e1, struct expr *e2)
352{
353 struct expr *tmp;
354 struct symbol *sym1, *sym2;
355
356 if (expr_eq(e1, e2))
357 return expr_copy(e1);
358 if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT)
359 return NULL;
360 if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT)
361 return NULL;
362 if (e1->type == E_NOT) {
363 tmp = e1->left.expr;
364 if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL)
365 return NULL;
366 sym1 = tmp->left.sym;
367 } else
368 sym1 = e1->left.sym;
369 if (e2->type == E_NOT) {
370 if (e2->left.expr->type != E_SYMBOL)
371 return NULL;
372 sym2 = e2->left.expr->left.sym;
373 } else
374 sym2 = e2->left.sym;
375 if (sym1 != sym2)
376 return NULL;
377 if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE)
378 return NULL;
379 if (sym1->type == S_TRISTATE) {
380 if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
381 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) ||
382 (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) {
383 // (a='y') || (a='m') -> (a!='n')
384 return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_no);
385 }
386 if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
387 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) ||
388 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) {
389 // (a='y') || (a='n') -> (a!='m')
390 return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_mod);
391 }
392 if (e1->type == E_EQUAL && e2->type == E_EQUAL &&
393 ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) ||
394 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) {
395 // (a='m') || (a='n') -> (a!='y')
396 return expr_alloc_comp(E_UNEQUAL, sym1, &symbol_yes);
397 }
398 }
399 if (sym1->type == S_BOOLEAN && sym1 == sym2) {
400 if ((e1->type == E_NOT && e1->left.expr->type == E_SYMBOL && e2->type == E_SYMBOL) ||
401 (e2->type == E_NOT && e2->left.expr->type == E_SYMBOL && e1->type == E_SYMBOL))
402 return expr_alloc_symbol(&symbol_yes);
403 }
404
405 if (DEBUG_EXPR) {
406 printf("optimize (");
407 expr_fprint(e1, stdout);
408 printf(") || (");
409 expr_fprint(e2, stdout);
410 printf(")?\n");
411 }
412 return NULL;
413}
414
415struct expr *expr_join_and(struct expr *e1, struct expr *e2)
416{
417 struct expr *tmp;
418 struct symbol *sym1, *sym2;
419
420 if (expr_eq(e1, e2))
421 return expr_copy(e1);
422 if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT)
423 return NULL;
424 if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT)
425 return NULL;
426 if (e1->type == E_NOT) {
427 tmp = e1->left.expr;
428 if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL)
429 return NULL;
430 sym1 = tmp->left.sym;
431 } else
432 sym1 = e1->left.sym;
433 if (e2->type == E_NOT) {
434 if (e2->left.expr->type != E_SYMBOL)
435 return NULL;
436 sym2 = e2->left.expr->left.sym;
437 } else
438 sym2 = e2->left.sym;
439 if (sym1 != sym2)
440 return NULL;
441 if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE)
442 return NULL;
443
444 if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_yes) ||
445 (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_yes))
446 // (a) && (a='y') -> (a='y')
447 return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes);
448
449 if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_no) ||
450 (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_no))
451 // (a) && (a!='n') -> (a)
452 return expr_alloc_symbol(sym1);
453
454 if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_mod) ||
455 (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_mod))
456 // (a) && (a!='m') -> (a='y')
457 return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes);
458
459 if (sym1->type == S_TRISTATE) {
460 if (e1->type == E_EQUAL && e2->type == E_UNEQUAL) {
461 // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b'
462 sym2 = e1->right.sym;
463 if ((e2->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST))
464 return sym2 != e2->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2)
465 : expr_alloc_symbol(&symbol_no);
466 }
467 if (e1->type == E_UNEQUAL && e2->type == E_EQUAL) {
468 // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b'
469 sym2 = e2->right.sym;
470 if ((e1->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST))
471 return sym2 != e1->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2)
472 : expr_alloc_symbol(&symbol_no);
473 }
474 if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL &&
475 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) ||
476 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes)))
477 // (a!='y') && (a!='n') -> (a='m')
478 return expr_alloc_comp(E_EQUAL, sym1, &symbol_mod);
479
480 if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL &&
481 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) ||
482 (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes)))
483 // (a!='y') && (a!='m') -> (a='n')
484 return expr_alloc_comp(E_EQUAL, sym1, &symbol_no);
485
486 if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL &&
487 ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) ||
488 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod)))
489 // (a!='m') && (a!='n') -> (a='m')
490 return expr_alloc_comp(E_EQUAL, sym1, &symbol_yes);
491
492 if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_mod) ||
493 (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_mod) ||
494 (e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_yes) ||
495 (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_yes))
496 return NULL;
497 }
498
499 if (DEBUG_EXPR) {
500 printf("optimize (");
501 expr_fprint(e1, stdout);
502 printf(") && (");
503 expr_fprint(e2, stdout);
504 printf(")?\n");
505 }
506 return NULL;
507}
508
509static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2)
510{
511#define e1 (*ep1)
512#define e2 (*ep2)
513 struct expr *tmp;
514
515 if (e1->type == type) {
516 expr_eliminate_dups1(type, &e1->left.expr, &e2);
517 expr_eliminate_dups1(type, &e1->right.expr, &e2);
518 return;
519 }
520 if (e2->type == type) {
521 expr_eliminate_dups1(type, &e1, &e2->left.expr);
522 expr_eliminate_dups1(type, &e1, &e2->right.expr);
523 return;
524 }
525 if (e1 == e2)
526 return;
527
528 switch (e1->type) {
529 case E_OR: case E_AND:
530 expr_eliminate_dups1(e1->type, &e1, &e1);
531 default:
532 ;
533 }
534
535 switch (type) {
536 case E_OR:
537 tmp = expr_join_or(e1, e2);
538 if (tmp) {
539 expr_free(e1); expr_free(e2);
540 e1 = expr_alloc_symbol(&symbol_no);
541 e2 = tmp;
542 trans_count++;
543 }
544 break;
545 case E_AND:
546 tmp = expr_join_and(e1, e2);
547 if (tmp) {
548 expr_free(e1); expr_free(e2);
549 e1 = expr_alloc_symbol(&symbol_yes);
550 e2 = tmp;
551 trans_count++;
552 }
553 break;
554 default:
555 ;
556 }
557#undef e1
558#undef e2
559}
560
561static void expr_eliminate_dups2(enum expr_type type, struct expr **ep1, struct expr **ep2)
562{
563#define e1 (*ep1)
564#define e2 (*ep2)
565 struct expr *tmp, *tmp1, *tmp2;
566
567 if (e1->type == type) {
568 expr_eliminate_dups2(type, &e1->left.expr, &e2);
569 expr_eliminate_dups2(type, &e1->right.expr, &e2);
570 return;
571 }
572 if (e2->type == type) {
573 expr_eliminate_dups2(type, &e1, &e2->left.expr);
574 expr_eliminate_dups2(type, &e1, &e2->right.expr);
575 }
576 if (e1 == e2)
577 return;
578
579 switch (e1->type) {
580 case E_OR:
581 expr_eliminate_dups2(e1->type, &e1, &e1);
582 // (FOO || BAR) && (!FOO && !BAR) -> n
583 tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1)));
584 tmp2 = expr_copy(e2);
585 tmp = expr_extract_eq_and(&tmp1, &tmp2);
586 if (expr_is_yes(tmp1)) {
587 expr_free(e1);
588 e1 = expr_alloc_symbol(&symbol_no);
589 trans_count++;
590 }
591 expr_free(tmp2);
592 expr_free(tmp1);
593 expr_free(tmp);
594 break;
595 case E_AND:
596 expr_eliminate_dups2(e1->type, &e1, &e1);
597 // (FOO && BAR) || (!FOO || !BAR) -> y
598 tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1)));
599 tmp2 = expr_copy(e2);
600 tmp = expr_extract_eq_or(&tmp1, &tmp2);
601 if (expr_is_no(tmp1)) {
602 expr_free(e1);
603 e1 = expr_alloc_symbol(&symbol_yes);
604 trans_count++;
605 }
606 expr_free(tmp2);
607 expr_free(tmp1);
608 expr_free(tmp);
609 break;
610 default:
611 ;
612 }
613#undef e1
614#undef e2
615}
616
617struct expr *expr_eliminate_dups(struct expr *e)
618{
619 int oldcount;
620 if (!e)
621 return e;
622
623 oldcount = trans_count;
624 while (1) {
625 trans_count = 0;
626 switch (e->type) {
627 case E_OR: case E_AND:
628 expr_eliminate_dups1(e->type, &e, &e);
629 expr_eliminate_dups2(e->type, &e, &e);
630 default:
631 ;
632 }
633 if (!trans_count)
634 break;
635 e = expr_eliminate_yn(e);
636 }
637 trans_count = oldcount;
638 return e;
639}
640
641struct expr *expr_transform(struct expr *e)
642{
643 struct expr *tmp;
644
645 if (!e)
646 return NULL;
647 switch (e->type) {
648 case E_EQUAL:
649 case E_UNEQUAL:
650 case E_SYMBOL:
651 case E_CHOICE:
652 break;
653 default:
654 e->left.expr = expr_transform(e->left.expr);
655 e->right.expr = expr_transform(e->right.expr);
656 }
657
658 switch (e->type) {
659 case E_EQUAL:
660 if (e->left.sym->type != S_BOOLEAN)
661 break;
662 if (e->right.sym == &symbol_no) {
663 e->type = E_NOT;
664 e->left.expr = expr_alloc_symbol(e->left.sym);
665 e->right.sym = NULL;
666 break;
667 }
668 if (e->right.sym == &symbol_mod) {
669 printf("boolean symbol %s tested for 'm'? test forced to 'n'\n", e->left.sym->name);
670 e->type = E_SYMBOL;
671 e->left.sym = &symbol_no;
672 e->right.sym = NULL;
673 break;
674 }
675 if (e->right.sym == &symbol_yes) {
676 e->type = E_SYMBOL;
677 e->right.sym = NULL;
678 break;
679 }
680 break;
681 case E_UNEQUAL:
682 if (e->left.sym->type != S_BOOLEAN)
683 break;
684 if (e->right.sym == &symbol_no) {
685 e->type = E_SYMBOL;
686 e->right.sym = NULL;
687 break;
688 }
689 if (e->right.sym == &symbol_mod) {
690 printf("boolean symbol %s tested for 'm'? test forced to 'y'\n", e->left.sym->name);
691 e->type = E_SYMBOL;
692 e->left.sym = &symbol_yes;
693 e->right.sym = NULL;
694 break;
695 }
696 if (e->right.sym == &symbol_yes) {
697 e->type = E_NOT;
698 e->left.expr = expr_alloc_symbol(e->left.sym);
699 e->right.sym = NULL;
700 break;
701 }
702 break;
703 case E_NOT:
704 switch (e->left.expr->type) {
705 case E_NOT:
706 // !!a -> a
707 tmp = e->left.expr->left.expr;
708 free(e->left.expr);
709 free(e);
710 e = tmp;
711 e = expr_transform(e);
712 break;
713 case E_EQUAL:
714 case E_UNEQUAL:
715 // !a='x' -> a!='x'
716 tmp = e->left.expr;
717 free(e);
718 e = tmp;
719 e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL;
720 break;
721 case E_OR:
722 // !(a || b) -> !a && !b
723 tmp = e->left.expr;
724 e->type = E_AND;
725 e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr);
726 tmp->type = E_NOT;
727 tmp->right.expr = NULL;
728 e = expr_transform(e);
729 break;
730 case E_AND:
731 // !(a && b) -> !a || !b
732 tmp = e->left.expr;
733 e->type = E_OR;
734 e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr);
735 tmp->type = E_NOT;
736 tmp->right.expr = NULL;
737 e = expr_transform(e);
738 break;
739 case E_SYMBOL:
740 if (e->left.expr->left.sym == &symbol_yes) {
741 // !'y' -> 'n'
742 tmp = e->left.expr;
743 free(e);
744 e = tmp;
745 e->type = E_SYMBOL;
746 e->left.sym = &symbol_no;
747 break;
748 }
749 if (e->left.expr->left.sym == &symbol_mod) {
750 // !'m' -> 'm'
751 tmp = e->left.expr;
752 free(e);
753 e = tmp;
754 e->type = E_SYMBOL;
755 e->left.sym = &symbol_mod;
756 break;
757 }
758 if (e->left.expr->left.sym == &symbol_no) {
759 // !'n' -> 'y'
760 tmp = e->left.expr;
761 free(e);
762 e = tmp;
763 e->type = E_SYMBOL;
764 e->left.sym = &symbol_yes;
765 break;
766 }
767 break;
768 default:
769 ;
770 }
771 break;
772 default:
773 ;
774 }
775 return e;
776}
777
778int expr_contains_symbol(struct expr *dep, struct symbol *sym)
779{
780 if (!dep)
781 return 0;
782
783 switch (dep->type) {
784 case E_AND:
785 case E_OR:
786 return expr_contains_symbol(dep->left.expr, sym) ||
787 expr_contains_symbol(dep->right.expr, sym);
788 case E_SYMBOL:
789 return dep->left.sym == sym;
790 case E_EQUAL:
791 case E_UNEQUAL:
792 return dep->left.sym == sym ||
793 dep->right.sym == sym;
794 case E_NOT:
795 return expr_contains_symbol(dep->left.expr, sym);
796 default:
797 ;
798 }
799 return 0;
800}
801
802bool expr_depends_symbol(struct expr *dep, struct symbol *sym)
803{
804 if (!dep)
805 return false;
806
807 switch (dep->type) {
808 case E_AND:
809 return expr_depends_symbol(dep->left.expr, sym) ||
810 expr_depends_symbol(dep->right.expr, sym);
811 case E_SYMBOL:
812 return dep->left.sym == sym;
813 case E_EQUAL:
814 if (dep->left.sym == sym) {
815 if (dep->right.sym == &symbol_yes || dep->right.sym == &symbol_mod)
816 return true;
817 }
818 break;
819 case E_UNEQUAL:
820 if (dep->left.sym == sym) {
821 if (dep->right.sym == &symbol_no)
822 return true;
823 }
824 break;
825 default:
826 ;
827 }
828 return false;
829}
830
831struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2)
832{
833 struct expr *tmp = NULL;
834 expr_extract_eq(E_AND, &tmp, ep1, ep2);
835 if (tmp) {
836 *ep1 = expr_eliminate_yn(*ep1);
837 *ep2 = expr_eliminate_yn(*ep2);
838 }
839 return tmp;
840}
841
842struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2)
843{
844 struct expr *tmp = NULL;
845 expr_extract_eq(E_OR, &tmp, ep1, ep2);
846 if (tmp) {
847 *ep1 = expr_eliminate_yn(*ep1);
848 *ep2 = expr_eliminate_yn(*ep2);
849 }
850 return tmp;
851}
852
853void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2)
854{
855#define e1 (*ep1)
856#define e2 (*ep2)
857 if (e1->type == type) {
858 expr_extract_eq(type, ep, &e1->left.expr, &e2);
859 expr_extract_eq(type, ep, &e1->right.expr, &e2);
860 return;
861 }
862 if (e2->type == type) {
863 expr_extract_eq(type, ep, ep1, &e2->left.expr);
864 expr_extract_eq(type, ep, ep1, &e2->right.expr);
865 return;
866 }
867 if (expr_eq(e1, e2)) {
868 *ep = *ep ? expr_alloc_two(type, *ep, e1) : e1;
869 expr_free(e2);
870 if (type == E_AND) {
871 e1 = expr_alloc_symbol(&symbol_yes);
872 e2 = expr_alloc_symbol(&symbol_yes);
873 } else if (type == E_OR) {
874 e1 = expr_alloc_symbol(&symbol_no);
875 e2 = expr_alloc_symbol(&symbol_no);
876 }
877 }
878#undef e1
879#undef e2
880}
881
882struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym)
883{
884 struct expr *e1, *e2;
885
886 if (!e) {
887 e = expr_alloc_symbol(sym);
888 if (type == E_UNEQUAL)
889 e = expr_alloc_one(E_NOT, e);
890 return e;
891 }
892 switch (e->type) {
893 case E_AND:
894 e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym);
895 e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym);
896 if (sym == &symbol_yes)
897 e = expr_alloc_two(E_AND, e1, e2);
898 if (sym == &symbol_no)
899 e = expr_alloc_two(E_OR, e1, e2);
900 if (type == E_UNEQUAL)
901 e = expr_alloc_one(E_NOT, e);
902 return e;
903 case E_OR:
904 e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym);
905 e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym);
906 if (sym == &symbol_yes)
907 e = expr_alloc_two(E_OR, e1, e2);
908 if (sym == &symbol_no)
909 e = expr_alloc_two(E_AND, e1, e2);
910 if (type == E_UNEQUAL)
911 e = expr_alloc_one(E_NOT, e);
912 return e;
913 case E_NOT:
914 return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym);
915 case E_UNEQUAL:
916 case E_EQUAL:
917 if (type == E_EQUAL) {
918 if (sym == &symbol_yes)
919 return expr_copy(e);
920 if (sym == &symbol_mod)
921 return expr_alloc_symbol(&symbol_no);
922 if (sym == &symbol_no)
923 return expr_alloc_one(E_NOT, expr_copy(e));
924 } else {
925 if (sym == &symbol_yes)
926 return expr_alloc_one(E_NOT, expr_copy(e));
927 if (sym == &symbol_mod)
928 return expr_alloc_symbol(&symbol_yes);
929 if (sym == &symbol_no)
930 return expr_copy(e);
931 }
932 break;
933 case E_SYMBOL:
934 return expr_alloc_comp(type, e->left.sym, sym);
935 case E_CHOICE:
936 case E_RANGE:
937 case E_NONE:
938 /* panic */;
939 }
940 return NULL;
941}
942
943tristate expr_calc_value(struct expr *e)
944{
945 tristate val1, val2;
946 const char *str1, *str2;
947
948 if (!e)
949 return yes;
950
951 switch (e->type) {
952 case E_SYMBOL:
953 sym_calc_value(e->left.sym);
954 return e->left.sym->curr.tri;
955 case E_AND:
956 val1 = expr_calc_value(e->left.expr);
957 val2 = expr_calc_value(e->right.expr);
958 return E_AND(val1, val2);
959 case E_OR:
960 val1 = expr_calc_value(e->left.expr);
961 val2 = expr_calc_value(e->right.expr);
962 return E_OR(val1, val2);
963 case E_NOT:
964 val1 = expr_calc_value(e->left.expr);
965 return E_NOT(val1);
966 case E_EQUAL:
967 sym_calc_value(e->left.sym);
968 sym_calc_value(e->right.sym);
969 str1 = sym_get_string_value(e->left.sym);
970 str2 = sym_get_string_value(e->right.sym);
971 return !strcmp(str1, str2) ? yes : no;
972 case E_UNEQUAL:
973 sym_calc_value(e->left.sym);
974 sym_calc_value(e->right.sym);
975 str1 = sym_get_string_value(e->left.sym);
976 str2 = sym_get_string_value(e->right.sym);
977 return !strcmp(str1, str2) ? no : yes;
978 default:
979 printf("expr_calc_value: %d?\n", e->type);
980 return no;
981 }
982}
983
984int expr_compare_type(enum expr_type t1, enum expr_type t2)
985{
986#if 0
987 return 1;
988#else
989 if (t1 == t2)
990 return 0;
991 switch (t1) {
992 case E_EQUAL:
993 case E_UNEQUAL:
994 if (t2 == E_NOT)
995 return 1;
996 case E_NOT:
997 if (t2 == E_AND)
998 return 1;
999 case E_AND:
1000 if (t2 == E_OR)
1001 return 1;
1002 case E_OR:
1003 if (t2 == E_CHOICE)
1004 return 1;
1005 case E_CHOICE:
1006 if (t2 == 0)
1007 return 1;
1008 default:
1009 return -1;
1010 }
1011 printf("[%dgt%d?]", t1, t2);
1012 return 0;
1013#endif
1014}
1015
1016void expr_print(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken)
1017{
1018 if (!e) {
1019 fn(data, "y");
1020 return;
1021 }
1022
1023 if (expr_compare_type(prevtoken, e->type) > 0)
1024 fn(data, "(");
1025 switch (e->type) {
1026 case E_SYMBOL:
1027 if (e->left.sym->name)
1028 fn(data, e->left.sym->name);
1029 else
1030 fn(data, "<choice>");
1031 break;
1032 case E_NOT:
1033 fn(data, "!");
1034 expr_print(e->left.expr, fn, data, E_NOT);
1035 break;
1036 case E_EQUAL:
1037 fn(data, e->left.sym->name);
1038 fn(data, "=");
1039 fn(data, e->right.sym->name);
1040 break;
1041 case E_UNEQUAL:
1042 fn(data, e->left.sym->name);
1043 fn(data, "!=");
1044 fn(data, e->right.sym->name);
1045 break;
1046 case E_OR:
1047 expr_print(e->left.expr, fn, data, E_OR);
1048 fn(data, " || ");
1049 expr_print(e->right.expr, fn, data, E_OR);
1050 break;
1051 case E_AND:
1052 expr_print(e->left.expr, fn, data, E_AND);
1053 fn(data, " && ");
1054 expr_print(e->right.expr, fn, data, E_AND);
1055 break;
1056 case E_CHOICE:
1057 fn(data, e->right.sym->name);
1058 if (e->left.expr) {
1059 fn(data, " ^ ");
1060 expr_print(e->left.expr, fn, data, E_CHOICE);
1061 }
1062 break;
1063 case E_RANGE:
1064 fn(data, "[");
1065 fn(data, e->left.sym->name);
1066 fn(data, " ");
1067 fn(data, e->right.sym->name);
1068 fn(data, "]");
1069 break;
1070 default:
1071 {
1072 char buf[32];
1073 sprintf(buf, "<unknown type %d>", e->type);
1074 fn(data, buf);
1075 break;
1076 }
1077 }
1078 if (expr_compare_type(prevtoken, e->type) > 0)
1079 fn(data, ")");
1080}
1081
1082static void expr_print_file_helper(void *data, const char *str)
1083{
1084 fwrite(str, strlen(str), 1, data);
1085}
1086
1087void expr_fprint(struct expr *e, FILE *out)
1088{
1089 expr_print(e, expr_print_file_helper, out, E_NONE);
1090}
1091
1092static void expr_print_gstr_helper(void *data, const char *str)
1093{
1094 str_append((struct gstr*)data, str);
1095}
1096
1097void expr_gstr_print(struct expr *e, struct gstr *gs)
1098{
1099 expr_print(e, expr_print_gstr_helper, gs, E_NONE);
1100}
diff --git a/scripts/config/expr.h b/scripts/config/expr.h
deleted file mode 100644
index de7332f64..000000000
--- a/scripts/config/expr.h
+++ /dev/null
@@ -1,196 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0.
5 */
6
7#ifndef EXPR_H
8#define EXPR_H
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14#include <stdio.h>
15#ifndef __cplusplus
16#include <stdbool.h>
17#endif
18
19struct file {
20 struct file *next;
21 struct file *parent;
22 char *name;
23 int lineno;
24 int flags;
25};
26
27#define FILE_BUSY 0x0001
28#define FILE_SCANNED 0x0002
29#define FILE_PRINTED 0x0004
30
31typedef enum tristate {
32 no, mod, yes
33} tristate;
34
35enum expr_type {
36 E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_CHOICE, E_SYMBOL, E_RANGE
37};
38
39union expr_data {
40 struct expr *expr;
41 struct symbol *sym;
42};
43
44struct expr {
45 enum expr_type type;
46 union expr_data left, right;
47};
48
49#define E_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2))
50#define E_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2))
51#define E_NOT(dep) (2-(dep))
52
53struct expr_value {
54 struct expr *expr;
55 tristate tri;
56};
57
58struct symbol_value {
59 void *val;
60 tristate tri;
61};
62
63enum symbol_type {
64 S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER
65};
66
67struct symbol {
68 struct symbol *next;
69 char *name;
70 char *help;
71 enum symbol_type type;
72 struct symbol_value curr, user;
73 tristate visible;
74 int flags;
75 struct property *prop;
76 struct expr *dep, *dep2;
77 struct expr_value rev_dep;
78};
79
80#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
81
82#define SYMBOL_YES 0x0001
83#define SYMBOL_MOD 0x0002
84#define SYMBOL_NO 0x0004
85#define SYMBOL_CONST 0x0007
86#define SYMBOL_CHECK 0x0008
87#define SYMBOL_CHOICE 0x0010
88#define SYMBOL_CHOICEVAL 0x0020
89#define SYMBOL_PRINTED 0x0040
90#define SYMBOL_VALID 0x0080
91#define SYMBOL_OPTIONAL 0x0100
92#define SYMBOL_WRITE 0x0200
93#define SYMBOL_CHANGED 0x0400
94#define SYMBOL_NEW 0x0800
95#define SYMBOL_AUTO 0x1000
96#define SYMBOL_CHECKED 0x2000
97#define SYMBOL_CHECK_DONE 0x4000
98#define SYMBOL_WARNED 0x8000
99
100#define SYMBOL_MAXLENGTH 256
101#define SYMBOL_HASHSIZE 257
102#define SYMBOL_HASHMASK 0xff
103
104enum prop_type {
105 P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, P_SELECT, P_RANGE
106};
107
108struct property {
109 struct property *next;
110 struct symbol *sym;
111 enum prop_type type;
112 const char *text;
113 struct expr_value visible;
114 struct expr *expr;
115 struct menu *menu;
116 struct file *file;
117 int lineno;
118};
119
120#define for_all_properties(sym, st, tok) \
121 for (st = sym->prop; st; st = st->next) \
122 if (st->type == (tok))
123#define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT)
124#define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE)
125#define for_all_prompts(sym, st) \
126 for (st = sym->prop; st; st = st->next) \
127 if (st->text)
128
129struct menu {
130 struct menu *next;
131 struct menu *parent;
132 struct menu *list;
133 struct symbol *sym;
134 struct property *prompt;
135 struct expr *dep;
136 unsigned int flags;
137 //char *help;
138 struct file *file;
139 int lineno;
140 void *data;
141};
142
143#define MENU_CHANGED 0x0001
144#define MENU_ROOT 0x0002
145
146#ifndef SWIG
147
148extern struct file *file_list;
149extern struct file *current_file;
150struct file *lookup_file(const char *name);
151
152extern struct symbol symbol_yes, symbol_no, symbol_mod;
153extern struct symbol *modules_sym;
154extern int cdebug;
155struct expr *expr_alloc_symbol(struct symbol *sym);
156struct expr *expr_alloc_one(enum expr_type type, struct expr *ce);
157struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2);
158struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2);
159struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
160struct expr *expr_alloc_or(struct expr *e1, struct expr *e2);
161struct expr *expr_copy(struct expr *org);
162void expr_free(struct expr *e);
163int expr_eq(struct expr *e1, struct expr *e2);
164void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
165tristate expr_calc_value(struct expr *e);
166struct expr *expr_eliminate_yn(struct expr *e);
167struct expr *expr_trans_bool(struct expr *e);
168struct expr *expr_eliminate_dups(struct expr *e);
169struct expr *expr_transform(struct expr *e);
170int expr_contains_symbol(struct expr *dep, struct symbol *sym);
171bool expr_depends_symbol(struct expr *dep, struct symbol *sym);
172struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2);
173struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2);
174void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2);
175struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
176
177void expr_fprint(struct expr *e, FILE *out);
178struct gstr; /* forward */
179void expr_gstr_print(struct expr *e, struct gstr *gs);
180
181static inline int expr_is_yes(struct expr *e)
182{
183 return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes);
184}
185
186static inline int expr_is_no(struct expr *e)
187{
188 return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no);
189}
190#endif
191
192#ifdef __cplusplus
193}
194#endif
195
196#endif /* EXPR_H */
diff --git a/scripts/config/lex.zconf.c_shipped b/scripts/config/lex.zconf.c_shipped
deleted file mode 100644
index 8e5e85e4c..000000000
--- a/scripts/config/lex.zconf.c_shipped
+++ /dev/null
@@ -1,3688 +0,0 @@
1
2#line 3 "lex.zconf.c"
3
4#define YY_INT_ALIGNED short int
5
6/* A lexical scanner generated by flex */
7
8#define FLEX_SCANNER
9#define YY_FLEX_MAJOR_VERSION 2
10#define YY_FLEX_MINOR_VERSION 5
11#define YY_FLEX_SUBMINOR_VERSION 31
12#if YY_FLEX_SUBMINOR_VERSION > 0
13#define FLEX_BETA
14#endif
15
16/* First, we deal with platform-specific or compiler-specific issues. */
17
18/* begin standard C headers. */
19#include <stdio.h>
20#include <string.h>
21#include <errno.h>
22#include <stdlib.h>
23
24/* end standard C headers. */
25
26/* flex integer type definitions */
27
28#ifndef FLEXINT_H
29#define FLEXINT_H
30
31/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
32
33#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
34#include <inttypes.h>
35typedef int8_t flex_int8_t;
36typedef uint8_t flex_uint8_t;
37typedef int16_t flex_int16_t;
38typedef uint16_t flex_uint16_t;
39typedef int32_t flex_int32_t;
40typedef uint32_t flex_uint32_t;
41#else
42typedef signed char flex_int8_t;
43typedef short int flex_int16_t;
44typedef int flex_int32_t;
45typedef unsigned char flex_uint8_t;
46typedef unsigned short int flex_uint16_t;
47typedef unsigned int flex_uint32_t;
48#endif /* ! C99 */
49
50/* Limits of integral types. */
51#ifndef INT8_MIN
52#define INT8_MIN (-128)
53#endif
54#ifndef INT16_MIN
55#define INT16_MIN (-32767-1)
56#endif
57#ifndef INT32_MIN
58#define INT32_MIN (-2147483647-1)
59#endif
60#ifndef INT8_MAX
61#define INT8_MAX (127)
62#endif
63#ifndef INT16_MAX
64#define INT16_MAX (32767)
65#endif
66#ifndef INT32_MAX
67#define INT32_MAX (2147483647)
68#endif
69#ifndef UINT8_MAX
70#define UINT8_MAX (255U)
71#endif
72#ifndef UINT16_MAX
73#define UINT16_MAX (65535U)
74#endif
75#ifndef UINT32_MAX
76#define UINT32_MAX (4294967295U)
77#endif
78
79#endif /* ! FLEXINT_H */
80
81#ifdef __cplusplus
82
83/* The "const" storage-class-modifier is valid. */
84#define YY_USE_CONST
85
86#else /* ! __cplusplus */
87
88#if __STDC__
89
90#define YY_USE_CONST
91
92#endif /* __STDC__ */
93#endif /* ! __cplusplus */
94
95#ifdef YY_USE_CONST
96#define yyconst const
97#else
98#define yyconst
99#endif
100
101/* Returned upon end-of-file. */
102#define YY_NULL 0
103
104/* Promotes a possibly negative, possibly signed char to an unsigned
105 * integer for use as an array index. If the signed char is negative,
106 * we want to instead treat it as an 8-bit unsigned char, hence the
107 * double cast.
108 */
109#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
110
111/* Enter a start condition. This macro really ought to take a parameter,
112 * but we do it the disgusting crufty way forced on us by the ()-less
113 * definition of BEGIN.
114 */
115#define BEGIN (yy_start) = 1 + 2 *
116
117/* Translate the current start state into a value that can be later handed
118 * to BEGIN to return to the state. The YYSTATE alias is for lex
119 * compatibility.
120 */
121#define YY_START (((yy_start) - 1) / 2)
122#define YYSTATE YY_START
123
124/* Action number for EOF rule of a given start state. */
125#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
126
127/* Special action meaning "start processing a new file". */
128#define YY_NEW_FILE zconfrestart(zconfin )
129
130#define YY_END_OF_BUFFER_CHAR 0
131
132/* Size of default input buffer. */
133#ifndef YY_BUF_SIZE
134#define YY_BUF_SIZE 16384
135#endif
136
137#ifndef YY_TYPEDEF_YY_BUFFER_STATE
138#define YY_TYPEDEF_YY_BUFFER_STATE
139typedef struct yy_buffer_state *YY_BUFFER_STATE;
140#endif
141
142extern int zconfleng;
143
144extern FILE *zconfin, *zconfout;
145
146#define EOB_ACT_CONTINUE_SCAN 0
147#define EOB_ACT_END_OF_FILE 1
148#define EOB_ACT_LAST_MATCH 2
149
150 #define YY_LESS_LINENO(n)
151
152/* Return all but the first "n" matched characters back to the input stream. */
153#define yyless(n) \
154 do \
155 { \
156 /* Undo effects of setting up zconftext. */ \
157 int yyless_macro_arg = (n); \
158 YY_LESS_LINENO(yyless_macro_arg);\
159 *yy_cp = (yy_hold_char); \
160 YY_RESTORE_YY_MORE_OFFSET \
161 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
162 YY_DO_BEFORE_ACTION; /* set up zconftext again */ \
163 } \
164 while ( 0 )
165
166#define unput(c) yyunput( c, (yytext_ptr) )
167
168/* The following is because we cannot portably get our hands on size_t
169 * (without autoconf's help, which isn't available because we want
170 * flex-generated scanners to compile on their own).
171 */
172
173#ifndef YY_TYPEDEF_YY_SIZE_T
174#define YY_TYPEDEF_YY_SIZE_T
175typedef unsigned int yy_size_t;
176#endif
177
178#ifndef YY_STRUCT_YY_BUFFER_STATE
179#define YY_STRUCT_YY_BUFFER_STATE
180struct yy_buffer_state
181 {
182 FILE *yy_input_file;
183
184 char *yy_ch_buf; /* input buffer */
185 char *yy_buf_pos; /* current position in input buffer */
186
187 /* Size of input buffer in bytes, not including room for EOB
188 * characters.
189 */
190 yy_size_t yy_buf_size;
191
192 /* Number of characters read into yy_ch_buf, not including EOB
193 * characters.
194 */
195 int yy_n_chars;
196
197 /* Whether we "own" the buffer - i.e., we know we created it,
198 * and can realloc() it to grow it, and should free() it to
199 * delete it.
200 */
201 int yy_is_our_buffer;
202
203 /* Whether this is an "interactive" input source; if so, and
204 * if we're using stdio for input, then we want to use getc()
205 * instead of fread(), to make sure we stop fetching input after
206 * each newline.
207 */
208 int yy_is_interactive;
209
210 /* Whether we're considered to be at the beginning of a line.
211 * If so, '^' rules will be active on the next match, otherwise
212 * not.
213 */
214 int yy_at_bol;
215
216 int yy_bs_lineno; /**< The line count. */
217 int yy_bs_column; /**< The column count. */
218
219 /* Whether to try to fill the input buffer when we reach the
220 * end of it.
221 */
222 int yy_fill_buffer;
223
224 int yy_buffer_status;
225
226#define YY_BUFFER_NEW 0
227#define YY_BUFFER_NORMAL 1
228 /* When an EOF's been seen but there's still some text to process
229 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
230 * shouldn't try reading from the input source any more. We might
231 * still have a bunch of tokens to match, though, because of
232 * possible backing-up.
233 *
234 * When we actually see the EOF, we change the status to "new"
235 * (via zconfrestart()), so that the user can continue scanning by
236 * just pointing zconfin at a new input file.
237 */
238#define YY_BUFFER_EOF_PENDING 2
239
240 };
241#endif /* !YY_STRUCT_YY_BUFFER_STATE */
242
243/* Stack of input buffers. */
244static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
245static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
246static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
247
248/* We provide macros for accessing buffer states in case in the
249 * future we want to put the buffer states in a more general
250 * "scanner state".
251 *
252 * Returns the top of the stack, or NULL.
253 */
254#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
255 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
256 : NULL)
257
258/* Same as previous macro, but useful when we know that the buffer stack is not
259 * NULL or when we need an lvalue. For internal use only.
260 */
261#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
262
263/* yy_hold_char holds the character lost when zconftext is formed. */
264static char yy_hold_char;
265static int yy_n_chars; /* number of characters read into yy_ch_buf */
266int zconfleng;
267
268/* Points to current character in buffer. */
269static char *yy_c_buf_p = (char *) 0;
270static int yy_init = 1; /* whether we need to initialize */
271static int yy_start = 0; /* start state number */
272
273/* Flag which is used to allow zconfwrap()'s to do buffer switches
274 * instead of setting up a fresh zconfin. A bit of a hack ...
275 */
276static int yy_did_buffer_switch_on_eof;
277
278void zconfrestart (FILE *input_file );
279void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer );
280YY_BUFFER_STATE zconf_create_buffer (FILE *file,int size );
281void zconf_delete_buffer (YY_BUFFER_STATE b );
282void zconf_flush_buffer (YY_BUFFER_STATE b );
283void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer );
284void zconfpop_buffer_state (void );
285
286static void zconfensure_buffer_stack (void );
287static void zconf_load_buffer_state (void );
288static void zconf_init_buffer (YY_BUFFER_STATE b,FILE *file );
289
290#define YY_FLUSH_BUFFER zconf_flush_buffer(YY_CURRENT_BUFFER )
291
292YY_BUFFER_STATE zconf_scan_buffer (char *base,yy_size_t size );
293YY_BUFFER_STATE zconf_scan_string (yyconst char *yy_str );
294YY_BUFFER_STATE zconf_scan_bytes (yyconst char *bytes,int len );
295
296void *zconfalloc (yy_size_t );
297void *zconfrealloc (void *,yy_size_t );
298void zconffree (void * );
299
300#define yy_new_buffer zconf_create_buffer
301
302#define yy_set_interactive(is_interactive) \
303 { \
304 if ( ! YY_CURRENT_BUFFER ){ \
305 zconfensure_buffer_stack (); \
306 YY_CURRENT_BUFFER_LVALUE = \
307 zconf_create_buffer(zconfin,YY_BUF_SIZE ); \
308 } \
309 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
310 }
311
312#define yy_set_bol(at_bol) \
313 { \
314 if ( ! YY_CURRENT_BUFFER ){\
315 zconfensure_buffer_stack (); \
316 YY_CURRENT_BUFFER_LVALUE = \
317 zconf_create_buffer(zconfin,YY_BUF_SIZE ); \
318 } \
319 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
320 }
321
322#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
323
324/* Begin user sect3 */
325
326#define zconfwrap(n) 1
327#define YY_SKIP_YYWRAP
328
329typedef unsigned char YY_CHAR;
330
331FILE *zconfin = (FILE *) 0, *zconfout = (FILE *) 0;
332
333typedef int yy_state_type;
334
335extern int zconflineno;
336
337int zconflineno = 1;
338
339extern char *zconftext;
340#define yytext_ptr zconftext
341static yyconst flex_int16_t yy_nxt[][38] =
342 {
343 {
344 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
345 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
346 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
347 0, 0, 0, 0, 0, 0, 0, 0
348 },
349
350 {
351 11, 12, 13, 14, 12, 12, 15, 12, 12, 12,
352 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
353 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
354 12, 12, 12, 12, 12, 12, 12, 12
355 },
356
357 {
358 11, 12, 13, 14, 12, 12, 15, 12, 12, 12,
359 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
360
361 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
362 12, 12, 12, 12, 12, 12, 12, 12
363 },
364
365 {
366 11, 16, 16, 17, 16, 16, 16, 16, 16, 16,
367 16, 16, 16, 18, 16, 16, 18, 18, 19, 20,
368 21, 22, 18, 18, 23, 24, 18, 25, 18, 26,
369 27, 18, 28, 29, 30, 18, 18, 16
370 },
371
372 {
373 11, 16, 16, 17, 16, 16, 16, 16, 16, 16,
374 16, 16, 16, 18, 16, 16, 18, 18, 19, 20,
375 21, 22, 18, 18, 23, 24, 18, 25, 18, 26,
376 27, 18, 28, 29, 30, 18, 18, 16
377
378 },
379
380 {
381 11, 31, 32, 33, 31, 31, 31, 31, 31, 31,
382 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
383 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
384 31, 31, 31, 31, 31, 31, 31, 31
385 },
386
387 {
388 11, 31, 32, 33, 31, 31, 31, 31, 31, 31,
389 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
390 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
391 31, 31, 31, 31, 31, 31, 31, 31
392 },
393
394 {
395 11, 34, 34, 35, 34, 36, 34, 34, 36, 34,
396 34, 34, 34, 34, 34, 37, 34, 34, 34, 34,
397
398 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
399 34, 34, 34, 34, 34, 34, 34, 34
400 },
401
402 {
403 11, 34, 34, 35, 34, 36, 34, 34, 36, 34,
404 34, 34, 34, 34, 34, 37, 34, 34, 34, 34,
405 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
406 34, 34, 34, 34, 34, 34, 34, 34
407 },
408
409 {
410 11, 38, 38, 39, 40, 41, 42, 43, 41, 44,
411 45, 46, 47, 47, 48, 49, 47, 47, 47, 47,
412 47, 47, 47, 47, 47, 50, 47, 47, 47, 51,
413 47, 47, 47, 47, 47, 47, 47, 52
414
415 },
416
417 {
418 11, 38, 38, 39, 40, 41, 42, 43, 41, 44,
419 45, 46, 47, 47, 48, 49, 47, 47, 47, 47,
420 47, 47, 47, 47, 47, 50, 47, 47, 47, 51,
421 47, 47, 47, 47, 47, 47, 47, 52
422 },
423
424 {
425 -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
426 -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
427 -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
428 -11, -11, -11, -11, -11, -11, -11, -11
429 },
430
431 {
432 11, -12, -12, -12, -12, -12, -12, -12, -12, -12,
433 -12, -12, -12, -12, -12, -12, -12, -12, -12, -12,
434
435 -12, -12, -12, -12, -12, -12, -12, -12, -12, -12,
436 -12, -12, -12, -12, -12, -12, -12, -12
437 },
438
439 {
440 11, -13, 53, 54, -13, -13, 55, -13, -13, -13,
441 -13, -13, -13, -13, -13, -13, -13, -13, -13, -13,
442 -13, -13, -13, -13, -13, -13, -13, -13, -13, -13,
443 -13, -13, -13, -13, -13, -13, -13, -13
444 },
445
446 {
447 11, -14, -14, -14, -14, -14, -14, -14, -14, -14,
448 -14, -14, -14, -14, -14, -14, -14, -14, -14, -14,
449 -14, -14, -14, -14, -14, -14, -14, -14, -14, -14,
450 -14, -14, -14, -14, -14, -14, -14, -14
451
452 },
453
454 {
455 11, 56, 56, 57, 56, 56, 56, 56, 56, 56,
456 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
457 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
458 56, 56, 56, 56, 56, 56, 56, 56
459 },
460
461 {
462 11, -16, -16, -16, -16, -16, -16, -16, -16, -16,
463 -16, -16, -16, -16, -16, -16, -16, -16, -16, -16,
464 -16, -16, -16, -16, -16, -16, -16, -16, -16, -16,
465 -16, -16, -16, -16, -16, -16, -16, -16
466 },
467
468 {
469 11, -17, -17, -17, -17, -17, -17, -17, -17, -17,
470 -17, -17, -17, -17, -17, -17, -17, -17, -17, -17,
471
472 -17, -17, -17, -17, -17, -17, -17, -17, -17, -17,
473 -17, -17, -17, -17, -17, -17, -17, -17
474 },
475
476 {
477 11, -18, -18, -18, -18, -18, -18, -18, -18, -18,
478 -18, -18, -18, 58, -18, -18, 58, 58, 58, 58,
479 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
480 58, 58, 58, 58, 58, 58, 58, -18
481 },
482
483 {
484 11, -19, -19, -19, -19, -19, -19, -19, -19, -19,
485 -19, -19, -19, 58, -19, -19, 58, 58, 58, 58,
486 58, 58, 58, 58, 58, 58, 58, 58, 58, 59,
487 58, 58, 58, 58, 58, 58, 58, -19
488
489 },
490
491 {
492 11, -20, -20, -20, -20, -20, -20, -20, -20, -20,
493 -20, -20, -20, 58, -20, -20, 58, 58, 58, 58,
494 58, 58, 58, 58, 60, 58, 58, 58, 58, 61,
495 58, 58, 58, 58, 58, 58, 58, -20
496 },
497
498 {
499 11, -21, -21, -21, -21, -21, -21, -21, -21, -21,
500 -21, -21, -21, 58, -21, -21, 58, 58, 58, 58,
501 58, 62, 58, 58, 58, 58, 58, 58, 58, 58,
502 58, 58, 58, 58, 58, 58, 58, -21
503 },
504
505 {
506 11, -22, -22, -22, -22, -22, -22, -22, -22, -22,
507 -22, -22, -22, 58, -22, -22, 58, 58, 58, 58,
508
509 58, 58, 58, 58, 58, 58, 58, 58, 63, 58,
510 58, 58, 58, 58, 58, 58, 58, -22
511 },
512
513 {
514 11, -23, -23, -23, -23, -23, -23, -23, -23, -23,
515 -23, -23, -23, 58, -23, -23, 58, 58, 58, 58,
516 58, 64, 58, 58, 58, 58, 58, 58, 58, 58,
517 58, 58, 58, 58, 58, 58, 58, -23
518 },
519
520 {
521 11, -24, -24, -24, -24, -24, -24, -24, -24, -24,
522 -24, -24, -24, 58, -24, -24, 58, 58, 58, 58,
523 58, 58, 65, 58, 58, 58, 58, 58, 66, 58,
524 58, 58, 58, 58, 58, 58, 58, -24
525
526 },
527
528 {
529 11, -25, -25, -25, -25, -25, -25, -25, -25, -25,
530 -25, -25, -25, 58, -25, -25, 58, 67, 58, 58,
531 58, 68, 58, 58, 58, 58, 58, 58, 58, 58,
532 58, 58, 58, 58, 58, 58, 58, -25
533 },
534
535 {
536 11, -26, -26, -26, -26, -26, -26, -26, -26, -26,
537 -26, -26, -26, 58, -26, -26, 58, 58, 58, 58,
538 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
539 69, 58, 58, 58, 58, 58, 58, -26
540 },
541
542 {
543 11, -27, -27, -27, -27, -27, -27, -27, -27, -27,
544 -27, -27, -27, 58, -27, -27, 58, 58, 58, 58,
545
546 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
547 58, 58, 70, 58, 58, 58, 58, -27
548 },
549
550 {
551 11, -28, -28, -28, -28, -28, -28, -28, -28, -28,
552 -28, -28, -28, 58, -28, -28, 58, 71, 58, 58,
553 58, 72, 58, 58, 58, 58, 58, 58, 58, 58,
554 58, 58, 58, 58, 58, 58, 58, -28
555 },
556
557 {
558 11, -29, -29, -29, -29, -29, -29, -29, -29, -29,
559 -29, -29, -29, 58, -29, -29, 58, 58, 58, 58,
560 58, 73, 58, 58, 58, 58, 58, 58, 58, 74,
561 58, 58, 58, 58, 75, 58, 58, -29
562
563 },
564
565 {
566 11, -30, -30, -30, -30, -30, -30, -30, -30, -30,
567 -30, -30, -30, 58, -30, -30, 58, 58, 58, 58,
568 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
569 58, 58, 76, 58, 58, 58, 58, -30
570 },
571
572 {
573 11, 77, 77, -31, 77, 77, 77, 77, 77, 77,
574 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
575 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
576 77, 77, 77, 77, 77, 77, 77, 77
577 },
578
579 {
580 11, -32, 78, 79, -32, -32, -32, -32, -32, -32,
581 -32, -32, -32, -32, -32, -32, -32, -32, -32, -32,
582
583 -32, -32, -32, -32, -32, -32, -32, -32, -32, -32,
584 -32, -32, -32, -32, -32, -32, -32, -32
585 },
586
587 {
588 11, 80, -33, -33, 80, 80, 80, 80, 80, 80,
589 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
590 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
591 80, 80, 80, 80, 80, 80, 80, 80
592 },
593
594 {
595 11, 81, 81, 82, 81, -34, 81, 81, -34, 81,
596 81, 81, 81, 81, 81, -34, 81, 81, 81, 81,
597 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
598 81, 81, 81, 81, 81, 81, 81, 81
599
600 },
601
602 {
603 11, -35, -35, -35, -35, -35, -35, -35, -35, -35,
604 -35, -35, -35, -35, -35, -35, -35, -35, -35, -35,
605 -35, -35, -35, -35, -35, -35, -35, -35, -35, -35,
606 -35, -35, -35, -35, -35, -35, -35, -35
607 },
608
609 {
610 11, -36, -36, -36, -36, -36, -36, -36, -36, -36,
611 -36, -36, -36, -36, -36, -36, -36, -36, -36, -36,
612 -36, -36, -36, -36, -36, -36, -36, -36, -36, -36,
613 -36, -36, -36, -36, -36, -36, -36, -36
614 },
615
616 {
617 11, 83, 83, 84, 83, 83, 83, 83, 83, 83,
618 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
619
620 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
621 83, 83, 83, 83, 83, 83, 83, 83
622 },
623
624 {
625 11, -38, -38, -38, -38, -38, -38, -38, -38, -38,
626 -38, -38, -38, -38, -38, -38, -38, -38, -38, -38,
627 -38, -38, -38, -38, -38, -38, -38, -38, -38, -38,
628 -38, -38, -38, -38, -38, -38, -38, -38
629 },
630
631 {
632 11, -39, -39, -39, -39, -39, -39, -39, -39, -39,
633 -39, -39, -39, -39, -39, -39, -39, -39, -39, -39,
634 -39, -39, -39, -39, -39, -39, -39, -39, -39, -39,
635 -39, -39, -39, -39, -39, -39, -39, -39
636
637 },
638
639 {
640 11, -40, -40, -40, -40, -40, -40, -40, -40, -40,
641 -40, -40, -40, -40, 85, -40, -40, -40, -40, -40,
642 -40, -40, -40, -40, -40, -40, -40, -40, -40, -40,
643 -40, -40, -40, -40, -40, -40, -40, -40
644 },
645
646 {
647 11, -41, -41, -41, -41, -41, -41, -41, -41, -41,
648 -41, -41, -41, -41, -41, -41, -41, -41, -41, -41,
649 -41, -41, -41, -41, -41, -41, -41, -41, -41, -41,
650 -41, -41, -41, -41, -41, -41, -41, -41
651 },
652
653 {
654 11, 86, 86, -42, 86, 86, 86, 86, 86, 86,
655 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
656
657 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
658 86, 86, 86, 86, 86, 86, 86, 86
659 },
660
661 {
662 11, -43, -43, -43, -43, -43, -43, 87, -43, -43,
663 -43, -43, -43, -43, -43, -43, -43, -43, -43, -43,
664 -43, -43, -43, -43, -43, -43, -43, -43, -43, -43,
665 -43, -43, -43, -43, -43, -43, -43, -43
666 },
667
668 {
669 11, -44, -44, -44, -44, -44, -44, -44, -44, -44,
670 -44, -44, -44, -44, -44, -44, -44, -44, -44, -44,
671 -44, -44, -44, -44, -44, -44, -44, -44, -44, -44,
672 -44, -44, -44, -44, -44, -44, -44, -44
673
674 },
675
676 {
677 11, -45, -45, -45, -45, -45, -45, -45, -45, -45,
678 -45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
679 -45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
680 -45, -45, -45, -45, -45, -45, -45, -45
681 },
682
683 {
684 11, -46, -46, -46, -46, -46, -46, -46, -46, -46,
685 -46, 88, 89, 89, -46, -46, 89, 89, 89, 89,
686 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
687 89, 89, 89, 89, 89, 89, 89, -46
688 },
689
690 {
691 11, -47, -47, -47, -47, -47, -47, -47, -47, -47,
692 -47, 89, 89, 89, -47, -47, 89, 89, 89, 89,
693
694 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
695 89, 89, 89, 89, 89, 89, 89, -47
696 },
697
698 {
699 11, -48, -48, -48, -48, -48, -48, -48, -48, -48,
700 -48, -48, -48, -48, -48, -48, -48, -48, -48, -48,
701 -48, -48, -48, -48, -48, -48, -48, -48, -48, -48,
702 -48, -48, -48, -48, -48, -48, -48, -48
703 },
704
705 {
706 11, -49, -49, 90, -49, -49, -49, -49, -49, -49,
707 -49, -49, -49, -49, -49, -49, -49, -49, -49, -49,
708 -49, -49, -49, -49, -49, -49, -49, -49, -49, -49,
709 -49, -49, -49, -49, -49, -49, -49, -49
710
711 },
712
713 {
714 11, -50, -50, -50, -50, -50, -50, -50, -50, -50,
715 -50, 89, 89, 89, -50, -50, 89, 89, 89, 89,
716 89, 89, 91, 89, 89, 89, 89, 89, 89, 89,
717 89, 89, 89, 89, 89, 89, 89, -50
718 },
719
720 {
721 11, -51, -51, -51, -51, -51, -51, -51, -51, -51,
722 -51, 89, 89, 89, -51, -51, 89, 89, 89, 89,
723 89, 89, 89, 89, 89, 89, 89, 89, 92, 89,
724 89, 89, 89, 89, 89, 89, 89, -51
725 },
726
727 {
728 11, -52, -52, -52, -52, -52, -52, -52, -52, -52,
729 -52, -52, -52, -52, -52, -52, -52, -52, -52, -52,
730
731 -52, -52, -52, -52, -52, -52, -52, -52, -52, -52,
732 -52, -52, -52, -52, -52, -52, -52, 93
733 },
734
735 {
736 11, -53, 53, 54, -53, -53, 55, -53, -53, -53,
737 -53, -53, -53, -53, -53, -53, -53, -53, -53, -53,
738 -53, -53, -53, -53, -53, -53, -53, -53, -53, -53,
739 -53, -53, -53, -53, -53, -53, -53, -53
740 },
741
742 {
743 11, -54, -54, -54, -54, -54, -54, -54, -54, -54,
744 -54, -54, -54, -54, -54, -54, -54, -54, -54, -54,
745 -54, -54, -54, -54, -54, -54, -54, -54, -54, -54,
746 -54, -54, -54, -54, -54, -54, -54, -54
747
748 },
749
750 {
751 11, 56, 56, 57, 56, 56, 56, 56, 56, 56,
752 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
753 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
754 56, 56, 56, 56, 56, 56, 56, 56
755 },
756
757 {
758 11, 56, 56, 57, 56, 56, 56, 56, 56, 56,
759 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
760 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
761 56, 56, 56, 56, 56, 56, 56, 56
762 },
763
764 {
765 11, -57, -57, -57, -57, -57, -57, -57, -57, -57,
766 -57, -57, -57, -57, -57, -57, -57, -57, -57, -57,
767
768 -57, -57, -57, -57, -57, -57, -57, -57, -57, -57,
769 -57, -57, -57, -57, -57, -57, -57, -57
770 },
771
772 {
773 11, -58, -58, -58, -58, -58, -58, -58, -58, -58,
774 -58, -58, -58, 58, -58, -58, 58, 58, 58, 58,
775 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
776 58, 58, 58, 58, 58, 58, 58, -58
777 },
778
779 {
780 11, -59, -59, -59, -59, -59, -59, -59, -59, -59,
781 -59, -59, -59, 58, -59, -59, 58, 58, 58, 58,
782 58, 58, 58, 58, 58, 58, 58, 58, 58, 94,
783 58, 58, 58, 58, 58, 58, 58, -59
784
785 },
786
787 {
788 11, -60, -60, -60, -60, -60, -60, -60, -60, -60,
789 -60, -60, -60, 58, -60, -60, 58, 58, 58, 58,
790 58, 58, 58, 58, 58, 58, 58, 58, 58, 95,
791 58, 58, 58, 58, 58, 58, 58, -60
792 },
793
794 {
795 11, -61, -61, -61, -61, -61, -61, -61, -61, -61,
796 -61, -61, -61, 58, -61, -61, 58, 58, 58, 58,
797 58, 58, 58, 58, 58, 58, 58, 96, 97, 58,
798 58, 58, 58, 58, 58, 58, 58, -61
799 },
800
801 {
802 11, -62, -62, -62, -62, -62, -62, -62, -62, -62,
803 -62, -62, -62, 58, -62, -62, 58, 58, 58, 58,
804
805 58, 58, 98, 58, 58, 58, 58, 58, 58, 58,
806 99, 58, 58, 58, 58, 58, 58, -62
807 },
808
809 {
810 11, -63, -63, -63, -63, -63, -63, -63, -63, -63,
811 -63, -63, -63, 58, -63, -63, 58, 100, 58, 58,
812 101, 58, 58, 58, 58, 58, 58, 58, 58, 58,
813 58, 58, 58, 58, 58, 58, 58, -63
814 },
815
816 {
817 11, -64, -64, -64, -64, -64, -64, -64, -64, -64,
818 -64, -64, -64, 58, -64, -64, 58, 58, 58, 58,
819 58, 58, 58, 58, 58, 58, 102, 58, 58, 58,
820 58, 58, 58, 58, 58, 58, 103, -64
821
822 },
823
824 {
825 11, -65, -65, -65, -65, -65, -65, -65, -65, -65,
826 -65, -65, -65, 58, -65, -65, 58, 58, 58, 58,
827 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
828 58, 58, 58, 58, 58, 58, 58, -65
829 },
830
831 {
832 11, -66, -66, -66, -66, -66, -66, -66, -66, -66,
833 -66, -66, -66, 58, -66, -66, 58, 58, 58, 58,
834 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
835 58, 58, 58, 58, 104, 58, 58, -66
836 },
837
838 {
839 11, -67, -67, -67, -67, -67, -67, -67, -67, -67,
840 -67, -67, -67, 58, -67, -67, 58, 58, 58, 58,
841
842 58, 58, 58, 58, 58, 105, 58, 58, 58, 58,
843 58, 58, 58, 58, 58, 58, 58, -67
844 },
845
846 {
847 11, -68, -68, -68, -68, -68, -68, -68, -68, -68,
848 -68, -68, -68, 58, -68, -68, 58, 58, 58, 58,
849 58, 58, 58, 58, 58, 58, 58, 58, 106, 58,
850 58, 58, 58, 58, 58, 58, 58, -68
851 },
852
853 {
854 11, -69, -69, -69, -69, -69, -69, -69, -69, -69,
855 -69, -69, -69, 58, -69, -69, 58, 58, 58, 58,
856 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
857 58, 58, 58, 58, 107, 58, 58, -69
858
859 },
860
861 {
862 11, -70, -70, -70, -70, -70, -70, -70, -70, -70,
863 -70, -70, -70, 58, -70, -70, 58, 58, 58, 58,
864 58, 58, 58, 58, 58, 58, 58, 58, 58, 108,
865 58, 58, 58, 58, 58, 58, 58, -70
866 },
867
868 {
869 11, -71, -71, -71, -71, -71, -71, -71, -71, -71,
870 -71, -71, -71, 58, -71, -71, 58, 58, 58, 58,
871 58, 58, 58, 58, 58, 58, 58, 58, 109, 58,
872 58, 58, 58, 58, 58, 58, 58, -71
873 },
874
875 {
876 11, -72, -72, -72, -72, -72, -72, -72, -72, -72,
877 -72, -72, -72, 58, -72, -72, 58, 58, 58, 58,
878
879 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
880 58, 110, 58, 58, 58, 58, 58, -72
881 },
882
883 {
884 11, -73, -73, -73, -73, -73, -73, -73, -73, -73,
885 -73, -73, -73, 58, -73, -73, 58, 58, 58, 58,
886 58, 58, 58, 58, 58, 58, 111, 58, 58, 58,
887 58, 58, 58, 58, 58, 58, 58, -73
888 },
889
890 {
891 11, -74, -74, -74, -74, -74, -74, -74, -74, -74,
892 -74, -74, -74, 58, -74, -74, 58, 58, 58, 58,
893 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
894 58, 58, 58, 58, 58, 112, 58, -74
895
896 },
897
898 {
899 11, -75, -75, -75, -75, -75, -75, -75, -75, -75,
900 -75, -75, -75, 58, -75, -75, 58, 58, 58, 58,
901 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
902 58, 58, 113, 58, 58, 58, 58, -75
903 },
904
905 {
906 11, -76, -76, -76, -76, -76, -76, -76, -76, -76,
907 -76, -76, -76, 58, -76, -76, 58, 58, 58, 58,
908 58, 58, 58, 58, 58, 114, 58, 58, 58, 58,
909 58, 58, 58, 58, 58, 58, 58, -76
910 },
911
912 {
913 11, 77, 77, -77, 77, 77, 77, 77, 77, 77,
914 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
915
916 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
917 77, 77, 77, 77, 77, 77, 77, 77
918 },
919
920 {
921 11, -78, 78, 79, -78, -78, -78, -78, -78, -78,
922 -78, -78, -78, -78, -78, -78, -78, -78, -78, -78,
923 -78, -78, -78, -78, -78, -78, -78, -78, -78, -78,
924 -78, -78, -78, -78, -78, -78, -78, -78
925 },
926
927 {
928 11, 80, -79, -79, 80, 80, 80, 80, 80, 80,
929 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
930 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
931 80, 80, 80, 80, 80, 80, 80, 80
932
933 },
934
935 {
936 11, -80, -80, -80, -80, -80, -80, -80, -80, -80,
937 -80, -80, -80, -80, -80, -80, -80, -80, -80, -80,
938 -80, -80, -80, -80, -80, -80, -80, -80, -80, -80,
939 -80, -80, -80, -80, -80, -80, -80, -80
940 },
941
942 {
943 11, 81, 81, 82, 81, -81, 81, 81, -81, 81,
944 81, 81, 81, 81, 81, -81, 81, 81, 81, 81,
945 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
946 81, 81, 81, 81, 81, 81, 81, 81
947 },
948
949 {
950 11, -82, -82, -82, -82, -82, -82, -82, -82, -82,
951 -82, -82, -82, -82, -82, -82, -82, -82, -82, -82,
952
953 -82, -82, -82, -82, -82, -82, -82, -82, -82, -82,
954 -82, -82, -82, -82, -82, -82, -82, -82
955 },
956
957 {
958 11, -83, -83, 84, -83, -83, -83, -83, -83, -83,
959 -83, -83, -83, -83, -83, -83, -83, -83, -83, -83,
960 -83, -83, -83, -83, -83, -83, -83, -83, -83, -83,
961 -83, -83, -83, -83, -83, -83, -83, -83
962 },
963
964 {
965 11, -84, -84, -84, -84, -84, -84, -84, -84, -84,
966 -84, -84, -84, -84, -84, -84, -84, -84, -84, -84,
967 -84, -84, -84, -84, -84, -84, -84, -84, -84, -84,
968 -84, -84, -84, -84, -84, -84, -84, -84
969
970 },
971
972 {
973 11, -85, -85, -85, -85, -85, -85, -85, -85, -85,
974 -85, -85, -85, -85, -85, -85, -85, -85, -85, -85,
975 -85, -85, -85, -85, -85, -85, -85, -85, -85, -85,
976 -85, -85, -85, -85, -85, -85, -85, -85
977 },
978
979 {
980 11, 86, 86, -86, 86, 86, 86, 86, 86, 86,
981 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
982 86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
983 86, 86, 86, 86, 86, 86, 86, 86
984 },
985
986 {
987 11, -87, -87, -87, -87, -87, -87, -87, -87, -87,
988 -87, -87, -87, -87, -87, -87, -87, -87, -87, -87,
989
990 -87, -87, -87, -87, -87, -87, -87, -87, -87, -87,
991 -87, -87, -87, -87, -87, -87, -87, -87
992 },
993
994 {
995 11, -88, -88, -88, -88, -88, -88, -88, -88, -88,
996 -88, 115, 89, 89, -88, -88, 89, 89, 89, 89,
997 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
998 89, 89, 89, 89, 89, 89, 89, -88
999 },
1000
1001 {
1002 11, -89, -89, -89, -89, -89, -89, -89, -89, -89,
1003 -89, 89, 89, 89, -89, -89, 89, 89, 89, 89,
1004 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
1005 89, 89, 89, 89, 89, 89, 89, -89
1006
1007 },
1008
1009 {
1010 11, -90, -90, -90, -90, -90, -90, -90, -90, -90,
1011 -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
1012 -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
1013 -90, -90, -90, -90, -90, -90, -90, -90
1014 },
1015
1016 {
1017 11, -91, -91, -91, -91, -91, -91, -91, -91, -91,
1018 -91, 89, 89, 89, -91, -91, 89, 89, 89, 89,
1019 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
1020 89, 89, 89, 89, 89, 89, 89, -91
1021 },
1022
1023 {
1024 11, -92, -92, -92, -92, -92, -92, -92, -92, -92,
1025 -92, 89, 89, 89, -92, -92, 89, 89, 89, 89,
1026
1027 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
1028 89, 89, 89, 89, 89, 89, 89, -92
1029 },
1030
1031 {
1032 11, -93, -93, -93, -93, -93, -93, -93, -93, -93,
1033 -93, -93, -93, -93, -93, -93, -93, -93, -93, -93,
1034 -93, -93, -93, -93, -93, -93, -93, -93, -93, -93,
1035 -93, -93, -93, -93, -93, -93, -93, -93
1036 },
1037
1038 {
1039 11, -94, -94, -94, -94, -94, -94, -94, -94, -94,
1040 -94, -94, -94, 58, -94, -94, 58, 58, 58, 58,
1041 58, 58, 58, 58, 58, 58, 116, 58, 58, 58,
1042 58, 58, 58, 58, 58, 58, 58, -94
1043
1044 },
1045
1046 {
1047 11, -95, -95, -95, -95, -95, -95, -95, -95, -95,
1048 -95, -95, -95, 58, -95, -95, 58, 58, 58, 58,
1049 58, 58, 58, 58, 58, 117, 58, 58, 58, 58,
1050 58, 58, 58, 58, 58, 58, 58, -95
1051 },
1052
1053 {
1054 11, -96, -96, -96, -96, -96, -96, -96, -96, -96,
1055 -96, -96, -96, 58, -96, -96, 58, 58, 58, 58,
1056 58, 58, 58, 58, 58, 58, 58, 118, 58, 58,
1057 58, 58, 58, 58, 58, 58, 58, -96
1058 },
1059
1060 {
1061 11, -97, -97, -97, -97, -97, -97, -97, -97, -97,
1062 -97, -97, -97, 58, -97, -97, 58, 58, 58, 58,
1063
1064 58, 58, 119, 58, 58, 58, 58, 58, 58, 58,
1065 58, 58, 58, 58, 58, 58, 58, -97
1066 },
1067
1068 {
1069 11, -98, -98, -98, -98, -98, -98, -98, -98, -98,
1070 -98, -98, -98, 58, -98, -98, 120, 121, 58, 58,
1071 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1072 58, 58, 58, 58, 58, 58, 58, -98
1073 },
1074
1075 {
1076 11, -99, -99, -99, -99, -99, -99, -99, -99, -99,
1077 -99, -99, -99, 58, -99, -99, 58, 58, 58, 58,
1078 58, 122, 58, 58, 58, 58, 58, 58, 58, 58,
1079 58, 58, 58, 58, 58, 58, 58, -99
1080
1081 },
1082
1083 {
1084 11, -100, -100, -100, -100, -100, -100, -100, -100, -100,
1085 -100, -100, -100, 58, -100, -100, 58, 58, 123, 58,
1086 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1087 58, 58, 58, 58, 58, 58, 58, -100
1088 },
1089
1090 {
1091 11, -101, -101, -101, -101, -101, -101, -101, -101, -101,
1092 -101, -101, -101, 58, -101, -101, 58, 58, 58, 124,
1093 58, 58, 58, 58, 58, 125, 58, 126, 58, 58,
1094 58, 58, 58, 58, 58, 58, 58, -101
1095 },
1096
1097 {
1098 11, -102, -102, -102, -102, -102, -102, -102, -102, -102,
1099 -102, -102, -102, 58, -102, -102, 58, 58, 58, 58,
1100
1101 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1102 127, 58, 58, 58, 58, 58, 58, -102
1103 },
1104
1105 {
1106 11, -103, -103, -103, -103, -103, -103, -103, -103, -103,
1107 -103, -103, -103, 58, -103, -103, 58, 58, 58, 58,
1108 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1109 58, 58, 58, 58, 58, 58, 58, -103
1110 },
1111
1112 {
1113 11, -104, -104, -104, -104, -104, -104, -104, -104, -104,
1114 -104, -104, -104, 58, -104, -104, 58, 58, 58, 58,
1115 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1116 58, 58, 58, 58, 58, 58, 58, -104
1117
1118 },
1119
1120 {
1121 11, -105, -105, -105, -105, -105, -105, -105, -105, -105,
1122 -105, -105, -105, 58, -105, -105, 58, 58, 58, 58,
1123 58, 58, 58, 58, 58, 58, 58, 58, 128, 58,
1124 58, 58, 58, 58, 58, 58, 58, -105
1125 },
1126
1127 {
1128 11, -106, -106, -106, -106, -106, -106, -106, -106, -106,
1129 -106, -106, -106, 58, -106, -106, 58, 58, 58, 58,
1130 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1131 58, 58, 58, 58, 58, 129, 58, -106
1132 },
1133
1134 {
1135 11, -107, -107, -107, -107, -107, -107, -107, -107, -107,
1136 -107, -107, -107, 58, -107, -107, 58, 58, 58, 58,
1137
1138 58, 58, 58, 58, 58, 130, 58, 58, 58, 58,
1139 58, 58, 58, 58, 58, 58, 58, -107
1140 },
1141
1142 {
1143 11, -108, -108, -108, -108, -108, -108, -108, -108, -108,
1144 -108, -108, -108, 58, -108, -108, 58, 58, 58, 58,
1145 58, 58, 58, 58, 58, 58, 58, 131, 58, 58,
1146 58, 58, 58, 58, 58, 58, 58, -108
1147 },
1148
1149 {
1150 11, -109, -109, -109, -109, -109, -109, -109, -109, -109,
1151 -109, -109, -109, 58, -109, -109, 58, 58, 58, 58,
1152 58, 58, 58, 132, 58, 58, 58, 58, 58, 58,
1153 58, 58, 58, 58, 58, 58, 58, -109
1154
1155 },
1156
1157 {
1158 11, -110, -110, -110, -110, -110, -110, -110, -110, -110,
1159 -110, -110, -110, 58, -110, -110, 58, 58, 58, 58,
1160 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1161 58, 58, 58, 58, 58, 133, 58, -110
1162 },
1163
1164 {
1165 11, -111, -111, -111, -111, -111, -111, -111, -111, -111,
1166 -111, -111, -111, 58, -111, -111, 58, 58, 58, 58,
1167 58, 134, 58, 58, 58, 58, 58, 58, 58, 58,
1168 58, 58, 58, 58, 58, 58, 58, -111
1169 },
1170
1171 {
1172 11, -112, -112, -112, -112, -112, -112, -112, -112, -112,
1173 -112, -112, -112, 58, -112, -112, 58, 58, 58, 58,
1174
1175 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1176 58, 58, 135, 58, 58, 58, 58, -112
1177 },
1178
1179 {
1180 11, -113, -113, -113, -113, -113, -113, -113, -113, -113,
1181 -113, -113, -113, 58, -113, -113, 58, 58, 58, 58,
1182 58, 58, 58, 58, 58, 136, 58, 58, 58, 58,
1183 58, 58, 58, 58, 58, 58, 58, -113
1184 },
1185
1186 {
1187 11, -114, -114, -114, -114, -114, -114, -114, -114, -114,
1188 -114, -114, -114, 58, -114, -114, 58, 58, 58, 58,
1189 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1190 58, 58, 58, 137, 58, 58, 58, -114
1191
1192 },
1193
1194 {
1195 11, -115, -115, -115, -115, -115, -115, -115, -115, -115,
1196 -115, 89, 89, 89, -115, -115, 89, 89, 89, 89,
1197 89, 89, 89, 89, 89, 89, 89, 89, 89, 89,
1198 89, 89, 89, 89, 89, 89, 89, -115
1199 },
1200
1201 {
1202 11, -116, -116, -116, -116, -116, -116, -116, -116, -116,
1203 -116, -116, -116, 58, -116, -116, 58, 58, 58, 58,
1204 58, 138, 58, 58, 58, 58, 58, 58, 58, 58,
1205 58, 58, 58, 58, 58, 58, 58, -116
1206 },
1207
1208 {
1209 11, -117, -117, -117, -117, -117, -117, -117, -117, -117,
1210 -117, -117, -117, 58, -117, -117, 58, 58, 58, 139,
1211
1212 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1213 58, 58, 58, 58, 58, 58, 58, -117
1214 },
1215
1216 {
1217 11, -118, -118, -118, -118, -118, -118, -118, -118, -118,
1218 -118, -118, -118, 58, -118, -118, 58, 58, 58, 58,
1219 58, 140, 58, 58, 58, 58, 58, 58, 58, 58,
1220 58, 58, 58, 58, 58, 58, 58, -118
1221 },
1222
1223 {
1224 11, -119, -119, -119, -119, -119, -119, -119, -119, -119,
1225 -119, -119, -119, 58, -119, -119, 58, 58, 58, 58,
1226 58, 58, 58, 58, 58, 141, 58, 58, 58, 58,
1227 58, 58, 58, 58, 58, 58, 58, -119
1228
1229 },
1230
1231 {
1232 11, -120, -120, -120, -120, -120, -120, -120, -120, -120,
1233 -120, -120, -120, 58, -120, -120, 58, 58, 142, 58,
1234 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1235 58, 58, 58, 58, 143, 58, 58, -120
1236 },
1237
1238 {
1239 11, -121, -121, -121, -121, -121, -121, -121, -121, -121,
1240 -121, -121, -121, 58, -121, -121, 58, 58, 58, 58,
1241 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1242 58, 58, 58, 58, 58, 144, 58, -121
1243 },
1244
1245 {
1246 11, -122, -122, -122, -122, -122, -122, -122, -122, -122,
1247 -122, -122, -122, 58, -122, -122, 58, 58, 58, 58,
1248
1249 58, 58, 58, 58, 58, 58, 58, 58, 145, 58,
1250 58, 58, 58, 58, 58, 58, 58, -122
1251 },
1252
1253 {
1254 11, -123, -123, -123, -123, -123, -123, -123, -123, -123,
1255 -123, -123, -123, 58, -123, -123, 58, 58, 58, 58,
1256 58, 58, 58, 58, 58, 58, 146, 58, 58, 58,
1257 58, 58, 58, 58, 58, 58, 58, -123
1258 },
1259
1260 {
1261 11, -124, -124, -124, -124, -124, -124, -124, -124, -124,
1262 -124, -124, -124, 58, -124, -124, 58, 58, 58, 58,
1263 58, 58, 58, 58, 147, 58, 58, 58, 58, 58,
1264 58, 58, 58, 58, 58, 58, 58, -124
1265
1266 },
1267
1268 {
1269 11, -125, -125, -125, -125, -125, -125, -125, -125, -125,
1270 -125, -125, -125, 58, -125, -125, 58, 58, 58, 58,
1271 58, 58, 148, 58, 58, 58, 58, 58, 58, 58,
1272 58, 58, 58, 58, 58, 58, 58, -125
1273 },
1274
1275 {
1276 11, -126, -126, -126, -126, -126, -126, -126, -126, -126,
1277 -126, -126, -126, 58, -126, -126, 58, 58, 58, 58,
1278 58, 149, 58, 58, 58, 58, 58, 58, 58, 58,
1279 58, 58, 58, 58, 58, 58, 58, -126
1280 },
1281
1282 {
1283 11, -127, -127, -127, -127, -127, -127, -127, -127, -127,
1284 -127, -127, -127, 58, -127, -127, 58, 58, 58, 58,
1285
1286 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1287 58, 58, 58, 58, 58, 58, 58, -127
1288 },
1289
1290 {
1291 11, -128, -128, -128, -128, -128, -128, -128, -128, -128,
1292 -128, -128, -128, 58, -128, -128, 58, 58, 58, 58,
1293 58, 58, 58, 58, 58, 58, 58, 150, 58, 58,
1294 58, 58, 58, 58, 58, 58, 58, -128
1295 },
1296
1297 {
1298 11, -129, -129, -129, -129, -129, -129, -129, -129, -129,
1299 -129, -129, -129, 58, -129, -129, 58, 58, 58, 151,
1300 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1301 58, 58, 58, 58, 58, 58, 58, -129
1302
1303 },
1304
1305 {
1306 11, -130, -130, -130, -130, -130, -130, -130, -130, -130,
1307 -130, -130, -130, 58, -130, -130, 58, 58, 58, 58,
1308 58, 58, 58, 58, 58, 58, 58, 58, 58, 152,
1309 58, 58, 58, 58, 58, 58, 58, -130
1310 },
1311
1312 {
1313 11, -131, -131, -131, -131, -131, -131, -131, -131, -131,
1314 -131, -131, -131, 58, -131, -131, 58, 58, 58, 58,
1315 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1316 153, 58, 58, 58, 58, 58, 58, -131
1317 },
1318
1319 {
1320 11, -132, -132, -132, -132, -132, -132, -132, -132, -132,
1321 -132, -132, -132, 58, -132, -132, 58, 58, 58, 58,
1322
1323 58, 154, 58, 58, 58, 58, 58, 58, 58, 58,
1324 58, 58, 58, 58, 58, 58, 58, -132
1325 },
1326
1327 {
1328 11, -133, -133, -133, -133, -133, -133, -133, -133, -133,
1329 -133, -133, -133, 58, -133, -133, 58, 58, 58, 58,
1330 58, 58, 58, 58, 58, 155, 58, 58, 58, 58,
1331 58, 58, 58, 58, 58, 58, 58, -133
1332 },
1333
1334 {
1335 11, -134, -134, -134, -134, -134, -134, -134, -134, -134,
1336 -134, -134, -134, 58, -134, -134, 58, 58, 58, 156,
1337 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1338 58, 58, 58, 58, 58, 58, 58, -134
1339
1340 },
1341
1342 {
1343 11, -135, -135, -135, -135, -135, -135, -135, -135, -135,
1344 -135, -135, -135, 58, -135, -135, 58, 58, 58, 157,
1345 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1346 58, 58, 58, 58, 58, 58, 58, -135
1347 },
1348
1349 {
1350 11, -136, -136, -136, -136, -136, -136, -136, -136, -136,
1351 -136, -136, -136, 58, -136, -136, 58, 58, 58, 58,
1352 58, 58, 58, 58, 58, 58, 58, 58, 158, 58,
1353 58, 58, 58, 58, 58, 58, 58, -136
1354 },
1355
1356 {
1357 11, -137, -137, -137, -137, -137, -137, -137, -137, -137,
1358 -137, -137, -137, 58, -137, -137, 58, 58, 58, 58,
1359
1360 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1361 58, 58, 58, 58, 159, 58, 58, -137
1362 },
1363
1364 {
1365 11, -138, -138, -138, -138, -138, -138, -138, -138, -138,
1366 -138, -138, -138, 58, -138, -138, 58, 160, 58, 58,
1367 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1368 58, 58, 58, 58, 58, 58, 58, -138
1369 },
1370
1371 {
1372 11, -139, -139, -139, -139, -139, -139, -139, -139, -139,
1373 -139, -139, -139, 58, -139, -139, 58, 58, 58, 58,
1374 58, 161, 58, 58, 58, 58, 58, 58, 58, 58,
1375 58, 58, 58, 58, 58, 58, 58, -139
1376
1377 },
1378
1379 {
1380 11, -140, -140, -140, -140, -140, -140, -140, -140, -140,
1381 -140, -140, -140, 58, -140, -140, 58, 58, 58, 58,
1382 58, 58, 58, 58, 58, 58, 58, 58, 162, 58,
1383 58, 58, 58, 58, 58, 58, 58, -140
1384 },
1385
1386 {
1387 11, -141, -141, -141, -141, -141, -141, -141, -141, -141,
1388 -141, -141, -141, 58, -141, -141, 58, 58, 58, 58,
1389 58, 58, 58, 163, 58, 58, 58, 58, 58, 58,
1390 58, 58, 58, 58, 58, 58, 58, -141
1391 },
1392
1393 {
1394 11, -142, -142, -142, -142, -142, -142, -142, -142, -142,
1395 -142, -142, -142, 58, -142, -142, 58, 58, 58, 58,
1396
1397 58, 58, 58, 58, 58, 58, 58, 58, 58, 164,
1398 58, 58, 58, 58, 58, 58, 58, -142
1399 },
1400
1401 {
1402 11, -143, -143, -143, -143, -143, -143, -143, -143, -143,
1403 -143, -143, -143, 58, -143, -143, 58, 58, 58, 58,
1404 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1405 58, 58, 165, 58, 58, 58, 58, -143
1406 },
1407
1408 {
1409 11, -144, -144, -144, -144, -144, -144, -144, -144, -144,
1410 -144, -144, -144, 58, -144, -144, 58, 58, 58, 58,
1411 58, 58, 58, 58, 58, 58, 166, 58, 58, 58,
1412 58, 58, 58, 58, 58, 58, 58, -144
1413
1414 },
1415
1416 {
1417 11, -145, -145, -145, -145, -145, -145, -145, -145, -145,
1418 -145, -145, -145, 58, -145, -145, 58, 58, 58, 58,
1419 167, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1420 58, 58, 58, 58, 58, 58, 58, -145
1421 },
1422
1423 {
1424 11, -146, -146, -146, -146, -146, -146, -146, -146, -146,
1425 -146, -146, -146, 58, -146, -146, 58, 58, 58, 58,
1426 58, 168, 58, 58, 58, 58, 58, 58, 58, 58,
1427 58, 58, 58, 58, 58, 58, 58, -146
1428 },
1429
1430 {
1431 11, -147, -147, -147, -147, -147, -147, -147, -147, -147,
1432 -147, -147, -147, 58, -147, -147, 58, 58, 58, 58,
1433
1434 58, 58, 58, 58, 58, 58, 58, 58, 58, 169,
1435 58, 58, 58, 58, 58, 58, 58, -147
1436 },
1437
1438 {
1439 11, -148, -148, -148, -148, -148, -148, -148, -148, -148,
1440 -148, -148, -148, 58, -148, -148, 58, 58, 58, 58,
1441 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1442 58, 58, 58, 58, 58, 58, 58, -148
1443 },
1444
1445 {
1446 11, -149, -149, -149, -149, -149, -149, -149, -149, -149,
1447 -149, -149, -149, 58, -149, -149, 58, 58, 58, 58,
1448 58, 58, 58, 58, 58, 58, 58, 58, 170, 58,
1449 58, 58, 58, 58, 58, 58, 58, -149
1450
1451 },
1452
1453 {
1454 11, -150, -150, -150, -150, -150, -150, -150, -150, -150,
1455 -150, -150, -150, 58, -150, -150, 58, 58, 58, 58,
1456 58, 171, 58, 58, 58, 58, 58, 58, 58, 58,
1457 58, 58, 58, 58, 58, 58, 58, -150
1458 },
1459
1460 {
1461 11, -151, -151, -151, -151, -151, -151, -151, -151, -151,
1462 -151, -151, -151, 58, -151, -151, 58, 58, 58, 58,
1463 58, 58, 58, 58, 58, 58, 58, 58, 58, 172,
1464 58, 58, 58, 58, 58, 58, 58, -151
1465 },
1466
1467 {
1468 11, -152, -152, -152, -152, -152, -152, -152, -152, -152,
1469 -152, -152, -152, 58, -152, -152, 58, 58, 58, 58,
1470
1471 58, 58, 58, 58, 58, 58, 58, 58, 173, 58,
1472 58, 58, 58, 58, 58, 58, 58, -152
1473 },
1474
1475 {
1476 11, -153, -153, -153, -153, -153, -153, -153, -153, -153,
1477 -153, -153, -153, 58, -153, -153, 58, 58, 58, 58,
1478 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1479 58, 58, 58, 58, 174, 58, 58, -153
1480 },
1481
1482 {
1483 11, -154, -154, -154, -154, -154, -154, -154, -154, -154,
1484 -154, -154, -154, 58, -154, -154, 58, 58, 58, 58,
1485 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1486 58, 58, 58, 58, 58, 58, 58, -154
1487
1488 },
1489
1490 {
1491 11, -155, -155, -155, -155, -155, -155, -155, -155, -155,
1492 -155, -155, -155, 58, -155, -155, 58, 58, 58, 58,
1493 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1494 58, 58, 175, 58, 58, 58, 58, -155
1495 },
1496
1497 {
1498 11, -156, -156, -156, -156, -156, -156, -156, -156, -156,
1499 -156, -156, -156, 58, -156, -156, 58, 58, 58, 58,
1500 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1501 58, 58, 58, 58, 176, 58, 58, -156
1502 },
1503
1504 {
1505 11, -157, -157, -157, -157, -157, -157, -157, -157, -157,
1506 -157, -157, -157, 58, -157, -157, 58, 58, 58, 58,
1507
1508 58, 177, 58, 58, 58, 58, 58, 58, 58, 58,
1509 58, 58, 58, 58, 58, 58, 58, -157
1510 },
1511
1512 {
1513 11, -158, -158, -158, -158, -158, -158, -158, -158, -158,
1514 -158, -158, -158, 58, -158, -158, 58, 58, 58, 58,
1515 58, 58, 58, 178, 58, 58, 58, 58, 58, 58,
1516 58, 58, 58, 58, 58, 58, 58, -158
1517 },
1518
1519 {
1520 11, -159, -159, -159, -159, -159, -159, -159, -159, -159,
1521 -159, -159, -159, 58, -159, -159, 58, 179, 58, 58,
1522 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1523 58, 58, 58, 58, 58, 58, 58, -159
1524
1525 },
1526
1527 {
1528 11, -160, -160, -160, -160, -160, -160, -160, -160, -160,
1529 -160, -160, -160, 58, -160, -160, 58, 58, 58, 58,
1530 58, 58, 58, 58, 58, 58, 58, 58, 180, 58,
1531 58, 58, 58, 58, 58, 58, 58, -160
1532 },
1533
1534 {
1535 11, -161, -161, -161, -161, -161, -161, -161, -161, -161,
1536 -161, -161, -161, 58, -161, -161, 58, 58, 58, 58,
1537 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1538 58, 58, 58, 58, 58, 58, 58, -161
1539 },
1540
1541 {
1542 11, -162, -162, -162, -162, -162, -162, -162, -162, -162,
1543 -162, -162, -162, 58, -162, -162, 58, 58, 58, 58,
1544
1545 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1546 58, 58, 58, 58, 181, 58, 58, -162
1547 },
1548
1549 {
1550 11, -163, -163, -163, -163, -163, -163, -163, -163, -163,
1551 -163, -163, -163, 58, -163, -163, 58, 58, 58, 58,
1552 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1553 58, 58, 58, 58, 58, 58, 58, -163
1554 },
1555
1556 {
1557 11, -164, -164, -164, -164, -164, -164, -164, -164, -164,
1558 -164, -164, -164, 58, -164, -164, 58, 58, 58, 58,
1559 58, 58, 58, 58, 58, 58, 58, 58, 58, 182,
1560 58, 58, 58, 58, 58, 58, 58, -164
1561
1562 },
1563
1564 {
1565 11, -165, -165, -165, -165, -165, -165, -165, -165, -165,
1566 -165, -165, -165, 58, -165, -165, 58, 58, 58, 58,
1567 58, 58, 58, 58, 58, 183, 58, 58, 58, 58,
1568 58, 58, 58, 58, 58, 58, 58, -165
1569 },
1570
1571 {
1572 11, -166, -166, -166, -166, -166, -166, -166, -166, -166,
1573 -166, -166, -166, 58, -166, -166, 58, 58, 58, 58,
1574 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1575 58, 58, 58, 58, 184, 58, 58, -166
1576 },
1577
1578 {
1579 11, -167, -167, -167, -167, -167, -167, -167, -167, -167,
1580 -167, -167, -167, 58, -167, -167, 58, 58, 58, 58,
1581
1582 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1583 58, 58, 58, 185, 58, 58, 58, -167
1584 },
1585
1586 {
1587 11, -168, -168, -168, -168, -168, -168, -168, -168, -168,
1588 -168, -168, -168, 58, -168, -168, 58, 58, 58, 58,
1589 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1590 58, 58, 58, 58, 58, 58, 58, -168
1591 },
1592
1593 {
1594 11, -169, -169, -169, -169, -169, -169, -169, -169, -169,
1595 -169, -169, -169, 58, -169, -169, 58, 58, 58, 58,
1596 58, 58, 58, 58, 58, 186, 58, 58, 58, 58,
1597 58, 58, 58, 58, 58, 58, 58, -169
1598
1599 },
1600
1601 {
1602 11, -170, -170, -170, -170, -170, -170, -170, -170, -170,
1603 -170, -170, -170, 58, -170, -170, 58, 58, 58, 58,
1604 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1605 58, 58, 58, 58, 58, 187, 58, -170
1606 },
1607
1608 {
1609 11, -171, -171, -171, -171, -171, -171, -171, -171, -171,
1610 -171, -171, -171, 58, -171, -171, 58, 58, 58, 58,
1611 58, 58, 58, 58, 58, 58, 58, 58, 188, 58,
1612 58, 58, 58, 58, 58, 58, 58, -171
1613 },
1614
1615 {
1616 11, -172, -172, -172, -172, -172, -172, -172, -172, -172,
1617 -172, -172, -172, 58, -172, -172, 58, 58, 58, 58,
1618
1619 58, 58, 58, 58, 58, 58, 58, 58, 189, 58,
1620 58, 58, 58, 58, 58, 58, 58, -172
1621 },
1622
1623 {
1624 11, -173, -173, -173, -173, -173, -173, -173, -173, -173,
1625 -173, -173, -173, 58, -173, -173, 58, 190, 58, 58,
1626 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1627 58, 58, 58, 58, 58, 58, 58, -173
1628 },
1629
1630 {
1631 11, -174, -174, -174, -174, -174, -174, -174, -174, -174,
1632 -174, -174, -174, 58, -174, -174, 58, 58, 58, 58,
1633 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1634 58, 58, 58, 58, 58, 58, 58, -174
1635
1636 },
1637
1638 {
1639 11, -175, -175, -175, -175, -175, -175, -175, -175, -175,
1640 -175, -175, -175, 58, -175, -175, 58, 58, 58, 58,
1641 58, 191, 58, 58, 58, 58, 58, 58, 58, 58,
1642 58, 58, 58, 58, 58, 58, 58, -175
1643 },
1644
1645 {
1646 11, -176, -176, -176, -176, -176, -176, -176, -176, -176,
1647 -176, -176, -176, 58, -176, -176, 58, 58, 58, 58,
1648 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1649 58, 58, 58, 58, 58, 58, 58, -176
1650 },
1651
1652 {
1653 11, -177, -177, -177, -177, -177, -177, -177, -177, -177,
1654 -177, -177, -177, 58, -177, -177, 58, 58, 58, 58,
1655
1656 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1657 58, 58, 58, 58, 58, 58, 58, -177
1658 },
1659
1660 {
1661 11, -178, -178, -178, -178, -178, -178, -178, -178, -178,
1662 -178, -178, -178, 58, -178, -178, 58, 58, 58, 58,
1663 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1664 58, 58, 58, 58, 58, 58, 58, -178
1665 },
1666
1667 {
1668 11, -179, -179, -179, -179, -179, -179, -179, -179, -179,
1669 -179, -179, -179, 58, -179, -179, 58, 58, 58, 58,
1670 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1671 58, 58, 58, 58, 192, 58, 58, -179
1672
1673 },
1674
1675 {
1676 11, -180, -180, -180, -180, -180, -180, -180, -180, -180,
1677 -180, -180, -180, 58, -180, -180, 58, 58, 58, 58,
1678 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1679 58, 58, 58, 58, 58, 58, 58, -180
1680 },
1681
1682 {
1683 11, -181, -181, -181, -181, -181, -181, -181, -181, -181,
1684 -181, -181, -181, 58, -181, -181, 58, 58, 58, 58,
1685 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1686 58, 58, 58, 58, 58, 58, 58, -181
1687 },
1688
1689 {
1690 11, -182, -182, -182, -182, -182, -182, -182, -182, -182,
1691 -182, -182, -182, 58, -182, -182, 58, 58, 58, 58,
1692
1693 58, 58, 58, 58, 58, 58, 193, 58, 58, 58,
1694 58, 58, 58, 58, 58, 58, 58, -182
1695 },
1696
1697 {
1698 11, -183, -183, -183, -183, -183, -183, -183, -183, -183,
1699 -183, -183, -183, 58, -183, -183, 58, 58, 58, 58,
1700 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1701 58, 58, 58, 194, 58, 58, 58, -183
1702 },
1703
1704 {
1705 11, -184, -184, -184, -184, -184, -184, -184, -184, -184,
1706 -184, -184, -184, 58, -184, -184, 58, 58, 58, 58,
1707 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1708 58, 58, 58, 58, 58, 58, 58, -184
1709
1710 },
1711
1712 {
1713 11, -185, -185, -185, -185, -185, -185, -185, -185, -185,
1714 -185, -185, -185, 58, -185, -185, 58, 58, 58, 58,
1715 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1716 58, 58, 58, 58, 58, 58, 58, -185
1717 },
1718
1719 {
1720 11, -186, -186, -186, -186, -186, -186, -186, -186, -186,
1721 -186, -186, -186, 58, -186, -186, 58, 58, 58, 195,
1722 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1723 58, 58, 58, 58, 58, 58, 58, -186
1724 },
1725
1726 {
1727 11, -187, -187, -187, -187, -187, -187, -187, -187, -187,
1728 -187, -187, -187, 58, -187, -187, 58, 58, 58, 58,
1729
1730 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1731 58, 58, 58, 58, 58, 58, 58, -187
1732 },
1733
1734 {
1735 11, -188, -188, -188, -188, -188, -188, -188, -188, -188,
1736 -188, -188, -188, 58, -188, -188, 58, 58, 58, 58,
1737 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1738 58, 58, 58, 58, 58, 196, 58, -188
1739 },
1740
1741 {
1742 11, -189, -189, -189, -189, -189, -189, -189, -189, -189,
1743 -189, -189, -189, 58, -189, -189, 58, 58, 58, 58,
1744 58, 58, 197, 58, 58, 58, 58, 58, 58, 58,
1745 58, 58, 58, 58, 58, 58, 58, -189
1746
1747 },
1748
1749 {
1750 11, -190, -190, -190, -190, -190, -190, -190, -190, -190,
1751 -190, -190, -190, 58, -190, -190, 58, 58, 58, 58,
1752 58, 58, 58, 58, 58, 58, 198, 58, 58, 58,
1753 58, 58, 58, 58, 58, 58, 58, -190
1754 },
1755
1756 {
1757 11, -191, -191, -191, -191, -191, -191, -191, -191, -191,
1758 -191, -191, -191, 58, -191, -191, 58, 58, 58, 58,
1759 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1760 58, 58, 58, 199, 58, 58, 58, -191
1761 },
1762
1763 {
1764 11, -192, -192, -192, -192, -192, -192, -192, -192, -192,
1765 -192, -192, -192, 58, -192, -192, 58, 58, 58, 58,
1766
1767 58, 200, 58, 58, 58, 58, 58, 58, 58, 58,
1768 58, 58, 58, 58, 58, 58, 58, -192
1769 },
1770
1771 {
1772 11, -193, -193, -193, -193, -193, -193, -193, -193, -193,
1773 -193, -193, -193, 58, -193, -193, 58, 58, 58, 58,
1774 58, 201, 58, 58, 58, 58, 58, 58, 58, 58,
1775 58, 58, 58, 58, 58, 58, 58, -193
1776 },
1777
1778 {
1779 11, -194, -194, -194, -194, -194, -194, -194, -194, -194,
1780 -194, -194, -194, 58, -194, -194, 58, 58, 58, 58,
1781 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1782 58, 58, 58, 58, 202, 58, 58, -194
1783
1784 },
1785
1786 {
1787 11, -195, -195, -195, -195, -195, -195, -195, -195, -195,
1788 -195, -195, -195, 58, -195, -195, 58, 58, 58, 58,
1789 58, 203, 58, 58, 58, 58, 58, 58, 58, 58,
1790 58, 58, 58, 58, 58, 58, 58, -195
1791 },
1792
1793 {
1794 11, -196, -196, -196, -196, -196, -196, -196, -196, -196,
1795 -196, -196, -196, 58, -196, -196, 58, 58, 58, 58,
1796 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1797 58, 58, 58, 58, 58, 58, 58, -196
1798 },
1799
1800 {
1801 11, -197, -197, -197, -197, -197, -197, -197, -197, -197,
1802 -197, -197, -197, 58, -197, -197, 58, 58, 58, 58,
1803
1804 58, 58, 58, 58, 58, 204, 58, 58, 58, 58,
1805 58, 58, 58, 58, 58, 58, 58, -197
1806 },
1807
1808 {
1809 11, -198, -198, -198, -198, -198, -198, -198, -198, -198,
1810 -198, -198, -198, 58, -198, -198, 58, 58, 58, 58,
1811 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1812 58, 58, 58, 58, 58, 58, 58, -198
1813 },
1814
1815 {
1816 11, -199, -199, -199, -199, -199, -199, -199, -199, -199,
1817 -199, -199, -199, 58, -199, -199, 58, 58, 58, 58,
1818 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1819 58, 58, 58, 58, 58, 58, 58, -199
1820
1821 },
1822
1823 {
1824 11, -200, -200, -200, -200, -200, -200, -200, -200, -200,
1825 -200, -200, -200, 58, -200, -200, 58, 58, 58, 58,
1826 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1827 58, 58, 58, 58, 58, 58, 58, -200
1828 },
1829
1830 {
1831 11, -201, -201, -201, -201, -201, -201, -201, -201, -201,
1832 -201, -201, -201, 58, -201, -201, 58, 205, 58, 58,
1833 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1834 58, 58, 58, 58, 58, 58, 58, -201
1835 },
1836
1837 {
1838 11, -202, -202, -202, -202, -202, -202, -202, -202, -202,
1839 -202, -202, -202, 58, -202, -202, 58, 206, 58, 58,
1840
1841 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1842 58, 58, 58, 58, 58, 58, 58, -202
1843 },
1844
1845 {
1846 11, -203, -203, -203, -203, -203, -203, -203, -203, -203,
1847 -203, -203, -203, 58, -203, -203, 58, 58, 58, 58,
1848 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1849 58, 58, 58, 58, 58, 58, 58, -203
1850 },
1851
1852 {
1853 11, -204, -204, -204, -204, -204, -204, -204, -204, -204,
1854 -204, -204, -204, 58, -204, -204, 58, 58, 58, 58,
1855 58, 58, 58, 207, 58, 58, 58, 58, 58, 58,
1856 58, 58, 58, 58, 58, 58, 58, -204
1857
1858 },
1859
1860 {
1861 11, -205, -205, -205, -205, -205, -205, -205, -205, -205,
1862 -205, -205, -205, 58, -205, -205, 58, 58, 58, 58,
1863 58, 58, 58, 58, 58, 58, 58, 58, 208, 58,
1864 58, 58, 58, 58, 58, 58, 58, -205
1865 },
1866
1867 {
1868 11, -206, -206, -206, -206, -206, -206, -206, -206, -206,
1869 -206, -206, -206, 58, -206, -206, 58, 58, 58, 58,
1870 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1871 58, 58, 58, 58, 209, 58, 58, -206
1872 },
1873
1874 {
1875 11, -207, -207, -207, -207, -207, -207, -207, -207, -207,
1876 -207, -207, -207, 58, -207, -207, 58, 58, 58, 58,
1877
1878 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1879 58, 58, 58, 58, 58, 58, 58, -207
1880 },
1881
1882 {
1883 11, -208, -208, -208, -208, -208, -208, -208, -208, -208,
1884 -208, -208, -208, 58, -208, -208, 58, 58, 58, 58,
1885 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1886 58, 58, 58, 58, 58, 58, 58, -208
1887 },
1888
1889 {
1890 11, -209, -209, -209, -209, -209, -209, -209, -209, -209,
1891 -209, -209, -209, 58, -209, -209, 58, 58, 58, 58,
1892 58, 210, 58, 58, 58, 58, 58, 58, 58, 58,
1893 58, 58, 58, 58, 58, 58, 58, -209
1894
1895 },
1896
1897 {
1898 11, -210, -210, -210, -210, -210, -210, -210, -210, -210,
1899 -210, -210, -210, 58, -210, -210, 58, 58, 58, 58,
1900 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
1901 58, 58, 58, 58, 58, 58, 58, -210
1902 },
1903
1904 } ;
1905
1906static yy_state_type yy_get_previous_state (void );
1907static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
1908static int yy_get_next_buffer (void );
1909static void yy_fatal_error (yyconst char msg[] );
1910
1911/* Done after the current pattern has been matched and before the
1912 * corresponding action - sets up zconftext.
1913 */
1914#define YY_DO_BEFORE_ACTION \
1915 (yytext_ptr) = yy_bp; \
1916 zconfleng = (size_t) (yy_cp - yy_bp); \
1917 (yy_hold_char) = *yy_cp; \
1918 *yy_cp = '\0'; \
1919 (yy_c_buf_p) = yy_cp;
1920
1921#define YY_NUM_RULES 64
1922#define YY_END_OF_BUFFER 65
1923/* This struct is not used in this scanner,
1924 but its presence is necessary. */
1925struct yy_trans_info
1926 {
1927 flex_int32_t yy_verify;
1928 flex_int32_t yy_nxt;
1929 };
1930static yyconst flex_int16_t yy_accept[211] =
1931 { 0,
1932 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1933 65, 5, 4, 3, 2, 36, 37, 35, 35, 35,
1934 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
1935 63, 60, 62, 55, 59, 58, 57, 53, 48, 42,
1936 47, 51, 53, 40, 41, 50, 50, 43, 53, 50,
1937 50, 53, 4, 3, 2, 2, 1, 35, 35, 35,
1938 35, 35, 35, 35, 16, 35, 35, 35, 35, 35,
1939 35, 35, 35, 35, 35, 35, 63, 60, 62, 61,
1940 55, 54, 57, 56, 44, 51, 38, 50, 50, 52,
1941 45, 46, 39, 35, 35, 35, 35, 35, 35, 35,
1942
1943 35, 35, 30, 29, 35, 35, 35, 35, 35, 35,
1944 35, 35, 35, 35, 49, 25, 35, 35, 35, 35,
1945 35, 35, 35, 35, 35, 35, 15, 35, 7, 35,
1946 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
1947 35, 35, 35, 35, 35, 35, 35, 17, 35, 35,
1948 35, 35, 35, 34, 35, 35, 35, 35, 35, 35,
1949 10, 35, 13, 35, 35, 35, 35, 33, 35, 35,
1950 35, 35, 35, 22, 35, 32, 9, 31, 35, 26,
1951 12, 35, 35, 21, 18, 35, 8, 35, 35, 35,
1952 35, 35, 27, 35, 35, 6, 35, 20, 19, 23,
1953
1954 35, 35, 11, 35, 35, 35, 14, 28, 35, 24
1955 } ;
1956
1957static yyconst flex_int32_t yy_ec[256] =
1958 { 0,
1959 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1960 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1961 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1962 1, 2, 4, 5, 6, 1, 1, 7, 8, 9,
1963 10, 1, 1, 1, 11, 12, 12, 13, 13, 13,
1964 13, 13, 13, 13, 13, 13, 13, 1, 1, 1,
1965 14, 1, 1, 1, 13, 13, 13, 13, 13, 13,
1966 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
1967 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
1968 1, 15, 1, 1, 16, 1, 17, 18, 19, 20,
1969
1970 21, 22, 23, 24, 25, 13, 13, 26, 27, 28,
1971 29, 30, 31, 32, 33, 34, 35, 13, 13, 36,
1972 13, 13, 1, 37, 1, 1, 1, 1, 1, 1,
1973 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1974 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1975 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1976 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1977 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1978 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1979 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1980
1981 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1982 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1983 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1984 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1985 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1986 1, 1, 1, 1, 1
1987 } ;
1988
1989extern int zconf_flex_debug;
1990int zconf_flex_debug = 0;
1991
1992/* The intent behind this definition is that it'll catch
1993 * any uses of REJECT which flex missed.
1994 */
1995#define REJECT reject_used_but_not_detected
1996#define yymore() yymore_used_but_not_detected
1997#define YY_MORE_ADJ 0
1998#define YY_RESTORE_YY_MORE_OFFSET
1999char *zconftext;
2000
2001/*
2002 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
2003 * Released under the terms of the GNU GPL v2.0.
2004 */
2005
2006#include <limits.h>
2007#include <stdio.h>
2008#include <stdlib.h>
2009#include <string.h>
2010#include <unistd.h>
2011
2012#define LKC_DIRECT_LINK
2013#include "lkc.h"
2014
2015#define START_STRSIZE 16
2016
2017char *text;
2018static char *text_ptr;
2019static int text_size, text_asize;
2020
2021struct buffer {
2022 struct buffer *parent;
2023 YY_BUFFER_STATE state;
2024};
2025
2026struct buffer *current_buf;
2027
2028static int last_ts, first_ts;
2029
2030static void zconf_endhelp(void);
2031static struct buffer *zconf_endfile(void);
2032
2033void new_string(void)
2034{
2035 text = malloc(START_STRSIZE);
2036 text_asize = START_STRSIZE;
2037 text_ptr = text;
2038 text_size = 0;
2039 *text_ptr = 0;
2040}
2041
2042void append_string(const char *str, int size)
2043{
2044 int new_size = text_size + size + 1;
2045 if (new_size > text_asize) {
2046 text = realloc(text, new_size);
2047 text_asize = new_size;
2048 text_ptr = text + text_size;
2049 }
2050 memcpy(text_ptr, str, size);
2051 text_ptr += size;
2052 text_size += size;
2053 *text_ptr = 0;
2054}
2055
2056void alloc_string(const char *str, int size)
2057{
2058 text = malloc(size + 1);
2059 memcpy(text, str, size);
2060 text[size] = 0;
2061}
2062
2063#define INITIAL 0
2064#define COMMAND 1
2065#define HELP 2
2066#define STRING 3
2067#define PARAM 4
2068
2069/* Special case for "unistd.h", since it is non-ANSI. We include it way
2070 * down here because we want the user's section 1 to have been scanned first.
2071 * The user has a chance to override it with an option.
2072 */
2073#include <unistd.h>
2074
2075#ifndef YY_EXTRA_TYPE
2076#define YY_EXTRA_TYPE void *
2077#endif
2078
2079/* Macros after this point can all be overridden by user definitions in
2080 * section 1.
2081 */
2082
2083#ifndef YY_SKIP_YYWRAP
2084#ifdef __cplusplus
2085extern "C" int zconfwrap (void );
2086#else
2087extern int zconfwrap (void );
2088#endif
2089#endif
2090
2091 static void yyunput (int c,char *buf_ptr );
2092
2093#ifndef yytext_ptr
2094static void yy_flex_strncpy (char *,yyconst char *,int );
2095#endif
2096
2097#ifdef YY_NEED_STRLEN
2098static int yy_flex_strlen (yyconst char * );
2099#endif
2100
2101#ifndef YY_NO_INPUT
2102
2103#ifdef __cplusplus
2104static int yyinput (void );
2105#else
2106static int input (void );
2107#endif
2108
2109#endif
2110
2111/* Amount of stuff to slurp up with each read. */
2112#ifndef YY_READ_BUF_SIZE
2113#define YY_READ_BUF_SIZE 8192
2114#endif
2115
2116/* Copy whatever the last rule matched to the standard output. */
2117#ifndef ECHO
2118/* This used to be an fputs(), but since the string might contain NUL's,
2119 * we now use fwrite().
2120 */
2121#define ECHO (void) fwrite( zconftext, zconfleng, 1, zconfout )
2122#endif
2123
2124/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
2125 * is returned in "result".
2126 */
2127#ifndef YY_INPUT
2128#define YY_INPUT(buf,result,max_size) \
2129 errno=0; \
2130 while ( (result = read( fileno(zconfin), (char *) buf, max_size )) < 0 ) \
2131 { \
2132 if( errno != EINTR) \
2133 { \
2134 YY_FATAL_ERROR( "input in flex scanner failed" ); \
2135 break; \
2136 } \
2137 errno=0; \
2138 clearerr(zconfin); \
2139 }\
2140\
2141
2142#endif
2143
2144/* No semi-colon after return; correct usage is to write "yyterminate();" -
2145 * we don't want an extra ';' after the "return" because that will cause
2146 * some compilers to complain about unreachable statements.
2147 */
2148#ifndef yyterminate
2149#define yyterminate() return YY_NULL
2150#endif
2151
2152/* Number of entries by which start-condition stack grows. */
2153#ifndef YY_START_STACK_INCR
2154#define YY_START_STACK_INCR 25
2155#endif
2156
2157/* Report a fatal error. */
2158#ifndef YY_FATAL_ERROR
2159#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
2160#endif
2161
2162/* end tables serialization structures and prototypes */
2163
2164/* Default declaration of generated scanner - a define so the user can
2165 * easily add parameters.
2166 */
2167#ifndef YY_DECL
2168#define YY_DECL_IS_OURS 1
2169
2170extern int zconflex (void);
2171
2172#define YY_DECL int zconflex (void)
2173#endif /* !YY_DECL */
2174
2175/* Code executed at the beginning of each rule, after zconftext and zconfleng
2176 * have been set up.
2177 */
2178#ifndef YY_USER_ACTION
2179#define YY_USER_ACTION
2180#endif
2181
2182/* Code executed at the end of each rule. */
2183#ifndef YY_BREAK
2184#define YY_BREAK break;
2185#endif
2186
2187#define YY_RULE_SETUP \
2188 YY_USER_ACTION
2189
2190/** The main scanner function which does all the work.
2191 */
2192YY_DECL
2193{
2194 register yy_state_type yy_current_state;
2195 register char *yy_cp, *yy_bp;
2196 register int yy_act;
2197
2198 int str = 0;
2199 int ts, i;
2200
2201 if ( (yy_init) )
2202 {
2203 (yy_init) = 0;
2204
2205#ifdef YY_USER_INIT
2206 YY_USER_INIT;
2207#endif
2208
2209 if ( ! (yy_start) )
2210 (yy_start) = 1; /* first start state */
2211
2212 if ( ! zconfin )
2213 zconfin = stdin;
2214
2215 if ( ! zconfout )
2216 zconfout = stdout;
2217
2218 if ( ! YY_CURRENT_BUFFER ) {
2219 zconfensure_buffer_stack ();
2220 YY_CURRENT_BUFFER_LVALUE =
2221 zconf_create_buffer(zconfin,YY_BUF_SIZE );
2222 }
2223
2224 zconf_load_buffer_state( );
2225 }
2226
2227 while ( 1 ) /* loops until end-of-file is reached */
2228 {
2229 yy_cp = (yy_c_buf_p);
2230
2231 /* Support of zconftext. */
2232 *yy_cp = (yy_hold_char);
2233
2234 /* yy_bp points to the position in yy_ch_buf of the start of
2235 * the current run.
2236 */
2237 yy_bp = yy_cp;
2238
2239 yy_current_state = (yy_start);
2240yy_match:
2241 while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 )
2242 ++yy_cp;
2243
2244 yy_current_state = -yy_current_state;
2245
2246yy_find_action:
2247 yy_act = yy_accept[yy_current_state];
2248
2249 YY_DO_BEFORE_ACTION;
2250
2251do_action: /* This label is used only to access EOF actions. */
2252
2253 switch ( yy_act )
2254 { /* beginning of action switch */
2255case 1:
2256/* rule 1 can match eol */
2257YY_RULE_SETUP
2258current_file->lineno++;
2259 YY_BREAK
2260case 2:
2261YY_RULE_SETUP
2262
2263 YY_BREAK
2264case 3:
2265/* rule 3 can match eol */
2266YY_RULE_SETUP
2267current_file->lineno++; return T_EOL;
2268 YY_BREAK
2269case 4:
2270YY_RULE_SETUP
2271{
2272 BEGIN(COMMAND);
2273}
2274 YY_BREAK
2275case 5:
2276YY_RULE_SETUP
2277{
2278 unput(zconftext[0]);
2279 BEGIN(COMMAND);
2280}
2281 YY_BREAK
2282
2283case 6:
2284YY_RULE_SETUP
2285BEGIN(PARAM); return T_MAINMENU;
2286 YY_BREAK
2287case 7:
2288YY_RULE_SETUP
2289BEGIN(PARAM); return T_MENU;
2290 YY_BREAK
2291case 8:
2292YY_RULE_SETUP
2293BEGIN(PARAM); return T_ENDMENU;
2294 YY_BREAK
2295case 9:
2296YY_RULE_SETUP
2297BEGIN(PARAM); return T_SOURCE;
2298 YY_BREAK
2299case 10:
2300YY_RULE_SETUP
2301BEGIN(PARAM); return T_CHOICE;
2302 YY_BREAK
2303case 11:
2304YY_RULE_SETUP
2305BEGIN(PARAM); return T_ENDCHOICE;
2306 YY_BREAK
2307case 12:
2308YY_RULE_SETUP
2309BEGIN(PARAM); return T_COMMENT;
2310 YY_BREAK
2311case 13:
2312YY_RULE_SETUP
2313BEGIN(PARAM); return T_CONFIG;
2314 YY_BREAK
2315case 14:
2316YY_RULE_SETUP
2317BEGIN(PARAM); return T_MENUCONFIG;
2318 YY_BREAK
2319case 15:
2320YY_RULE_SETUP
2321BEGIN(PARAM); return T_HELP;
2322 YY_BREAK
2323case 16:
2324YY_RULE_SETUP
2325BEGIN(PARAM); return T_IF;
2326 YY_BREAK
2327case 17:
2328YY_RULE_SETUP
2329BEGIN(PARAM); return T_ENDIF;
2330 YY_BREAK
2331case 18:
2332YY_RULE_SETUP
2333BEGIN(PARAM); return T_DEPENDS;
2334 YY_BREAK
2335case 19:
2336YY_RULE_SETUP
2337BEGIN(PARAM); return T_REQUIRES;
2338 YY_BREAK
2339case 20:
2340YY_RULE_SETUP
2341BEGIN(PARAM); return T_OPTIONAL;
2342 YY_BREAK
2343case 21:
2344YY_RULE_SETUP
2345BEGIN(PARAM); return T_DEFAULT;
2346 YY_BREAK
2347case 22:
2348YY_RULE_SETUP
2349BEGIN(PARAM); return T_PROMPT;
2350 YY_BREAK
2351case 23:
2352YY_RULE_SETUP
2353BEGIN(PARAM); return T_TRISTATE;
2354 YY_BREAK
2355case 24:
2356YY_RULE_SETUP
2357BEGIN(PARAM); return T_DEF_TRISTATE;
2358 YY_BREAK
2359case 25:
2360YY_RULE_SETUP
2361BEGIN(PARAM); return T_BOOLEAN;
2362 YY_BREAK
2363case 26:
2364YY_RULE_SETUP
2365BEGIN(PARAM); return T_BOOLEAN;
2366 YY_BREAK
2367case 27:
2368YY_RULE_SETUP
2369BEGIN(PARAM); return T_DEF_BOOLEAN;
2370 YY_BREAK
2371case 28:
2372YY_RULE_SETUP
2373BEGIN(PARAM); return T_DEF_BOOLEAN;
2374 YY_BREAK
2375case 29:
2376YY_RULE_SETUP
2377BEGIN(PARAM); return T_INT;
2378 YY_BREAK
2379case 30:
2380YY_RULE_SETUP
2381BEGIN(PARAM); return T_HEX;
2382 YY_BREAK
2383case 31:
2384YY_RULE_SETUP
2385BEGIN(PARAM); return T_STRING;
2386 YY_BREAK
2387case 32:
2388YY_RULE_SETUP
2389BEGIN(PARAM); return T_SELECT;
2390 YY_BREAK
2391case 33:
2392YY_RULE_SETUP
2393BEGIN(PARAM); return T_SELECT;
2394 YY_BREAK
2395case 34:
2396YY_RULE_SETUP
2397BEGIN(PARAM); return T_RANGE;
2398 YY_BREAK
2399case 35:
2400YY_RULE_SETUP
2401{
2402 alloc_string(zconftext, zconfleng);
2403 zconflval.string = text;
2404 return T_WORD;
2405 }
2406 YY_BREAK
2407case 36:
2408YY_RULE_SETUP
2409
2410 YY_BREAK
2411case 37:
2412/* rule 37 can match eol */
2413YY_RULE_SETUP
2414current_file->lineno++; BEGIN(INITIAL);
2415 YY_BREAK
2416
2417case 38:
2418YY_RULE_SETUP
2419return T_AND;
2420 YY_BREAK
2421case 39:
2422YY_RULE_SETUP
2423return T_OR;
2424 YY_BREAK
2425case 40:
2426YY_RULE_SETUP
2427return T_OPEN_PAREN;
2428 YY_BREAK
2429case 41:
2430YY_RULE_SETUP
2431return T_CLOSE_PAREN;
2432 YY_BREAK
2433case 42:
2434YY_RULE_SETUP
2435return T_NOT;
2436 YY_BREAK
2437case 43:
2438YY_RULE_SETUP
2439return T_EQUAL;
2440 YY_BREAK
2441case 44:
2442YY_RULE_SETUP
2443return T_UNEQUAL;
2444 YY_BREAK
2445case 45:
2446YY_RULE_SETUP
2447return T_IF;
2448 YY_BREAK
2449case 46:
2450YY_RULE_SETUP
2451return T_ON;
2452 YY_BREAK
2453case 47:
2454YY_RULE_SETUP
2455{
2456 str = zconftext[0];
2457 new_string();
2458 BEGIN(STRING);
2459 }
2460 YY_BREAK
2461case 48:
2462/* rule 48 can match eol */
2463YY_RULE_SETUP
2464BEGIN(INITIAL); current_file->lineno++; return T_EOL;
2465 YY_BREAK
2466case 49:
2467YY_RULE_SETUP
2468/* ignore */
2469 YY_BREAK
2470case 50:
2471YY_RULE_SETUP
2472{
2473 alloc_string(zconftext, zconfleng);
2474 zconflval.string = text;
2475 return T_WORD;
2476 }
2477 YY_BREAK
2478case 51:
2479YY_RULE_SETUP
2480/* comment */
2481 YY_BREAK
2482case 52:
2483/* rule 52 can match eol */
2484YY_RULE_SETUP
2485current_file->lineno++;
2486 YY_BREAK
2487case 53:
2488YY_RULE_SETUP
2489
2490 YY_BREAK
2491case YY_STATE_EOF(PARAM):
2492{
2493 BEGIN(INITIAL);
2494 }
2495 YY_BREAK
2496
2497case 54:
2498/* rule 54 can match eol */
2499*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
2500(yy_c_buf_p) = yy_cp -= 1;
2501YY_DO_BEFORE_ACTION; /* set up zconftext again */
2502YY_RULE_SETUP
2503{
2504 append_string(zconftext, zconfleng);
2505 zconflval.string = text;
2506 return T_WORD_QUOTE;
2507 }
2508 YY_BREAK
2509case 55:
2510YY_RULE_SETUP
2511{
2512 append_string(zconftext, zconfleng);
2513 }
2514 YY_BREAK
2515case 56:
2516/* rule 56 can match eol */
2517*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
2518(yy_c_buf_p) = yy_cp -= 1;
2519YY_DO_BEFORE_ACTION; /* set up zconftext again */
2520YY_RULE_SETUP
2521{
2522 append_string(zconftext + 1, zconfleng - 1);
2523 zconflval.string = text;
2524 return T_WORD_QUOTE;
2525 }
2526 YY_BREAK
2527case 57:
2528YY_RULE_SETUP
2529{
2530 append_string(zconftext + 1, zconfleng - 1);
2531 }
2532 YY_BREAK
2533case 58:
2534YY_RULE_SETUP
2535{
2536 if (str == zconftext[0]) {
2537 BEGIN(PARAM);
2538 zconflval.string = text;
2539 return T_WORD_QUOTE;
2540 } else
2541 append_string(zconftext, 1);
2542 }
2543 YY_BREAK
2544case 59:
2545/* rule 59 can match eol */
2546YY_RULE_SETUP
2547{
2548 printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno());
2549 current_file->lineno++;
2550 BEGIN(INITIAL);
2551 return T_EOL;
2552 }
2553 YY_BREAK
2554case YY_STATE_EOF(STRING):
2555{
2556 BEGIN(INITIAL);
2557 }
2558 YY_BREAK
2559
2560case 60:
2561YY_RULE_SETUP
2562{
2563 ts = 0;
2564 for (i = 0; i < zconfleng; i++) {
2565 if (zconftext[i] == '\t')
2566 ts = (ts & ~7) + 8;
2567 else
2568 ts++;
2569 }
2570 last_ts = ts;
2571 if (first_ts) {
2572 if (ts < first_ts) {
2573 zconf_endhelp();
2574 return T_HELPTEXT;
2575 }
2576 ts -= first_ts;
2577 while (ts > 8) {
2578 append_string(" ", 8);
2579 ts -= 8;
2580 }
2581 append_string(" ", ts);
2582 }
2583 }
2584 YY_BREAK
2585case 61:
2586/* rule 61 can match eol */
2587*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */
2588(yy_c_buf_p) = yy_cp -= 1;
2589YY_DO_BEFORE_ACTION; /* set up zconftext again */
2590YY_RULE_SETUP
2591{
2592 current_file->lineno++;
2593 zconf_endhelp();
2594 return T_HELPTEXT;
2595 }
2596 YY_BREAK
2597case 62:
2598/* rule 62 can match eol */
2599YY_RULE_SETUP
2600{
2601 current_file->lineno++;
2602 append_string("\n", 1);
2603 }
2604 YY_BREAK
2605case 63:
2606YY_RULE_SETUP
2607{
2608 append_string(zconftext, zconfleng);
2609 if (!first_ts)
2610 first_ts = last_ts;
2611 }
2612 YY_BREAK
2613case YY_STATE_EOF(HELP):
2614{
2615 zconf_endhelp();
2616 return T_HELPTEXT;
2617 }
2618 YY_BREAK
2619
2620case YY_STATE_EOF(INITIAL):
2621case YY_STATE_EOF(COMMAND):
2622{
2623 if (current_buf) {
2624 zconf_endfile();
2625 return T_EOF;
2626 }
2627 fclose(zconfin);
2628 yyterminate();
2629}
2630 YY_BREAK
2631case 64:
2632YY_RULE_SETUP
2633YY_FATAL_ERROR( "flex scanner jammed" );
2634 YY_BREAK
2635
2636 case YY_END_OF_BUFFER:
2637 {
2638 /* Amount of text matched not including the EOB char. */
2639 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
2640
2641 /* Undo the effects of YY_DO_BEFORE_ACTION. */
2642 *yy_cp = (yy_hold_char);
2643 YY_RESTORE_YY_MORE_OFFSET
2644
2645 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
2646 {
2647 /* We're scanning a new file or input source. It's
2648 * possible that this happened because the user
2649 * just pointed zconfin at a new source and called
2650 * zconflex(). If so, then we have to assure
2651 * consistency between YY_CURRENT_BUFFER and our
2652 * globals. Here is the right place to do so, because
2653 * this is the first action (other than possibly a
2654 * back-up) that will match for the new input source.
2655 */
2656 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2657 YY_CURRENT_BUFFER_LVALUE->yy_input_file = zconfin;
2658 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
2659 }
2660
2661 /* Note that here we test for yy_c_buf_p "<=" to the position
2662 * of the first EOB in the buffer, since yy_c_buf_p will
2663 * already have been incremented past the NUL character
2664 * (since all states make transitions on EOB to the
2665 * end-of-buffer state). Contrast this with the test
2666 * in input().
2667 */
2668 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
2669 { /* This was really a NUL. */
2670 yy_state_type yy_next_state;
2671
2672 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
2673
2674 yy_current_state = yy_get_previous_state( );
2675
2676 /* Okay, we're now positioned to make the NUL
2677 * transition. We couldn't have
2678 * yy_get_previous_state() go ahead and do it
2679 * for us because it doesn't know how to deal
2680 * with the possibility of jamming (and we don't
2681 * want to build jamming into it because then it
2682 * will run more slowly).
2683 */
2684
2685 yy_next_state = yy_try_NUL_trans( yy_current_state );
2686
2687 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
2688
2689 if ( yy_next_state )
2690 {
2691 /* Consume the NUL. */
2692 yy_cp = ++(yy_c_buf_p);
2693 yy_current_state = yy_next_state;
2694 goto yy_match;
2695 }
2696
2697 else
2698 {
2699 yy_cp = (yy_c_buf_p);
2700 goto yy_find_action;
2701 }
2702 }
2703
2704 else switch ( yy_get_next_buffer( ) )
2705 {
2706 case EOB_ACT_END_OF_FILE:
2707 {
2708 (yy_did_buffer_switch_on_eof) = 0;
2709
2710 if ( zconfwrap( ) )
2711 {
2712 /* Note: because we've taken care in
2713 * yy_get_next_buffer() to have set up
2714 * zconftext, we can now set up
2715 * yy_c_buf_p so that if some total
2716 * hoser (like flex itself) wants to
2717 * call the scanner after we return the
2718 * YY_NULL, it'll still work - another
2719 * YY_NULL will get returned.
2720 */
2721 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
2722
2723 yy_act = YY_STATE_EOF(YY_START);
2724 goto do_action;
2725 }
2726
2727 else
2728 {
2729 if ( ! (yy_did_buffer_switch_on_eof) )
2730 YY_NEW_FILE;
2731 }
2732 break;
2733 }
2734
2735 case EOB_ACT_CONTINUE_SCAN:
2736 (yy_c_buf_p) =
2737 (yytext_ptr) + yy_amount_of_matched_text;
2738
2739 yy_current_state = yy_get_previous_state( );
2740
2741 yy_cp = (yy_c_buf_p);
2742 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
2743 goto yy_match;
2744
2745 case EOB_ACT_LAST_MATCH:
2746 (yy_c_buf_p) =
2747 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
2748
2749 yy_current_state = yy_get_previous_state( );
2750
2751 yy_cp = (yy_c_buf_p);
2752 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
2753 goto yy_find_action;
2754 }
2755 break;
2756 }
2757
2758 default:
2759 YY_FATAL_ERROR(
2760 "fatal flex scanner internal error--no action found" );
2761 } /* end of action switch */
2762 } /* end of scanning one token */
2763} /* end of zconflex */
2764
2765/* yy_get_next_buffer - try to read in a new buffer
2766 *
2767 * Returns a code representing an action:
2768 * EOB_ACT_LAST_MATCH -
2769 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
2770 * EOB_ACT_END_OF_FILE - end of file
2771 */
2772static int yy_get_next_buffer (void)
2773{
2774 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
2775 register char *source = (yytext_ptr);
2776 register int number_to_move, i;
2777 int ret_val;
2778
2779 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
2780 YY_FATAL_ERROR(
2781 "fatal flex scanner internal error--end of buffer missed" );
2782
2783 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
2784 { /* Don't try to fill the buffer, so this is an EOF. */
2785 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
2786 {
2787 /* We matched a single character, the EOB, so
2788 * treat this as a final EOF.
2789 */
2790 return EOB_ACT_END_OF_FILE;
2791 }
2792
2793 else
2794 {
2795 /* We matched some text prior to the EOB, first
2796 * process it.
2797 */
2798 return EOB_ACT_LAST_MATCH;
2799 }
2800 }
2801
2802 /* Try to read more data. */
2803
2804 /* First move last chars to start of buffer. */
2805 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
2806
2807 for ( i = 0; i < number_to_move; ++i )
2808 *(dest++) = *(source++);
2809
2810 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
2811 /* don't do the read, it's not guaranteed to return an EOF,
2812 * just force an EOF
2813 */
2814 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
2815
2816 else
2817 {
2818 size_t num_to_read =
2819 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
2820
2821 while ( num_to_read <= 0 )
2822 { /* Not enough room in the buffer - grow it. */
2823
2824 /* just a shorter name for the current buffer */
2825 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
2826
2827 int yy_c_buf_p_offset =
2828 (int) ((yy_c_buf_p) - b->yy_ch_buf);
2829
2830 if ( b->yy_is_our_buffer )
2831 {
2832 int new_size = b->yy_buf_size * 2;
2833
2834 if ( new_size <= 0 )
2835 b->yy_buf_size += b->yy_buf_size / 8;
2836 else
2837 b->yy_buf_size *= 2;
2838
2839 b->yy_ch_buf = (char *)
2840 /* Include room in for 2 EOB chars. */
2841 zconfrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
2842 }
2843 else
2844 /* Can't grow it, we don't own it. */
2845 b->yy_ch_buf = 0;
2846
2847 if ( ! b->yy_ch_buf )
2848 YY_FATAL_ERROR(
2849 "fatal error - scanner input buffer overflow" );
2850
2851 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
2852
2853 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
2854 number_to_move - 1;
2855
2856 }
2857
2858 if ( num_to_read > YY_READ_BUF_SIZE )
2859 num_to_read = YY_READ_BUF_SIZE;
2860
2861 /* Read in more data. */
2862 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
2863 (yy_n_chars), num_to_read );
2864
2865 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
2866 }
2867
2868 if ( (yy_n_chars) == 0 )
2869 {
2870 if ( number_to_move == YY_MORE_ADJ )
2871 {
2872 ret_val = EOB_ACT_END_OF_FILE;
2873 zconfrestart(zconfin );
2874 }
2875
2876 else
2877 {
2878 ret_val = EOB_ACT_LAST_MATCH;
2879 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
2880 YY_BUFFER_EOF_PENDING;
2881 }
2882 }
2883
2884 else
2885 ret_val = EOB_ACT_CONTINUE_SCAN;
2886
2887 (yy_n_chars) += number_to_move;
2888 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
2889 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
2890
2891 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
2892
2893 return ret_val;
2894}
2895
2896/* yy_get_previous_state - get the state just before the EOB char was reached */
2897
2898 static yy_state_type yy_get_previous_state (void)
2899{
2900 register yy_state_type yy_current_state;
2901 register char *yy_cp;
2902
2903 yy_current_state = (yy_start);
2904
2905 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
2906 {
2907 yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)];
2908 }
2909
2910 return yy_current_state;
2911}
2912
2913/* yy_try_NUL_trans - try to make a transition on the NUL character
2914 *
2915 * synopsis
2916 * next_state = yy_try_NUL_trans( current_state );
2917 */
2918 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
2919{
2920 register int yy_is_jam;
2921
2922 yy_current_state = yy_nxt[yy_current_state][1];
2923 yy_is_jam = (yy_current_state <= 0);
2924
2925 return yy_is_jam ? 0 : yy_current_state;
2926}
2927
2928 static void yyunput (int c, register char * yy_bp )
2929{
2930 register char *yy_cp;
2931
2932 yy_cp = (yy_c_buf_p);
2933
2934 /* undo effects of setting up zconftext */
2935 *yy_cp = (yy_hold_char);
2936
2937 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
2938 { /* need to shift things up to make room */
2939 /* +2 for EOB chars. */
2940 register int number_to_move = (yy_n_chars) + 2;
2941 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
2942 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
2943 register char *source =
2944 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
2945
2946 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
2947 *--dest = *--source;
2948
2949 yy_cp += (int) (dest - source);
2950 yy_bp += (int) (dest - source);
2951 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
2952 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
2953
2954 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
2955 YY_FATAL_ERROR( "flex scanner push-back overflow" );
2956 }
2957
2958 *--yy_cp = (char) c;
2959
2960 (yytext_ptr) = yy_bp;
2961 (yy_hold_char) = *yy_cp;
2962 (yy_c_buf_p) = yy_cp;
2963}
2964
2965#ifndef YY_NO_INPUT
2966#ifdef __cplusplus
2967 static int yyinput (void)
2968#else
2969 static int input (void)
2970#endif
2971
2972{
2973 int c;
2974
2975 *(yy_c_buf_p) = (yy_hold_char);
2976
2977 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
2978 {
2979 /* yy_c_buf_p now points to the character we want to return.
2980 * If this occurs *before* the EOB characters, then it's a
2981 * valid NUL; if not, then we've hit the end of the buffer.
2982 */
2983 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
2984 /* This was really a NUL. */
2985 *(yy_c_buf_p) = '\0';
2986
2987 else
2988 { /* need more input */
2989 int offset = (yy_c_buf_p) - (yytext_ptr);
2990 ++(yy_c_buf_p);
2991
2992 switch ( yy_get_next_buffer( ) )
2993 {
2994 case EOB_ACT_LAST_MATCH:
2995 /* This happens because yy_g_n_b()
2996 * sees that we've accumulated a
2997 * token and flags that we need to
2998 * try matching the token before
2999 * proceeding. But for input(),
3000 * there's no matching to consider.
3001 * So convert the EOB_ACT_LAST_MATCH
3002 * to EOB_ACT_END_OF_FILE.
3003 */
3004
3005 /* Reset buffer status. */
3006 zconfrestart(zconfin );
3007
3008 /*FALLTHROUGH*/
3009
3010 case EOB_ACT_END_OF_FILE:
3011 {
3012 if ( zconfwrap( ) )
3013 return EOF;
3014
3015 if ( ! (yy_did_buffer_switch_on_eof) )
3016 YY_NEW_FILE;
3017#ifdef __cplusplus
3018 return yyinput();
3019#else
3020 return input();
3021#endif
3022 }
3023
3024 case EOB_ACT_CONTINUE_SCAN:
3025 (yy_c_buf_p) = (yytext_ptr) + offset;
3026 break;
3027 }
3028 }
3029 }
3030
3031 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
3032 *(yy_c_buf_p) = '\0'; /* preserve zconftext */
3033 (yy_hold_char) = *++(yy_c_buf_p);
3034
3035 return c;
3036}
3037#endif /* ifndef YY_NO_INPUT */
3038
3039/** Immediately switch to a different input stream.
3040 * @param input_file A readable stream.
3041 *
3042 * @note This function does not reset the start condition to @c INITIAL .
3043 */
3044 void zconfrestart (FILE * input_file )
3045{
3046
3047 if ( ! YY_CURRENT_BUFFER ){
3048 zconfensure_buffer_stack ();
3049 YY_CURRENT_BUFFER_LVALUE =
3050 zconf_create_buffer(zconfin,YY_BUF_SIZE );
3051 }
3052
3053 zconf_init_buffer(YY_CURRENT_BUFFER,input_file );
3054 zconf_load_buffer_state( );
3055}
3056
3057/** Switch to a different input buffer.
3058 * @param new_buffer The new input buffer.
3059 *
3060 */
3061 void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer )
3062{
3063
3064 /* TODO. We should be able to replace this entire function body
3065 * with
3066 * zconfpop_buffer_state();
3067 * zconfpush_buffer_state(new_buffer);
3068 */
3069 zconfensure_buffer_stack ();
3070 if ( YY_CURRENT_BUFFER == new_buffer )
3071 return;
3072
3073 if ( YY_CURRENT_BUFFER )
3074 {
3075 /* Flush out information for old buffer. */
3076 *(yy_c_buf_p) = (yy_hold_char);
3077 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
3078 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
3079 }
3080
3081 YY_CURRENT_BUFFER_LVALUE = new_buffer;
3082 zconf_load_buffer_state( );
3083
3084 /* We don't actually know whether we did this switch during
3085 * EOF (zconfwrap()) processing, but the only time this flag
3086 * is looked at is after zconfwrap() is called, so it's safe
3087 * to go ahead and always set it.
3088 */
3089 (yy_did_buffer_switch_on_eof) = 1;
3090}
3091
3092static void zconf_load_buffer_state (void)
3093{
3094 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
3095 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
3096 zconfin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
3097 (yy_hold_char) = *(yy_c_buf_p);
3098}
3099
3100/** Allocate and initialize an input buffer state.
3101 * @param file A readable stream.
3102 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
3103 *
3104 * @return the allocated buffer state.
3105 */
3106 YY_BUFFER_STATE zconf_create_buffer (FILE * file, int size )
3107{
3108 YY_BUFFER_STATE b;
3109
3110 b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) );
3111 if ( ! b )
3112 YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" );
3113
3114 b->yy_buf_size = size;
3115
3116 /* yy_ch_buf has to be 2 characters longer than the size given because
3117 * we need to put in 2 end-of-buffer characters.
3118 */
3119 b->yy_ch_buf = (char *) zconfalloc(b->yy_buf_size + 2 );
3120 if ( ! b->yy_ch_buf )
3121 YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" );
3122
3123 b->yy_is_our_buffer = 1;
3124
3125 zconf_init_buffer(b,file );
3126
3127 return b;
3128}
3129
3130/** Destroy the buffer.
3131 * @param b a buffer created with zconf_create_buffer()
3132 *
3133 */
3134 void zconf_delete_buffer (YY_BUFFER_STATE b )
3135{
3136
3137 if ( ! b )
3138 return;
3139
3140 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
3141 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
3142
3143 if ( b->yy_is_our_buffer )
3144 zconffree((void *) b->yy_ch_buf );
3145
3146 zconffree((void *) b );
3147}
3148
3149/* Initializes or reinitializes a buffer.
3150 * This function is sometimes called more than once on the same buffer,
3151 * such as during a zconfrestart() or at EOF.
3152 */
3153 static void zconf_init_buffer (YY_BUFFER_STATE b, FILE * file )
3154
3155{
3156 int oerrno = errno;
3157
3158 zconf_flush_buffer(b );
3159
3160 b->yy_input_file = file;
3161 b->yy_fill_buffer = 1;
3162
3163 /* If b is the current buffer, then zconf_init_buffer was _probably_
3164 * called from zconfrestart() or through yy_get_next_buffer.
3165 * In that case, we don't want to reset the lineno or column.
3166 */
3167 if (b != YY_CURRENT_BUFFER){
3168 b->yy_bs_lineno = 1;
3169 b->yy_bs_column = 0;
3170 }
3171
3172 b->yy_is_interactive = 0;
3173
3174 errno = oerrno;
3175}
3176
3177/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
3178 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
3179 *
3180 */
3181 void zconf_flush_buffer (YY_BUFFER_STATE b )
3182{
3183 if ( ! b )
3184 return;
3185
3186 b->yy_n_chars = 0;
3187
3188 /* We always need two end-of-buffer characters. The first causes
3189 * a transition to the end-of-buffer state. The second causes
3190 * a jam in that state.
3191 */
3192 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
3193 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
3194
3195 b->yy_buf_pos = &b->yy_ch_buf[0];
3196
3197 b->yy_at_bol = 1;
3198 b->yy_buffer_status = YY_BUFFER_NEW;
3199
3200 if ( b == YY_CURRENT_BUFFER )
3201 zconf_load_buffer_state( );
3202}
3203
3204/** Pushes the new state onto the stack. The new state becomes
3205 * the current state. This function will allocate the stack
3206 * if necessary.
3207 * @param new_buffer The new state.
3208 *
3209 */
3210void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer )
3211{
3212 if (new_buffer == NULL)
3213 return;
3214
3215 zconfensure_buffer_stack();
3216
3217 /* This block is copied from zconf_switch_to_buffer. */
3218 if ( YY_CURRENT_BUFFER )
3219 {
3220 /* Flush out information for old buffer. */
3221 *(yy_c_buf_p) = (yy_hold_char);
3222 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
3223 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
3224 }
3225
3226 /* Only push if top exists. Otherwise, replace top. */
3227 if (YY_CURRENT_BUFFER)
3228 (yy_buffer_stack_top)++;
3229 YY_CURRENT_BUFFER_LVALUE = new_buffer;
3230
3231 /* copied from zconf_switch_to_buffer. */
3232 zconf_load_buffer_state( );
3233 (yy_did_buffer_switch_on_eof) = 1;
3234}
3235
3236/** Removes and deletes the top of the stack, if present.
3237 * The next element becomes the new top.
3238 *
3239 */
3240void zconfpop_buffer_state (void)
3241{
3242 if (!YY_CURRENT_BUFFER)
3243 return;
3244
3245 zconf_delete_buffer(YY_CURRENT_BUFFER );
3246 YY_CURRENT_BUFFER_LVALUE = NULL;
3247 if ((yy_buffer_stack_top) > 0)
3248 --(yy_buffer_stack_top);
3249
3250 if (YY_CURRENT_BUFFER) {
3251 zconf_load_buffer_state( );
3252 (yy_did_buffer_switch_on_eof) = 1;
3253 }
3254}
3255
3256/* Allocates the stack if it does not exist.
3257 * Guarantees space for at least one push.
3258 */
3259static void zconfensure_buffer_stack (void)
3260{
3261 int num_to_alloc;
3262
3263 if (!(yy_buffer_stack)) {
3264
3265 /* First allocation is just for 2 elements, since we don't know if this
3266 * scanner will even need a stack. We use 2 instead of 1 to avoid an
3267 * immediate realloc on the next call.
3268 */
3269 num_to_alloc = 1;
3270 (yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc
3271 (num_to_alloc * sizeof(struct yy_buffer_state*)
3272 );
3273
3274 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
3275
3276 (yy_buffer_stack_max) = num_to_alloc;
3277 (yy_buffer_stack_top) = 0;
3278 return;
3279 }
3280
3281 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
3282
3283 /* Increase the buffer to prepare for a possible push. */
3284 int grow_size = 8 /* arbitrary grow size */;
3285
3286 num_to_alloc = (yy_buffer_stack_max) + grow_size;
3287 (yy_buffer_stack) = (struct yy_buffer_state**)zconfrealloc
3288 ((yy_buffer_stack),
3289 num_to_alloc * sizeof(struct yy_buffer_state*)
3290 );
3291
3292 /* zero only the new slots.*/
3293 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
3294 (yy_buffer_stack_max) = num_to_alloc;
3295 }
3296}
3297
3298/** Setup the input buffer state to scan directly from a user-specified character buffer.
3299 * @param base the character buffer
3300 * @param size the size in bytes of the character buffer
3301 *
3302 * @return the newly allocated buffer state object.
3303 */
3304YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size )
3305{
3306 YY_BUFFER_STATE b;
3307
3308 if ( size < 2 ||
3309 base[size-2] != YY_END_OF_BUFFER_CHAR ||
3310 base[size-1] != YY_END_OF_BUFFER_CHAR )
3311 /* They forgot to leave room for the EOB's. */
3312 return 0;
3313
3314 b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) );
3315 if ( ! b )
3316 YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_buffer()" );
3317
3318 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
3319 b->yy_buf_pos = b->yy_ch_buf = base;
3320 b->yy_is_our_buffer = 0;
3321 b->yy_input_file = 0;
3322 b->yy_n_chars = b->yy_buf_size;
3323 b->yy_is_interactive = 0;
3324 b->yy_at_bol = 1;
3325 b->yy_fill_buffer = 0;
3326 b->yy_buffer_status = YY_BUFFER_NEW;
3327
3328 zconf_switch_to_buffer(b );
3329
3330 return b;
3331}
3332
3333/** Setup the input buffer state to scan a string. The next call to zconflex() will
3334 * scan from a @e copy of @a str.
3335 * @param str a NUL-terminated string to scan
3336 *
3337 * @return the newly allocated buffer state object.
3338 * @note If you want to scan bytes that may contain NUL values, then use
3339 * zconf_scan_bytes() instead.
3340 */
3341YY_BUFFER_STATE zconf_scan_string (yyconst char * str )
3342{
3343
3344 return zconf_scan_bytes(str,strlen(str) );
3345}
3346
3347/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will
3348 * scan from a @e copy of @a bytes.
3349 * @param bytes the byte buffer to scan
3350 * @param len the number of bytes in the buffer pointed to by @a bytes.
3351 *
3352 * @return the newly allocated buffer state object.
3353 */
3354YY_BUFFER_STATE zconf_scan_bytes (yyconst char * bytes, int len )
3355{
3356 YY_BUFFER_STATE b;
3357 char *buf;
3358 yy_size_t n;
3359 int i;
3360
3361 /* Get memory for full buffer, including space for trailing EOB's. */
3362 n = len + 2;
3363 buf = (char *) zconfalloc(n );
3364 if ( ! buf )
3365 YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_bytes()" );
3366
3367 for ( i = 0; i < len; ++i )
3368 buf[i] = bytes[i];
3369
3370 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
3371
3372 b = zconf_scan_buffer(buf,n );
3373 if ( ! b )
3374 YY_FATAL_ERROR( "bad buffer in zconf_scan_bytes()" );
3375
3376 /* It's okay to grow etc. this buffer, and we should throw it
3377 * away when we're done.
3378 */
3379 b->yy_is_our_buffer = 1;
3380
3381 return b;
3382}
3383
3384#ifndef YY_EXIT_FAILURE
3385#define YY_EXIT_FAILURE 2
3386#endif
3387
3388static void yy_fatal_error (yyconst char* msg )
3389{
3390 (void) fprintf( stderr, "%s\n", msg );
3391 exit( YY_EXIT_FAILURE );
3392}
3393
3394/* Redefine yyless() so it works in section 3 code. */
3395
3396#undef yyless
3397#define yyless(n) \
3398 do \
3399 { \
3400 /* Undo effects of setting up zconftext. */ \
3401 int yyless_macro_arg = (n); \
3402 YY_LESS_LINENO(yyless_macro_arg);\
3403 zconftext[zconfleng] = (yy_hold_char); \
3404 (yy_c_buf_p) = zconftext + yyless_macro_arg; \
3405 (yy_hold_char) = *(yy_c_buf_p); \
3406 *(yy_c_buf_p) = '\0'; \
3407 zconfleng = yyless_macro_arg; \
3408 } \
3409 while ( 0 )
3410
3411/* Accessor methods (get/set functions) to struct members. */
3412
3413/** Get the current line number.
3414 *
3415 */
3416int zconfget_lineno (void)
3417{
3418
3419 return zconflineno;
3420}
3421
3422/** Get the input stream.
3423 *
3424 */
3425FILE *zconfget_in (void)
3426{
3427 return zconfin;
3428}
3429
3430/** Get the output stream.
3431 *
3432 */
3433FILE *zconfget_out (void)
3434{
3435 return zconfout;
3436}
3437
3438/** Get the length of the current token.
3439 *
3440 */
3441int zconfget_leng (void)
3442{
3443 return zconfleng;
3444}
3445
3446/** Get the current token.
3447 *
3448 */
3449
3450char *zconfget_text (void)
3451{
3452 return zconftext;
3453}
3454
3455/** Set the current line number.
3456 * @param line_number
3457 *
3458 */
3459void zconfset_lineno (int line_number )
3460{
3461
3462 zconflineno = line_number;
3463}
3464
3465/** Set the input stream. This does not discard the current
3466 * input buffer.
3467 * @param in_str A readable stream.
3468 *
3469 * @see zconf_switch_to_buffer
3470 */
3471void zconfset_in (FILE * in_str )
3472{
3473 zconfin = in_str ;
3474}
3475
3476void zconfset_out (FILE * out_str )
3477{
3478 zconfout = out_str ;
3479}
3480
3481int zconfget_debug (void)
3482{
3483 return zconf_flex_debug;
3484}
3485
3486void zconfset_debug (int bdebug )
3487{
3488 zconf_flex_debug = bdebug ;
3489}
3490
3491/* zconflex_destroy is for both reentrant and non-reentrant scanners. */
3492int zconflex_destroy (void)
3493{
3494
3495 /* Pop the buffer stack, destroying each element. */
3496 while(YY_CURRENT_BUFFER){
3497 zconf_delete_buffer(YY_CURRENT_BUFFER );
3498 YY_CURRENT_BUFFER_LVALUE = NULL;
3499 zconfpop_buffer_state();
3500 }
3501
3502 /* Destroy the stack itself. */
3503 zconffree((yy_buffer_stack) );
3504 (yy_buffer_stack) = NULL;
3505
3506 return 0;
3507}
3508
3509/*
3510 * Internal utility routines.
3511 */
3512
3513#ifndef yytext_ptr
3514static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
3515{
3516 register int i;
3517 for ( i = 0; i < n; ++i )
3518 s1[i] = s2[i];
3519}
3520#endif
3521
3522#ifdef YY_NEED_STRLEN
3523static int yy_flex_strlen (yyconst char * s )
3524{
3525 register int n;
3526 for ( n = 0; s[n]; ++n )
3527 ;
3528
3529 return n;
3530}
3531#endif
3532
3533void *zconfalloc (yy_size_t size )
3534{
3535 return (void *) malloc( size );
3536}
3537
3538void *zconfrealloc (void * ptr, yy_size_t size )
3539{
3540 /* The cast to (char *) in the following accommodates both
3541 * implementations that use char* generic pointers, and those
3542 * that use void* generic pointers. It works with the latter
3543 * because both ANSI C and C++ allow castless assignment from
3544 * any pointer type to void*, and deal with argument conversions
3545 * as though doing an assignment.
3546 */
3547 return (void *) realloc( (char *) ptr, size );
3548}
3549
3550void zconffree (void * ptr )
3551{
3552 free( (char *) ptr ); /* see zconfrealloc() for (char *) cast */
3553}
3554
3555#define YYTABLES_NAME "yytables"
3556
3557#undef YY_NEW_FILE
3558#undef YY_FLUSH_BUFFER
3559#undef yy_set_bol
3560#undef yy_new_buffer
3561#undef yy_set_interactive
3562#undef yytext_ptr
3563#undef YY_DO_BEFORE_ACTION
3564
3565#ifdef YY_DECL_IS_OURS
3566#undef YY_DECL_IS_OURS
3567#undef YY_DECL
3568#endif
3569
3570void zconf_starthelp(void)
3571{
3572 new_string();
3573 last_ts = first_ts = 0;
3574 BEGIN(HELP);
3575}
3576
3577static void zconf_endhelp(void)
3578{
3579 zconflval.string = text;
3580 BEGIN(INITIAL);
3581}
3582
3583/*
3584 * Try to open specified file with following names:
3585 * ./name
3586 * $(srctree)/name
3587 * The latter is used when srctree is separate from objtree
3588 * when compiling the kernel.
3589 * Return NULL if file is not found.
3590 */
3591FILE *zconf_fopen(const char *name)
3592{
3593 char *env, fullname[PATH_MAX+1];
3594 FILE *f;
3595
3596 f = fopen(name, "r");
3597 if (!f && name[0] != '/') {
3598 env = getenv(SRCTREE);
3599 if (env) {
3600 sprintf(fullname, "%s/%s", env, name);
3601 f = fopen(fullname, "r");
3602 }
3603 }
3604 return f;
3605}
3606
3607void zconf_initscan(const char *name)
3608{
3609 zconfin = zconf_fopen(name);
3610 if (!zconfin) {
3611 printf("can't find file %s\n", name);
3612 exit(1);
3613 }
3614
3615 current_buf = malloc(sizeof(*current_buf));
3616 memset(current_buf, 0, sizeof(*current_buf));
3617
3618 current_file = file_lookup(name);
3619 current_file->lineno = 1;
3620 current_file->flags = FILE_BUSY;
3621}
3622
3623void zconf_nextfile(const char *name)
3624{
3625 struct file *file = file_lookup(name);
3626 struct buffer *buf = malloc(sizeof(*buf));
3627 memset(buf, 0, sizeof(*buf));
3628
3629 current_buf->state = YY_CURRENT_BUFFER;
3630 zconfin = zconf_fopen(name);
3631 if (!zconfin) {
3632 printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name);
3633 exit(1);
3634 }
3635 zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE));
3636 buf->parent = current_buf;
3637 current_buf = buf;
3638
3639 if (file->flags & FILE_BUSY) {
3640 printf("recursive scan (%s)?\n", name);
3641 exit(1);
3642 }
3643 if (file->flags & FILE_SCANNED) {
3644 printf("file %s already scanned?\n", name);
3645 exit(1);
3646 }
3647 file->flags |= FILE_BUSY;
3648 file->lineno = 1;
3649 file->parent = current_file;
3650 current_file = file;
3651}
3652
3653static struct buffer *zconf_endfile(void)
3654{
3655 struct buffer *parent;
3656
3657 current_file->flags |= FILE_SCANNED;
3658 current_file->flags &= ~FILE_BUSY;
3659 current_file = current_file->parent;
3660
3661 parent = current_buf->parent;
3662 if (parent) {
3663 fclose(zconfin);
3664 zconf_delete_buffer(YY_CURRENT_BUFFER);
3665 zconf_switch_to_buffer(parent->state);
3666 }
3667 free(current_buf);
3668 current_buf = parent;
3669
3670 return parent;
3671}
3672
3673int zconf_lineno(void)
3674{
3675 if (current_buf)
3676 return current_file->lineno - 1;
3677 else
3678 return 0;
3679}
3680
3681char *zconf_curname(void)
3682{
3683 if (current_buf)
3684 return current_file->name;
3685 else
3686 return "<none>";
3687}
3688
diff --git a/scripts/config/lkc.h b/scripts/config/lkc.h
deleted file mode 100644
index 8c38f1f87..000000000
--- a/scripts/config/lkc.h
+++ /dev/null
@@ -1,124 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0.
5 */
6
7#ifndef LKC_H
8#define LKC_H
9
10#include "expr.h"
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16#ifdef LKC_DIRECT_LINK
17#define P(name,type,arg) extern type name arg
18#else
19#include "lkc_defs.h"
20#define P(name,type,arg) extern type (*name ## _p) arg
21#endif
22#include "lkc_proto.h"
23#undef P
24
25#define SRCTREE "srctree"
26
27int zconfparse(void);
28void zconfdump(FILE *out);
29
30extern int zconfdebug;
31void zconf_starthelp(void);
32FILE *zconf_fopen(const char *name);
33void zconf_initscan(const char *name);
34void zconf_nextfile(const char *name);
35int zconf_lineno(void);
36char *zconf_curname(void);
37
38/* confdata.c */
39extern const char conf_def_filename[];
40extern char conf_filename[];
41
42char *conf_get_default_confname(void);
43
44/* kconfig_load.c */
45void kconfig_load(void);
46
47/* menu.c */
48void menu_init(void);
49void menu_add_menu(void);
50void menu_end_menu(void);
51void menu_add_entry(struct symbol *sym);
52void menu_end_entry(void);
53void menu_add_dep(struct expr *dep);
54struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep);
55void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
56void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
57void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
58void menu_finalize(struct menu *parent);
59void menu_set_type(int type);
60
61/* util.c */
62struct file *file_lookup(const char *name);
63int file_write_dep(const char *name);
64
65struct gstr {
66 size_t len;
67 char *s;
68};
69struct gstr str_new(void);
70struct gstr str_assign(const char *s);
71void str_free(struct gstr *gs);
72void str_append(struct gstr *gs, const char *s);
73void str_printf(struct gstr *gs, const char *fmt, ...);
74const char *str_get(struct gstr *gs);
75
76/* symbol.c */
77void sym_init(void);
78void sym_clear_all_valid(void);
79void sym_set_changed(struct symbol *sym);
80struct symbol *sym_check_deps(struct symbol *sym);
81struct property *prop_alloc(enum prop_type type, struct symbol *sym);
82struct symbol *prop_get_symbol(struct property *prop);
83
84static inline tristate sym_get_tristate_value(struct symbol *sym)
85{
86 return sym->curr.tri;
87}
88
89
90static inline struct symbol *sym_get_choice_value(struct symbol *sym)
91{
92 return (struct symbol *)sym->curr.val;
93}
94
95static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval)
96{
97 return sym_set_tristate_value(chval, yes);
98}
99
100static inline bool sym_is_choice(struct symbol *sym)
101{
102 return sym->flags & SYMBOL_CHOICE ? true : false;
103}
104
105static inline bool sym_is_choice_value(struct symbol *sym)
106{
107 return sym->flags & SYMBOL_CHOICEVAL ? true : false;
108}
109
110static inline bool sym_is_optional(struct symbol *sym)
111{
112 return sym->flags & SYMBOL_OPTIONAL ? true : false;
113}
114
115static inline bool sym_has_value(struct symbol *sym)
116{
117 return sym->flags & SYMBOL_NEW ? false : true;
118}
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif /* LKC_H */
diff --git a/scripts/config/lkc_proto.h b/scripts/config/lkc_proto.h
deleted file mode 100644
index c416357df..000000000
--- a/scripts/config/lkc_proto.h
+++ /dev/null
@@ -1,41 +0,0 @@
1/* vi: set sw=4 ts=4: */
2
3/* confdata.c */
4P(conf_parse,void,(const char *name));
5P(conf_read,int,(const char *name));
6P(conf_write,int,(const char *name));
7
8/* menu.c */
9P(rootmenu,struct menu,);
10
11P(menu_is_visible,bool,(struct menu *menu));
12P(menu_get_prompt,const char *,(struct menu *menu));
13P(menu_get_root_menu,struct menu *,(struct menu *menu));
14P(menu_get_parent_menu,struct menu *,(struct menu *menu));
15
16/* symbol.c */
17P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
18P(sym_change_count,int,);
19
20P(sym_lookup,struct symbol *,(const char *name, int isconst));
21P(sym_find,struct symbol *,(const char *name));
22P(sym_re_search,struct symbol **,(const char *pattern));
23P(sym_type_name,const char *,(enum symbol_type type));
24P(sym_calc_value,void,(struct symbol *sym));
25P(sym_get_type,enum symbol_type,(struct symbol *sym));
26P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri));
27P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri));
28P(sym_toggle_tristate_value,tristate,(struct symbol *sym));
29P(sym_string_valid,bool,(struct symbol *sym, const char *newval));
30P(sym_string_within_range,bool,(struct symbol *sym, const char *str));
31P(sym_set_string_value,bool,(struct symbol *sym, const char *newval));
32P(sym_is_changable,bool,(struct symbol *sym));
33P(sym_get_choice_prop,struct property *,(struct symbol *sym));
34P(sym_get_default_prop,struct property *,(struct symbol *sym));
35P(sym_get_string_value,const char *,(struct symbol *sym));
36
37P(prop_get_type_name,const char *,(enum prop_type type));
38
39/* expr.c */
40P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2));
41P(expr_print,void,(struct expr *e, void (*fn)(void *, const char *), void *data, int prevtoken));
diff --git a/scripts/config/lxdialog/BIG.FAT.WARNING b/scripts/config/lxdialog/BIG.FAT.WARNING
deleted file mode 100644
index 7cb5a7ec9..000000000
--- a/scripts/config/lxdialog/BIG.FAT.WARNING
+++ /dev/null
@@ -1,4 +0,0 @@
1This is NOT the official version of dialog. This version has been
2significantly modified from the original. It is for use by the Linux
3kernel configuration script. Please do not bother Savio Lam with
4questions about this program.
diff --git a/scripts/config/lxdialog/checklist.c b/scripts/config/lxdialog/checklist.c
deleted file mode 100644
index 1513a8966..000000000
--- a/scripts/config/lxdialog/checklist.c
+++ /dev/null
@@ -1,373 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * checklist.c -- implements the checklist box
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension
7 * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two
8 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25#include "dialog.h"
26
27static int list_width, check_x, item_x, checkflag;
28
29/*
30 * Print list item
31 */
32static void
33print_item (WINDOW * win, const char *item, int status,
34 int choice, int selected)
35{
36 int i;
37
38 /* Clear 'residue' of last item */
39 wattrset (win, menubox_attr);
40 wmove (win, choice, 0);
41 for (i = 0; i < list_width; i++)
42 waddch (win, ' ');
43
44 wmove (win, choice, check_x);
45 wattrset (win, selected ? check_selected_attr : check_attr);
46 if (checkflag == FLAG_CHECK)
47 wprintw (win, "[%c]", status ? 'X' : ' ');
48 else
49 wprintw (win, "(%c)", status ? 'X' : ' ');
50
51 wattrset (win, selected ? tag_selected_attr : tag_attr);
52 mvwaddch(win, choice, item_x, item[0]);
53 wattrset (win, selected ? item_selected_attr : item_attr);
54 waddstr (win, (char *)item+1);
55 if (selected) {
56 wmove (win, choice, check_x+1);
57 wrefresh (win);
58 }
59}
60
61/*
62 * Print the scroll indicators.
63 */
64static void
65print_arrows (WINDOW * win, int choice, int item_no, int scroll,
66 int y, int x, int height)
67{
68 wmove(win, y, x);
69
70 if (scroll > 0) {
71 wattrset (win, uarrow_attr);
72 waddch (win, ACS_UARROW);
73 waddstr (win, "(-)");
74 }
75 else {
76 wattrset (win, menubox_attr);
77 waddch (win, ACS_HLINE);
78 waddch (win, ACS_HLINE);
79 waddch (win, ACS_HLINE);
80 waddch (win, ACS_HLINE);
81 }
82
83 y = y + height + 1;
84 wmove(win, y, x);
85
86 if ((height < item_no) && (scroll + choice < item_no - 1)) {
87 wattrset (win, darrow_attr);
88 waddch (win, ACS_DARROW);
89 waddstr (win, "(+)");
90 }
91 else {
92 wattrset (win, menubox_border_attr);
93 waddch (win, ACS_HLINE);
94 waddch (win, ACS_HLINE);
95 waddch (win, ACS_HLINE);
96 waddch (win, ACS_HLINE);
97 }
98}
99
100/*
101 * Display the termination buttons
102 */
103static void
104print_buttons( WINDOW *dialog, int height, int width, int selected)
105{
106 int x = width / 2 - 11;
107 int y = height - 2;
108
109 print_button (dialog, "Select", y, x, selected == 0);
110 print_button (dialog, " Help ", y, x + 14, selected == 1);
111
112 wmove(dialog, y, x+1 + 14*selected);
113 wrefresh (dialog);
114}
115
116/*
117 * Display a dialog box with a list of options that can be turned on or off
118 * The `flag' parameter is used to select between radiolist and checklist.
119 */
120int
121dialog_checklist (const char *title, const char *prompt, int height, int width,
122 int list_height, int item_no, struct dialog_list_item ** items,
123 int flag)
124
125{
126 int i, x, y, box_x, box_y;
127 int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status;
128 WINDOW *dialog, *list;
129
130 checkflag = flag;
131
132 /* Allocate space for storing item on/off status */
133 if ((status = malloc (sizeof (int) * item_no)) == NULL) {
134 endwin ();
135 fprintf (stderr,
136 "\nCan't allocate memory in dialog_checklist().\n");
137 exit (-1);
138 }
139
140 /* Initializes status */
141 for (i = 0; i < item_no; i++) {
142 status[i] = (items[i]->selected == 1); /* ON */
143 if ((!choice && status[i]) || items[i]->selected == 2) /* SELECTED */
144 choice = i + 1;
145 }
146 if (choice)
147 choice--;
148
149 max_choice = MIN (list_height, item_no);
150
151 /* center dialog box on screen */
152 x = (COLS - width) / 2;
153 y = (LINES - height) / 2;
154
155 draw_shadow (stdscr, y, x, height, width);
156
157 dialog = newwin (height, width, y, x);
158 keypad (dialog, TRUE);
159
160 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
161 wattrset (dialog, border_attr);
162 mvwaddch (dialog, height-3, 0, ACS_LTEE);
163 for (i = 0; i < width - 2; i++)
164 waddch (dialog, ACS_HLINE);
165 wattrset (dialog, dialog_attr);
166 waddch (dialog, ACS_RTEE);
167
168 if (title != NULL && strlen(title) >= width-2 ) {
169 /* truncate long title -- mec */
170 char * title2 = malloc(width-2+1);
171 memcpy( title2, title, width-2 );
172 title2[width-2] = '\0';
173 title = title2;
174 }
175
176 if (title != NULL) {
177 wattrset (dialog, title_attr);
178 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
179 waddstr (dialog, (char *)title);
180 waddch (dialog, ' ');
181 }
182
183 wattrset (dialog, dialog_attr);
184 print_autowrap (dialog, prompt, width - 2, 1, 3);
185
186 list_width = width - 6;
187 box_y = height - list_height - 5;
188 box_x = (width - list_width) / 2 - 1;
189
190 /* create new window for the list */
191 list = subwin (dialog, list_height, list_width, y+box_y+1, x+box_x+1);
192
193 keypad (list, TRUE);
194
195 /* draw a box around the list items */
196 draw_box (dialog, box_y, box_x, list_height + 2, list_width + 2,
197 menubox_border_attr, menubox_attr);
198
199 /* Find length of longest item in order to center checklist */
200 check_x = 0;
201 for (i = 0; i < item_no; i++)
202 check_x = MAX (check_x, + strlen (items[i]->name) + 4);
203
204 check_x = (list_width - check_x) / 2;
205 item_x = check_x + 4;
206
207 if (choice >= list_height) {
208 scroll = choice - list_height + 1;
209 choice -= scroll;
210 }
211
212 /* Print the list */
213 for (i = 0; i < max_choice; i++) {
214 print_item (list, items[scroll + i]->name,
215 status[i+scroll], i, i == choice);
216 }
217
218 print_arrows(dialog, choice, item_no, scroll,
219 box_y, box_x + check_x + 5, list_height);
220
221 print_buttons(dialog, height, width, 0);
222
223 wnoutrefresh (list);
224 wnoutrefresh (dialog);
225 doupdate ();
226
227 while (key != ESC) {
228 key = wgetch (dialog);
229
230 for (i = 0; i < max_choice; i++)
231 if (toupper(key) == toupper(items[scroll + i]->name[0]))
232 break;
233
234
235 if ( i < max_choice || key == KEY_UP || key == KEY_DOWN ||
236 key == '+' || key == '-' ) {
237 if (key == KEY_UP || key == '-') {
238 if (!choice) {
239 if (!scroll)
240 continue;
241 /* Scroll list down */
242 if (list_height > 1) {
243 /* De-highlight current first item */
244 print_item (list, items[scroll]->name,
245 status[scroll], 0, FALSE);
246 scrollok (list, TRUE);
247 wscrl (list, -1);
248 scrollok (list, FALSE);
249 }
250 scroll--;
251 print_item (list, items[scroll]->name,
252 status[scroll], 0, TRUE);
253 wnoutrefresh (list);
254
255 print_arrows(dialog, choice, item_no, scroll,
256 box_y, box_x + check_x + 5, list_height);
257
258 wrefresh (dialog);
259
260 continue; /* wait for another key press */
261 } else
262 i = choice - 1;
263 } else if (key == KEY_DOWN || key == '+') {
264 if (choice == max_choice - 1) {
265 if (scroll + choice >= item_no - 1)
266 continue;
267 /* Scroll list up */
268 if (list_height > 1) {
269 /* De-highlight current last item before scrolling up */
270 print_item (list, items[scroll + max_choice - 1]->name,
271 status[scroll + max_choice - 1],
272 max_choice - 1, FALSE);
273 scrollok (list, TRUE);
274 scroll (list);
275 scrollok (list, FALSE);
276 }
277 scroll++;
278 print_item (list, items[scroll + max_choice - 1]->name,
279 status[scroll + max_choice - 1],
280 max_choice - 1, TRUE);
281 wnoutrefresh (list);
282
283 print_arrows(dialog, choice, item_no, scroll,
284 box_y, box_x + check_x + 5, list_height);
285
286 wrefresh (dialog);
287
288 continue; /* wait for another key press */
289 } else
290 i = choice + 1;
291 }
292 if (i != choice) {
293 /* De-highlight current item */
294 print_item (list, items[scroll + choice]->name,
295 status[scroll + choice], choice, FALSE);
296 /* Highlight new item */
297 choice = i;
298 print_item (list, items[scroll + choice]->name,
299 status[scroll + choice], choice, TRUE);
300 wnoutrefresh (list);
301 wrefresh (dialog);
302 }
303 continue; /* wait for another key press */
304 }
305 switch (key) {
306 case 'H':
307 case 'h':
308 case '?':
309 for (i = 0; i < item_no; i++)
310 items[i]->selected = 0;
311 items[scroll + choice]->selected = 1;
312 delwin (dialog);
313 free (status);
314 return 1;
315 case TAB:
316 case KEY_LEFT:
317 case KEY_RIGHT:
318 button = ((key == KEY_LEFT ? --button : ++button) < 0)
319 ? 1 : (button > 1 ? 0 : button);
320
321 print_buttons(dialog, height, width, button);
322 wrefresh (dialog);
323 break;
324 case 'S':
325 case 's':
326 case ' ':
327 case '\n':
328 if (!button) {
329 if (flag == FLAG_CHECK) {
330 status[scroll + choice] = !status[scroll + choice];
331 wmove (list, choice, check_x);
332 wattrset (list, check_selected_attr);
333 wprintw (list, "[%c]", status[scroll + choice] ? 'X' : ' ');
334 } else {
335 if (!status[scroll + choice]) {
336 for (i = 0; i < item_no; i++)
337 status[i] = 0;
338 status[scroll + choice] = 1;
339 for (i = 0; i < max_choice; i++)
340 print_item (list, items[scroll + i]->name,
341 status[scroll + i], i, i == choice);
342 }
343 }
344 wnoutrefresh (list);
345 wrefresh (dialog);
346
347 for (i = 0; i < item_no; i++) {
348 items[i]->selected = status[i];
349 }
350 } else {
351 for (i = 0; i < item_no; i++)
352 items[i]->selected = 0;
353 items[scroll + choice]->selected = 1;
354 }
355 delwin (dialog);
356 free (status);
357 return button;
358 case 'X':
359 case 'x':
360 key = ESC;
361 case ESC:
362 break;
363 }
364
365 /* Now, update everything... */
366 doupdate ();
367 }
368
369
370 delwin (dialog);
371 free (status);
372 return -1; /* ESC pressed */
373}
diff --git a/scripts/config/lxdialog/colors.h b/scripts/config/lxdialog/colors.h
deleted file mode 100644
index 4a2d06421..000000000
--- a/scripts/config/lxdialog/colors.h
+++ /dev/null
@@ -1,162 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * colors.h -- color attribute definitions
4 *
5 * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22
23/*
24 * Default color definitions
25 *
26 * *_FG = foreground
27 * *_BG = background
28 * *_HL = highlight?
29 */
30#define SCREEN_FG COLOR_CYAN
31#define SCREEN_BG COLOR_BLUE
32#define SCREEN_HL TRUE
33
34#define SHADOW_FG COLOR_BLACK
35#define SHADOW_BG COLOR_BLACK
36#define SHADOW_HL TRUE
37
38#define DIALOG_FG COLOR_BLACK
39#define DIALOG_BG COLOR_WHITE
40#define DIALOG_HL FALSE
41
42#define TITLE_FG COLOR_YELLOW
43#define TITLE_BG COLOR_WHITE
44#define TITLE_HL TRUE
45
46#define BORDER_FG COLOR_WHITE
47#define BORDER_BG COLOR_WHITE
48#define BORDER_HL TRUE
49
50#define BUTTON_ACTIVE_FG COLOR_WHITE
51#define BUTTON_ACTIVE_BG COLOR_BLUE
52#define BUTTON_ACTIVE_HL TRUE
53
54#define BUTTON_INACTIVE_FG COLOR_BLACK
55#define BUTTON_INACTIVE_BG COLOR_WHITE
56#define BUTTON_INACTIVE_HL FALSE
57
58#define BUTTON_KEY_ACTIVE_FG COLOR_WHITE
59#define BUTTON_KEY_ACTIVE_BG COLOR_BLUE
60#define BUTTON_KEY_ACTIVE_HL TRUE
61
62#define BUTTON_KEY_INACTIVE_FG COLOR_RED
63#define BUTTON_KEY_INACTIVE_BG COLOR_WHITE
64#define BUTTON_KEY_INACTIVE_HL FALSE
65
66#define BUTTON_LABEL_ACTIVE_FG COLOR_YELLOW
67#define BUTTON_LABEL_ACTIVE_BG COLOR_BLUE
68#define BUTTON_LABEL_ACTIVE_HL TRUE
69
70#define BUTTON_LABEL_INACTIVE_FG COLOR_BLACK
71#define BUTTON_LABEL_INACTIVE_BG COLOR_WHITE
72#define BUTTON_LABEL_INACTIVE_HL TRUE
73
74#define INPUTBOX_FG COLOR_BLACK
75#define INPUTBOX_BG COLOR_WHITE
76#define INPUTBOX_HL FALSE
77
78#define INPUTBOX_BORDER_FG COLOR_BLACK
79#define INPUTBOX_BORDER_BG COLOR_WHITE
80#define INPUTBOX_BORDER_HL FALSE
81
82#define SEARCHBOX_FG COLOR_BLACK
83#define SEARCHBOX_BG COLOR_WHITE
84#define SEARCHBOX_HL FALSE
85
86#define SEARCHBOX_TITLE_FG COLOR_YELLOW
87#define SEARCHBOX_TITLE_BG COLOR_WHITE
88#define SEARCHBOX_TITLE_HL TRUE
89
90#define SEARCHBOX_BORDER_FG COLOR_WHITE
91#define SEARCHBOX_BORDER_BG COLOR_WHITE
92#define SEARCHBOX_BORDER_HL TRUE
93
94#define POSITION_INDICATOR_FG COLOR_YELLOW
95#define POSITION_INDICATOR_BG COLOR_WHITE
96#define POSITION_INDICATOR_HL TRUE
97
98#define MENUBOX_FG COLOR_BLACK
99#define MENUBOX_BG COLOR_WHITE
100#define MENUBOX_HL FALSE
101
102#define MENUBOX_BORDER_FG COLOR_WHITE
103#define MENUBOX_BORDER_BG COLOR_WHITE
104#define MENUBOX_BORDER_HL TRUE
105
106#define ITEM_FG COLOR_BLACK
107#define ITEM_BG COLOR_WHITE
108#define ITEM_HL FALSE
109
110#define ITEM_SELECTED_FG COLOR_WHITE
111#define ITEM_SELECTED_BG COLOR_BLUE
112#define ITEM_SELECTED_HL TRUE
113
114#define TAG_FG COLOR_YELLOW
115#define TAG_BG COLOR_WHITE
116#define TAG_HL TRUE
117
118#define TAG_SELECTED_FG COLOR_YELLOW
119#define TAG_SELECTED_BG COLOR_BLUE
120#define TAG_SELECTED_HL TRUE
121
122#define TAG_KEY_FG COLOR_YELLOW
123#define TAG_KEY_BG COLOR_WHITE
124#define TAG_KEY_HL TRUE
125
126#define TAG_KEY_SELECTED_FG COLOR_YELLOW
127#define TAG_KEY_SELECTED_BG COLOR_BLUE
128#define TAG_KEY_SELECTED_HL TRUE
129
130#define CHECK_FG COLOR_BLACK
131#define CHECK_BG COLOR_WHITE
132#define CHECK_HL FALSE
133
134#define CHECK_SELECTED_FG COLOR_WHITE
135#define CHECK_SELECTED_BG COLOR_BLUE
136#define CHECK_SELECTED_HL TRUE
137
138#define UARROW_FG COLOR_GREEN
139#define UARROW_BG COLOR_WHITE
140#define UARROW_HL TRUE
141
142#define DARROW_FG COLOR_GREEN
143#define DARROW_BG COLOR_WHITE
144#define DARROW_HL TRUE
145
146/* End of default color definitions */
147
148#define C_ATTR(x,y) ((x ? A_BOLD : 0) | COLOR_PAIR((y)))
149#define COLOR_NAME_LEN 10
150#define COLOR_COUNT 8
151
152/*
153 * Global variables
154 */
155
156typedef struct {
157 char name[COLOR_NAME_LEN];
158 int value;
159} color_names_st;
160
161extern color_names_st color_names[];
162extern int color_table[][3];
diff --git a/scripts/config/lxdialog/dialog.h b/scripts/config/lxdialog/dialog.h
deleted file mode 100644
index 236a68dce..000000000
--- a/scripts/config/lxdialog/dialog.h
+++ /dev/null
@@ -1,200 +0,0 @@
1/* vi: set sw=4 ts=4: */
2
3/*
4 * dialog.h -- common declarations for all dialog modules
5 *
6 * AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include <sys/types.h>
24#include <fcntl.h>
25#include <unistd.h>
26#include <ctype.h>
27#include <stdlib.h>
28#include <string.h>
29
30#ifdef CURSES_LOC
31#ifdef __sun__
32#define CURS_MACROS
33#endif
34#include CURSES_LOC
35
36/*
37 * Colors in ncurses 1.9.9e do not work properly since foreground and
38 * background colors are OR'd rather than separately masked. This version
39 * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible
40 * with standard curses. The simplest fix (to make this work with standard
41 * curses) uses the wbkgdset() function, not used in the original hack.
42 * Turn it off if we're building with 1.9.9e, since it just confuses things.
43 */
44#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE)
45#define OLD_NCURSES 1
46#undef wbkgdset
47#define wbkgdset(w,p) /*nothing*/
48#else
49#define OLD_NCURSES 0
50#endif
51
52#define TR(params) _tracef params
53
54#define ESC 27
55#define TAB 9
56#define MAX_LEN 2048
57#define BUF_SIZE (10*1024)
58#define MIN(x,y) (x < y ? x : y)
59#define MAX(x,y) (x > y ? x : y)
60
61
62#ifndef ACS_ULCORNER
63#define ACS_ULCORNER '+'
64#endif
65#ifndef ACS_LLCORNER
66#define ACS_LLCORNER '+'
67#endif
68#ifndef ACS_URCORNER
69#define ACS_URCORNER '+'
70#endif
71#ifndef ACS_LRCORNER
72#define ACS_LRCORNER '+'
73#endif
74#ifndef ACS_HLINE
75#define ACS_HLINE '-'
76#endif
77#ifndef ACS_VLINE
78#define ACS_VLINE '|'
79#endif
80#ifndef ACS_LTEE
81#define ACS_LTEE '+'
82#endif
83#ifndef ACS_RTEE
84#define ACS_RTEE '+'
85#endif
86#ifndef ACS_UARROW
87#define ACS_UARROW '^'
88#endif
89#ifndef ACS_DARROW
90#define ACS_DARROW 'v'
91#endif
92
93/*
94 * Attribute names
95 */
96#define screen_attr attributes[0]
97#define shadow_attr attributes[1]
98#define dialog_attr attributes[2]
99#define title_attr attributes[3]
100#define border_attr attributes[4]
101#define button_active_attr attributes[5]
102#define button_inactive_attr attributes[6]
103#define button_key_active_attr attributes[7]
104#define button_key_inactive_attr attributes[8]
105#define button_label_active_attr attributes[9]
106#define button_label_inactive_attr attributes[10]
107#define inputbox_attr attributes[11]
108#define inputbox_border_attr attributes[12]
109#define searchbox_attr attributes[13]
110#define searchbox_title_attr attributes[14]
111#define searchbox_border_attr attributes[15]
112#define position_indicator_attr attributes[16]
113#define menubox_attr attributes[17]
114#define menubox_border_attr attributes[18]
115#define item_attr attributes[19]
116#define item_selected_attr attributes[20]
117#define tag_attr attributes[21]
118#define tag_selected_attr attributes[22]
119#define tag_key_attr attributes[23]
120#define tag_key_selected_attr attributes[24]
121#define check_attr attributes[25]
122#define check_selected_attr attributes[26]
123#define uarrow_attr attributes[27]
124#define darrow_attr attributes[28]
125
126/* number of attributes */
127#define ATTRIBUTE_COUNT 29
128
129/*
130 * Global variables
131 */
132extern bool use_colors;
133
134extern chtype attributes[];
135#endif
136
137extern const char *backtitle;
138
139struct dialog_list_item {
140 char *name;
141 int namelen;
142 char *tag;
143 int selected; /* Set to 1 by dialog_*() function. */
144};
145
146/*
147 * Function prototypes
148 */
149
150void init_dialog (void);
151void end_dialog (void);
152void dialog_clear (void);
153#ifdef CURSES_LOC
154void attr_clear (WINDOW * win, int height, int width, chtype attr);
155void color_setup (void);
156void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x);
157void print_button (WINDOW * win, const char *label, int y, int x, int selected);
158void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box,
159 chtype border);
160void draw_shadow (WINDOW * win, int y, int x, int height, int width);
161#endif
162
163int first_alpha (const char *string, const char *exempt);
164int dialog_yesno (const char *title, const char *prompt, int height, int width);
165int dialog_msgbox (const char *title, const char *prompt, int height,
166 int width, int pause);
167int dialog_textbox (const char *title, const char *file, int height, int width);
168int dialog_menu (const char *title, const char *prompt, int height, int width,
169 int menu_height, const char *choice, int item_no,
170 struct dialog_list_item ** items);
171int dialog_checklist (const char *title, const char *prompt, int height,
172 int width, int list_height, int item_no,
173 struct dialog_list_item ** items, int flag);
174extern char dialog_input_result[];
175int dialog_inputbox (const char *title, const char *prompt, int height,
176 int width, const char *init);
177
178struct dialog_list_item *first_sel_item(int item_no,
179 struct dialog_list_item ** items);
180
181/*
182 * This is the base for fictitious keys, which activate
183 * the buttons.
184 *
185 * Mouse-generated keys are the following:
186 * -- the first 32 are used as numbers, in addition to '0'-'9'
187 * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o')
188 * -- uppercase chars are used to invoke the button (M_EVENT + 'O')
189 */
190#ifdef CURSES_LOC
191#define M_EVENT (KEY_MAX+1)
192#endif
193
194
195/*
196 * The `flag' parameter in checklist is used to select between
197 * radiolist and checklist
198 */
199#define FLAG_CHECK 1
200#define FLAG_RADIO 0
diff --git a/scripts/config/lxdialog/inputbox.c b/scripts/config/lxdialog/inputbox.c
deleted file mode 100644
index a42f8127d..000000000
--- a/scripts/config/lxdialog/inputbox.c
+++ /dev/null
@@ -1,241 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * inputbox.c -- implements the input box
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include "dialog.h"
24
25char dialog_input_result[MAX_LEN + 1];
26
27/*
28 * Print the termination buttons
29 */
30static void
31print_buttons(WINDOW *dialog, int height, int width, int selected)
32{
33 int x = width / 2 - 11;
34 int y = height - 2;
35
36 print_button (dialog, " Ok ", y, x, selected==0);
37 print_button (dialog, " Help ", y, x + 14, selected==1);
38
39 wmove(dialog, y, x+1+14*selected);
40 wrefresh(dialog);
41}
42
43/*
44 * Display a dialog box for inputing a string
45 */
46int
47dialog_inputbox (const char *title, const char *prompt, int height, int width,
48 const char *init)
49{
50 int i, x, y, box_y, box_x, box_width;
51 int input_x = 0, scroll = 0, key = 0, button = -1;
52 char *instr = dialog_input_result;
53 WINDOW *dialog;
54
55 /* center dialog box on screen */
56 x = (COLS - width) / 2;
57 y = (LINES - height) / 2;
58
59
60 draw_shadow (stdscr, y, x, height, width);
61
62 dialog = newwin (height, width, y, x);
63 keypad (dialog, TRUE);
64
65 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
66 wattrset (dialog, border_attr);
67 mvwaddch (dialog, height-3, 0, ACS_LTEE);
68 for (i = 0; i < width - 2; i++)
69 waddch (dialog, ACS_HLINE);
70 wattrset (dialog, dialog_attr);
71 waddch (dialog, ACS_RTEE);
72
73 if (title != NULL && strlen(title) >= width-2 ) {
74 /* truncate long title -- mec */
75 char * title2 = malloc(width-2+1);
76 memcpy( title2, title, width-2 );
77 title2[width-2] = '\0';
78 title = title2;
79 }
80
81 if (title != NULL) {
82 wattrset (dialog, title_attr);
83 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
84 waddstr (dialog, (char *)title);
85 waddch (dialog, ' ');
86 }
87
88 wattrset (dialog, dialog_attr);
89 print_autowrap (dialog, prompt, width - 2, 1, 3);
90
91 /* Draw the input field box */
92 box_width = width - 6;
93 getyx (dialog, y, x);
94 box_y = y + 2;
95 box_x = (width - box_width) / 2;
96 draw_box (dialog, y + 1, box_x - 1, 3, box_width + 2,
97 border_attr, dialog_attr);
98
99 print_buttons(dialog, height, width, 0);
100
101 /* Set up the initial value */
102 wmove (dialog, box_y, box_x);
103 wattrset (dialog, inputbox_attr);
104
105 if (!init)
106 instr[0] = '\0';
107 else
108 strcpy (instr, init);
109
110 input_x = strlen (instr);
111
112 if (input_x >= box_width) {
113 scroll = input_x - box_width + 1;
114 input_x = box_width - 1;
115 for (i = 0; i < box_width - 1; i++)
116 waddch (dialog, instr[scroll + i]);
117 } else
118 waddstr (dialog, instr);
119
120 wmove (dialog, box_y, box_x + input_x);
121
122 wrefresh (dialog);
123
124 while (key != ESC) {
125 key = wgetch (dialog);
126
127 if (button == -1) { /* Input box selected */
128 switch (key) {
129 case TAB:
130 case KEY_UP:
131 case KEY_DOWN:
132 break;
133 case KEY_LEFT:
134 continue;
135 case KEY_RIGHT:
136 continue;
137 case KEY_BACKSPACE:
138 case 127:
139 if (input_x || scroll) {
140 wattrset (dialog, inputbox_attr);
141 if (!input_x) {
142 scroll = scroll < box_width - 1 ?
143 0 : scroll - (box_width - 1);
144 wmove (dialog, box_y, box_x);
145 for (i = 0; i < box_width; i++)
146 waddch (dialog, instr[scroll + input_x + i] ?
147 instr[scroll + input_x + i] : ' ');
148 input_x = strlen (instr) - scroll;
149 } else
150 input_x--;
151 instr[scroll + input_x] = '\0';
152 mvwaddch (dialog, box_y, input_x + box_x, ' ');
153 wmove (dialog, box_y, input_x + box_x);
154 wrefresh (dialog);
155 }
156 continue;
157 default:
158 if (key < 0x100 && isprint (key)) {
159 if (scroll + input_x < MAX_LEN) {
160 wattrset (dialog, inputbox_attr);
161 instr[scroll + input_x] = key;
162 instr[scroll + input_x + 1] = '\0';
163 if (input_x == box_width - 1) {
164 scroll++;
165 wmove (dialog, box_y, box_x);
166 for (i = 0; i < box_width - 1; i++)
167 waddch (dialog, instr[scroll + i]);
168 } else {
169 wmove (dialog, box_y, input_x++ + box_x);
170 waddch (dialog, key);
171 }
172 wrefresh (dialog);
173 } else
174 flash (); /* Alarm user about overflow */
175 continue;
176 }
177 }
178 }
179 switch (key) {
180 case 'O':
181 case 'o':
182 delwin (dialog);
183 return 0;
184 case 'H':
185 case 'h':
186 delwin (dialog);
187 return 1;
188 case KEY_UP:
189 case KEY_LEFT:
190 switch (button) {
191 case -1:
192 button = 1; /* Indicates "Cancel" button is selected */
193 print_buttons(dialog, height, width, 1);
194 break;
195 case 0:
196 button = -1; /* Indicates input box is selected */
197 print_buttons(dialog, height, width, 0);
198 wmove (dialog, box_y, box_x + input_x);
199 wrefresh (dialog);
200 break;
201 case 1:
202 button = 0; /* Indicates "OK" button is selected */
203 print_buttons(dialog, height, width, 0);
204 break;
205 }
206 break;
207 case TAB:
208 case KEY_DOWN:
209 case KEY_RIGHT:
210 switch (button) {
211 case -1:
212 button = 0; /* Indicates "OK" button is selected */
213 print_buttons(dialog, height, width, 0);
214 break;
215 case 0:
216 button = 1; /* Indicates "Cancel" button is selected */
217 print_buttons(dialog, height, width, 1);
218 break;
219 case 1:
220 button = -1; /* Indicates input box is selected */
221 print_buttons(dialog, height, width, 0);
222 wmove (dialog, box_y, box_x + input_x);
223 wrefresh (dialog);
224 break;
225 }
226 break;
227 case ' ':
228 case '\n':
229 delwin (dialog);
230 return (button == -1 ? 0 : button);
231 case 'X':
232 case 'x':
233 key = ESC;
234 case ESC:
235 break;
236 }
237 }
238
239 delwin (dialog);
240 return -1; /* ESC pressed */
241}
diff --git a/scripts/config/lxdialog/menubox.c b/scripts/config/lxdialog/menubox.c
deleted file mode 100644
index bdaaa1040..000000000
--- a/scripts/config/lxdialog/menubox.c
+++ /dev/null
@@ -1,439 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * menubox.c -- implements the menu box
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23/*
24 * Changes by Clifford Wolf (god@clifford.at)
25 *
26 * [ 1998-06-13 ]
27 *
28 * *) A bugfix for the Page-Down problem
29 *
30 * *) Formerly when I used Page Down and Page Up, the cursor would be set
31 * to the first position in the menu box. Now lxdialog is a bit
32 * smarter and works more like other menu systems (just have a look at
33 * it).
34 *
35 * *) Formerly if I selected something my scrolling would be broken because
36 * lxdialog is re-invoked by the Menuconfig shell script, can't
37 * remember the last scrolling position, and just sets it so that the
38 * cursor is at the bottom of the box. Now it writes the temporary file
39 * lxdialog.scrltmp which contains this information. The file is
40 * deleted by lxdialog if the user leaves a submenu or enters a new
41 * one, but it would be nice if Menuconfig could make another "rm -f"
42 * just to be sure. Just try it out - you will recognise a difference!
43 *
44 * [ 1998-06-14 ]
45 *
46 * *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files
47 * and menus change their size on the fly.
48 *
49 * *) If for some reason the last scrolling position is not saved by
50 * lxdialog, it sets the scrolling so that the selected item is in the
51 * middle of the menu box, not at the bottom.
52 *
53 * 02 January 1999, Michael Elizabeth Chastain (mec@shout.net)
54 * Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus.
55 * This fixes a bug in Menuconfig where using ' ' to descend into menus
56 * would leave mis-synchronized lxdialog.scrltmp files lying around,
57 * fscanf would read in 'scroll', and eventually that value would get used.
58 */
59
60#include "dialog.h"
61
62static int menu_width, item_x;
63
64/*
65 * Print menu item
66 */
67static void
68print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey)
69{
70 int j;
71 char menu_item[menu_width+1];
72
73 strncpy(menu_item, item, menu_width);
74 menu_item[menu_width] = 0;
75 j = first_alpha(menu_item, "YyNnMmHh");
76
77 /* Clear 'residue' of last item */
78 wattrset (win, menubox_attr);
79 wmove (win, choice, 0);
80#if OLD_NCURSES
81 {
82 int i;
83 for (i = 0; i < menu_width; i++)
84 waddch (win, ' ');
85 }
86#else
87 wclrtoeol(win);
88#endif
89 wattrset (win, selected ? item_selected_attr : item_attr);
90 mvwaddstr (win, choice, item_x, menu_item);
91 if (hotkey) {
92 wattrset (win, selected ? tag_key_selected_attr : tag_key_attr);
93 mvwaddch(win, choice, item_x+j, menu_item[j]);
94 }
95 if (selected) {
96 wmove (win, choice, item_x+1);
97 wrefresh (win);
98 }
99}
100
101/*
102 * Print the scroll indicators.
103 */
104static void
105print_arrows (WINDOW * win, int item_no, int scroll,
106 int y, int x, int height)
107{
108 int cur_y, cur_x;
109
110 getyx(win, cur_y, cur_x);
111
112 wmove(win, y, x);
113
114 if (scroll > 0) {
115 wattrset (win, uarrow_attr);
116 waddch (win, ACS_UARROW);
117 waddstr (win, "(-)");
118 }
119 else {
120 wattrset (win, menubox_attr);
121 waddch (win, ACS_HLINE);
122 waddch (win, ACS_HLINE);
123 waddch (win, ACS_HLINE);
124 waddch (win, ACS_HLINE);
125 }
126
127 y = y + height + 1;
128 wmove(win, y, x);
129
130 if ((height < item_no) && (scroll + height < item_no)) {
131 wattrset (win, darrow_attr);
132 waddch (win, ACS_DARROW);
133 waddstr (win, "(+)");
134 }
135 else {
136 wattrset (win, menubox_border_attr);
137 waddch (win, ACS_HLINE);
138 waddch (win, ACS_HLINE);
139 waddch (win, ACS_HLINE);
140 waddch (win, ACS_HLINE);
141 }
142
143 wmove(win, cur_y, cur_x);
144}
145
146/*
147 * Display the termination buttons.
148 */
149static void
150print_buttons (WINDOW *win, int height, int width, int selected)
151{
152 int x = width / 2 - 16;
153 int y = height - 2;
154
155 print_button (win, "Select", y, x, selected == 0);
156 print_button (win, " Exit ", y, x + 12, selected == 1);
157 print_button (win, " Help ", y, x + 24, selected == 2);
158
159 wmove(win, y, x+1+12*selected);
160 wrefresh (win);
161}
162
163/*
164 * Display a menu for choosing among a number of options
165 */
166int
167dialog_menu (const char *title, const char *prompt, int height, int width,
168 int menu_height, const char *current, int item_no,
169 struct dialog_list_item ** items)
170{
171 int i, j, x, y, box_x, box_y;
172 int key = 0, button = 0, scroll = 0, choice = 0, first_item = 0, max_choice;
173 WINDOW *dialog, *menu;
174 FILE *f;
175
176 max_choice = MIN (menu_height, item_no);
177
178 /* center dialog box on screen */
179 x = (COLS - width) / 2;
180 y = (LINES - height) / 2;
181
182 draw_shadow (stdscr, y, x, height, width);
183
184 dialog = newwin (height, width, y, x);
185 keypad (dialog, TRUE);
186
187 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
188 wattrset (dialog, border_attr);
189 mvwaddch (dialog, height - 3, 0, ACS_LTEE);
190 for (i = 0; i < width - 2; i++)
191 waddch (dialog, ACS_HLINE);
192 wattrset (dialog, dialog_attr);
193 wbkgdset (dialog, dialog_attr & A_COLOR);
194 waddch (dialog, ACS_RTEE);
195
196 if (title != NULL && strlen(title) >= width-2 ) {
197 /* truncate long title -- mec */
198 char * title2 = malloc(width-2+1);
199 memcpy( title2, title, width-2 );
200 title2[width-2] = '\0';
201 title = title2;
202 }
203
204 if (title != NULL) {
205 wattrset (dialog, title_attr);
206 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
207 waddstr (dialog, (char *)title);
208 waddch (dialog, ' ');
209 }
210
211 wattrset (dialog, dialog_attr);
212 print_autowrap (dialog, prompt, width - 2, 1, 3);
213
214 menu_width = width - 6;
215 box_y = height - menu_height - 5;
216 box_x = (width - menu_width) / 2 - 1;
217
218 /* create new window for the menu */
219 menu = subwin (dialog, menu_height, menu_width,
220 y + box_y + 1, x + box_x + 1);
221 keypad (menu, TRUE);
222
223 /* draw a box around the menu items */
224 draw_box (dialog, box_y, box_x, menu_height + 2, menu_width + 2,
225 menubox_border_attr, menubox_attr);
226
227 /*
228 * Find length of longest item in order to center menu.
229 * Set 'choice' to default item.
230 */
231 item_x = 0;
232 for (i = 0; i < item_no; i++) {
233 item_x = MAX (item_x, MIN(menu_width, strlen (items[i]->name) + 2));
234 if (strcmp(current, items[i]->tag) == 0) choice = i;
235 }
236
237 item_x = (menu_width - item_x) / 2;
238
239 /* get the scroll info from the temp file */
240 if ( (f=fopen("lxdialog.scrltmp","r")) != NULL ) {
241 if ( (fscanf(f,"%d\n",&scroll) == 1) && (scroll <= choice) &&
242 (scroll+max_choice > choice) && (scroll >= 0) &&
243 (scroll+max_choice <= item_no) ) {
244 first_item = scroll;
245 choice = choice - scroll;
246 fclose(f);
247 } else {
248 scroll=0;
249 remove("lxdialog.scrltmp");
250 fclose(f);
251 f=NULL;
252 }
253 }
254 if ( (choice >= max_choice) || (f==NULL && choice >= max_choice/2) ) {
255 if (choice >= item_no-max_choice/2)
256 scroll = first_item = item_no-max_choice;
257 else
258 scroll = first_item = choice - max_choice/2;
259 choice = choice - scroll;
260 }
261
262 /* Print the menu */
263 for (i=0; i < max_choice; i++) {
264 print_item (menu, items[first_item + i]->name, i, i == choice,
265 (items[first_item + i]->tag[0] != ':'));
266 }
267
268 wnoutrefresh (menu);
269
270 print_arrows(dialog, item_no, scroll,
271 box_y, box_x+item_x+1, menu_height);
272
273 print_buttons (dialog, height, width, 0);
274 wmove (menu, choice, item_x+1);
275 wrefresh (menu);
276
277 while (key != ESC) {
278 key = wgetch(menu);
279
280 if (key < 256 && isalpha(key)) key = tolower(key);
281
282 if (strchr("ynmh", key))
283 i = max_choice;
284 else {
285 for (i = choice+1; i < max_choice; i++) {
286 j = first_alpha(items[scroll + i]->name, "YyNnMmHh");
287 if (key == tolower(items[scroll + i]->name[j]))
288 break;
289 }
290 if (i == max_choice)
291 for (i = 0; i < max_choice; i++) {
292 j = first_alpha(items[scroll + i]->name, "YyNnMmHh");
293 if (key == tolower(items[scroll + i]->name[j]))
294 break;
295 }
296 }
297
298 if (i < max_choice ||
299 key == KEY_UP || key == KEY_DOWN ||
300 key == '-' || key == '+' ||
301 key == KEY_PPAGE || key == KEY_NPAGE) {
302
303 print_item (menu, items[scroll + choice]->name, choice, FALSE,
304 (items[scroll + choice]->tag[0] != ':'));
305
306 if (key == KEY_UP || key == '-') {
307 if (choice < 2 && scroll) {
308 /* Scroll menu down */
309 scrollok (menu, TRUE);
310 wscrl (menu, -1);
311 scrollok (menu, FALSE);
312
313 scroll--;
314
315 print_item (menu, items[scroll]->name, 0, FALSE,
316 (items[scroll]->tag[0] != ':'));
317 } else
318 choice = MAX(choice - 1, 0);
319
320 } else if (key == KEY_DOWN || key == '+') {
321
322 print_item (menu, items[scroll + choice]->name, choice, FALSE,
323 (items[scroll + choice]->tag[0] != ':'));
324
325 if ((choice > max_choice-3) &&
326 (scroll + max_choice < item_no)
327 ) {
328 /* Scroll menu up */
329 scrollok (menu, TRUE);
330 scroll (menu);
331 scrollok (menu, FALSE);
332
333 scroll++;
334
335 print_item (menu, items[scroll + max_choice - 1]->name,
336 max_choice-1, FALSE,
337 (items[scroll + max_choice - 1]->tag[0] != ':'));
338 } else
339 choice = MIN(choice+1, max_choice-1);
340
341 } else if (key == KEY_PPAGE) {
342 scrollok (menu, TRUE);
343 for (i=0; (i < max_choice); i++) {
344 if (scroll > 0) {
345 wscrl (menu, -1);
346 scroll--;
347 print_item (menu, items[scroll]->name, 0, FALSE,
348 (items[scroll]->tag[0] != ':'));
349 } else {
350 if (choice > 0)
351 choice--;
352 }
353 }
354 scrollok (menu, FALSE);
355
356 } else if (key == KEY_NPAGE) {
357 for (i=0; (i < max_choice); i++) {
358 if (scroll+max_choice < item_no) {
359 scrollok (menu, TRUE);
360 scroll(menu);
361 scrollok (menu, FALSE);
362 scroll++;
363 print_item (menu, items[scroll + max_choice - 1]->name,
364 max_choice-1, FALSE,
365 (items[scroll + max_choice - 1]->tag[0] != ':'));
366 } else {
367 if (choice+1 < max_choice)
368 choice++;
369 }
370 }
371
372 } else
373 choice = i;
374
375 print_item (menu, items[scroll + choice]->name, choice, TRUE,
376 (items[scroll + choice]->tag[0] != ':'));
377
378 print_arrows(dialog, item_no, scroll,
379 box_y, box_x+item_x+1, menu_height);
380
381 wnoutrefresh (dialog);
382 wrefresh (menu);
383
384 continue; /* wait for another key press */
385 }
386
387 switch (key) {
388 case KEY_LEFT:
389 case TAB:
390 case KEY_RIGHT:
391 button = ((key == KEY_LEFT ? --button : ++button) < 0)
392 ? 2 : (button > 2 ? 0 : button);
393
394 print_buttons(dialog, height, width, button);
395 wrefresh (menu);
396 break;
397 case ' ':
398 case 's':
399 case 'y':
400 case 'n':
401 case 'm':
402 case '/':
403 /* save scroll info */
404 if ( (f=fopen("lxdialog.scrltmp","w")) != NULL ) {
405 fprintf(f,"%d\n",scroll);
406 fclose(f);
407 }
408 delwin (dialog);
409 items[scroll + choice]->selected = 1;
410 switch (key) {
411 case 's': return 3;
412 case 'y': return 3;
413 case 'n': return 4;
414 case 'm': return 5;
415 case ' ': return 6;
416 case '/': return 7;
417 }
418 return 0;
419 case 'h':
420 case '?':
421 button = 2;
422 case '\n':
423 delwin (dialog);
424 items[scroll + choice]->selected = 1;
425
426 remove("lxdialog.scrltmp");
427 return button;
428 case 'e':
429 case 'x':
430 key = ESC;
431 case ESC:
432 break;
433 }
434 }
435
436 delwin (dialog);
437 remove("lxdialog.scrltmp");
438 return -1; /* ESC pressed */
439}
diff --git a/scripts/config/lxdialog/msgbox.c b/scripts/config/lxdialog/msgbox.c
deleted file mode 100644
index a13bcbafb..000000000
--- a/scripts/config/lxdialog/msgbox.c
+++ /dev/null
@@ -1,86 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * msgbox.c -- implements the message box and info box
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include "dialog.h"
24
25/*
26 * Display a message box. Program will pause and display an "OK" button
27 * if the parameter 'pause' is non-zero.
28 */
29int
30dialog_msgbox (const char *title, const char *prompt, int height, int width,
31 int pause)
32{
33 int i, x, y, key = 0;
34 WINDOW *dialog;
35
36 /* center dialog box on screen */
37 x = (COLS - width) / 2;
38 y = (LINES - height) / 2;
39
40 draw_shadow (stdscr, y, x, height, width);
41
42 dialog = newwin (height, width, y, x);
43 keypad (dialog, TRUE);
44
45 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
46
47 if (title != NULL && strlen(title) >= width-2 ) {
48 /* truncate long title -- mec */
49 char * title2 = malloc(width-2+1);
50 memcpy( title2, title, width-2 );
51 title2[width-2] = '\0';
52 title = title2;
53 }
54
55 if (title != NULL) {
56 wattrset (dialog, title_attr);
57 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
58 waddstr (dialog, (char *)title);
59 waddch (dialog, ' ');
60 }
61 wattrset (dialog, dialog_attr);
62 print_autowrap (dialog, prompt, width - 2, 1, 2);
63
64 if (pause) {
65 wattrset (dialog, border_attr);
66 mvwaddch (dialog, height - 3, 0, ACS_LTEE);
67 for (i = 0; i < width - 2; i++)
68 waddch (dialog, ACS_HLINE);
69 wattrset (dialog, dialog_attr);
70 waddch (dialog, ACS_RTEE);
71
72 print_button (dialog, " Ok ",
73 height - 2, width / 2 - 4, TRUE);
74
75 wrefresh (dialog);
76 while (key != ESC && key != '\n' && key != ' ' &&
77 key != 'O' && key != 'o' && key != 'X' && key != 'x')
78 key = wgetch (dialog);
79 } else {
80 key = '\n';
81 wrefresh (dialog);
82 }
83
84 delwin (dialog);
85 return key == ESC ? -1 : 0;
86}
diff --git a/scripts/config/lxdialog/textbox.c b/scripts/config/lxdialog/textbox.c
deleted file mode 100644
index aa7f5afe2..000000000
--- a/scripts/config/lxdialog/textbox.c
+++ /dev/null
@@ -1,557 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * textbox.c -- implements the text box
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include "dialog.h"
24
25static void back_lines (int n);
26static void print_page (WINDOW * win, int height, int width);
27static void print_line (WINDOW * win, int row, int width);
28static char *get_line (void);
29static void print_position (WINDOW * win, int height, int width);
30
31static int hscroll, fd, file_size, bytes_read;
32static int begin_reached = 1, end_reached, page_length;
33static char *buf, *page;
34
35/*
36 * Display text from a file in a dialog box.
37 */
38int
39dialog_textbox (const char *title, const char *file, int height, int width)
40{
41 int i, x, y, cur_x, cur_y, fpos, key = 0;
42 int passed_end;
43 char search_term[MAX_LEN + 1];
44 WINDOW *dialog, *text;
45
46 search_term[0] = '\0'; /* no search term entered yet */
47
48 /* Open input file for reading */
49 if ((fd = open (file, O_RDONLY)) == -1) {
50 endwin ();
51 fprintf (stderr,
52 "\nCan't open input file in dialog_textbox().\n");
53 exit (-1);
54 }
55 /* Get file size. Actually, 'file_size' is the real file size - 1,
56 since it's only the last byte offset from the beginning */
57 if ((file_size = lseek (fd, 0, SEEK_END)) == -1) {
58 endwin ();
59 fprintf (stderr, "\nError getting file size in dialog_textbox().\n");
60 exit (-1);
61 }
62 /* Restore file pointer to beginning of file after getting file size */
63 if (lseek (fd, 0, SEEK_SET) == -1) {
64 endwin ();
65 fprintf (stderr, "\nError moving file pointer in dialog_textbox().\n");
66 exit (-1);
67 }
68 /* Allocate space for read buffer */
69 if ((buf = malloc (BUF_SIZE + 1)) == NULL) {
70 endwin ();
71 fprintf (stderr, "\nCan't allocate memory in dialog_textbox().\n");
72 exit (-1);
73 }
74 if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
75 endwin ();
76 fprintf (stderr, "\nError reading file in dialog_textbox().\n");
77 exit (-1);
78 }
79 buf[bytes_read] = '\0'; /* mark end of valid data */
80 page = buf; /* page is pointer to start of page to be displayed */
81
82 /* center dialog box on screen */
83 x = (COLS - width) / 2;
84 y = (LINES - height) / 2;
85
86
87 draw_shadow (stdscr, y, x, height, width);
88
89 dialog = newwin (height, width, y, x);
90 keypad (dialog, TRUE);
91
92 /* Create window for text region, used for scrolling text */
93 text = subwin (dialog, height - 4, width - 2, y + 1, x + 1);
94 wattrset (text, dialog_attr);
95 wbkgdset (text, dialog_attr & A_COLOR);
96
97 keypad (text, TRUE);
98
99 /* register the new window, along with its borders */
100 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
101
102 wattrset (dialog, border_attr);
103 mvwaddch (dialog, height-3, 0, ACS_LTEE);
104 for (i = 0; i < width - 2; i++)
105 waddch (dialog, ACS_HLINE);
106 wattrset (dialog, dialog_attr);
107 wbkgdset (dialog, dialog_attr & A_COLOR);
108 waddch (dialog, ACS_RTEE);
109
110 if (title != NULL && strlen(title) >= width-2 ) {
111 /* truncate long title -- mec */
112 char * title2 = malloc(width-2+1);
113 memcpy( title2, title, width-2 );
114 title2[width-2] = '\0';
115 title = title2;
116 }
117
118 if (title != NULL) {
119 wattrset (dialog, title_attr);
120 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
121 waddstr (dialog, (char *)title);
122 waddch (dialog, ' ');
123 }
124 print_button (dialog, " Exit ", height - 2, width / 2 - 4, TRUE);
125 wnoutrefresh (dialog);
126 getyx (dialog, cur_y, cur_x); /* Save cursor position */
127
128 /* Print first page of text */
129 attr_clear (text, height - 4, width - 2, dialog_attr);
130 print_page (text, height - 4, width - 2);
131 print_position (dialog, height, width);
132 wmove (dialog, cur_y, cur_x); /* Restore cursor position */
133 wrefresh (dialog);
134
135 while ((key != ESC) && (key != '\n')) {
136 key = wgetch (dialog);
137 switch (key) {
138 case 'E': /* Exit */
139 case 'e':
140 case 'X':
141 case 'x':
142 delwin (dialog);
143 free (buf);
144 close (fd);
145 return 0;
146 case 'g': /* First page */
147 case KEY_HOME:
148 if (!begin_reached) {
149 begin_reached = 1;
150 /* First page not in buffer? */
151 if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) {
152 endwin ();
153 fprintf (stderr,
154 "\nError moving file pointer in dialog_textbox().\n");
155 exit (-1);
156 }
157 if (fpos > bytes_read) { /* Yes, we have to read it in */
158 if (lseek (fd, 0, SEEK_SET) == -1) {
159 endwin ();
160 fprintf (stderr, "\nError moving file pointer in "
161 "dialog_textbox().\n");
162 exit (-1);
163 }
164 if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
165 endwin ();
166 fprintf (stderr,
167 "\nError reading file in dialog_textbox().\n");
168 exit (-1);
169 }
170 buf[bytes_read] = '\0';
171 }
172 page = buf;
173 print_page (text, height - 4, width - 2);
174 print_position (dialog, height, width);
175 wmove (dialog, cur_y, cur_x); /* Restore cursor position */
176 wrefresh (dialog);
177 }
178 break;
179 case 'G': /* Last page */
180 case KEY_END:
181
182 end_reached = 1;
183 /* Last page not in buffer? */
184 if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) {
185 endwin ();
186 fprintf (stderr,
187 "\nError moving file pointer in dialog_textbox().\n");
188 exit (-1);
189 }
190 if (fpos < file_size) { /* Yes, we have to read it in */
191 if (lseek (fd, -BUF_SIZE, SEEK_END) == -1) {
192 endwin ();
193 fprintf (stderr,
194 "\nError moving file pointer in dialog_textbox().\n");
195 exit (-1);
196 }
197 if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
198 endwin ();
199 fprintf (stderr,
200 "\nError reading file in dialog_textbox().\n");
201 exit (-1);
202 }
203 buf[bytes_read] = '\0';
204 }
205 page = buf + bytes_read;
206 back_lines (height - 4);
207 print_page (text, height - 4, width - 2);
208 print_position (dialog, height, width);
209 wmove (dialog, cur_y, cur_x); /* Restore cursor position */
210 wrefresh (dialog);
211 break;
212 case 'K': /* Previous line */
213 case 'k':
214 case KEY_UP:
215 if (!begin_reached) {
216 back_lines (page_length + 1);
217
218 /* We don't call print_page() here but use scrolling to ensure
219 faster screen update. However, 'end_reached' and
220 'page_length' should still be updated, and 'page' should
221 point to start of next page. This is done by calling
222 get_line() in the following 'for' loop. */
223 scrollok (text, TRUE);
224 wscrl (text, -1); /* Scroll text region down one line */
225 scrollok (text, FALSE);
226 page_length = 0;
227 passed_end = 0;
228 for (i = 0; i < height - 4; i++) {
229 if (!i) {
230 /* print first line of page */
231 print_line (text, 0, width - 2);
232 wnoutrefresh (text);
233 } else
234 /* Called to update 'end_reached' and 'page' */
235 get_line ();
236 if (!passed_end)
237 page_length++;
238 if (end_reached && !passed_end)
239 passed_end = 1;
240 }
241
242 print_position (dialog, height, width);
243 wmove (dialog, cur_y, cur_x); /* Restore cursor position */
244 wrefresh (dialog);
245 }
246 break;
247 case 'B': /* Previous page */
248 case 'b':
249 case KEY_PPAGE:
250 if (begin_reached)
251 break;
252 back_lines (page_length + height - 4);
253 print_page (text, height - 4, width - 2);
254 print_position (dialog, height, width);
255 wmove (dialog, cur_y, cur_x);
256 wrefresh (dialog);
257 break;
258 case 'J': /* Next line */
259 case 'j':
260 case KEY_DOWN:
261 if (!end_reached) {
262 begin_reached = 0;
263 scrollok (text, TRUE);
264 scroll (text); /* Scroll text region up one line */
265 scrollok (text, FALSE);
266 print_line (text, height - 5, width - 2);
267 wnoutrefresh (text);
268 print_position (dialog, height, width);
269 wmove (dialog, cur_y, cur_x); /* Restore cursor position */
270 wrefresh (dialog);
271 }
272 break;
273 case KEY_NPAGE: /* Next page */
274 case ' ':
275 if (end_reached)
276 break;
277
278 begin_reached = 0;
279 print_page (text, height - 4, width - 2);
280 print_position (dialog, height, width);
281 wmove (dialog, cur_y, cur_x);
282 wrefresh (dialog);
283 break;
284 case '0': /* Beginning of line */
285 case 'H': /* Scroll left */
286 case 'h':
287 case KEY_LEFT:
288 if (hscroll <= 0)
289 break;
290
291 if (key == '0')
292 hscroll = 0;
293 else
294 hscroll--;
295 /* Reprint current page to scroll horizontally */
296 back_lines (page_length);
297 print_page (text, height - 4, width - 2);
298 wmove (dialog, cur_y, cur_x);
299 wrefresh (dialog);
300 break;
301 case 'L': /* Scroll right */
302 case 'l':
303 case KEY_RIGHT:
304 if (hscroll >= MAX_LEN)
305 break;
306 hscroll++;
307 /* Reprint current page to scroll horizontally */
308 back_lines (page_length);
309 print_page (text, height - 4, width - 2);
310 wmove (dialog, cur_y, cur_x);
311 wrefresh (dialog);
312 break;
313 case ESC:
314 break;
315 }
316 }
317
318 delwin (dialog);
319 free (buf);
320 close (fd);
321 return 1; /* ESC pressed */
322}
323
324/*
325 * Go back 'n' lines in text file. Called by dialog_textbox().
326 * 'page' will be updated to point to the desired line in 'buf'.
327 */
328static void
329back_lines (int n)
330{
331 int i, fpos;
332
333 begin_reached = 0;
334 /* We have to distinguish between end_reached and !end_reached
335 since at end of file, the line is not ended by a '\n'.
336 The code inside 'if' basically does a '--page' to move one
337 character backward so as to skip '\n' of the previous line */
338 if (!end_reached) {
339 /* Either beginning of buffer or beginning of file reached? */
340 if (page == buf) {
341 if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) {
342 endwin ();
343 fprintf (stderr, "\nError moving file pointer in "
344 "back_lines().\n");
345 exit (-1);
346 }
347 if (fpos > bytes_read) { /* Not beginning of file yet */
348 /* We've reached beginning of buffer, but not beginning of
349 file yet, so read previous part of file into buffer.
350 Note that we only move backward for BUF_SIZE/2 bytes,
351 but not BUF_SIZE bytes to avoid re-reading again in
352 print_page() later */
353 /* Really possible to move backward BUF_SIZE/2 bytes? */
354 if (fpos < BUF_SIZE / 2 + bytes_read) {
355 /* No, move less then */
356 if (lseek (fd, 0, SEEK_SET) == -1) {
357 endwin ();
358 fprintf (stderr, "\nError moving file pointer in "
359 "back_lines().\n");
360 exit (-1);
361 }
362 page = buf + fpos - bytes_read;
363 } else { /* Move backward BUF_SIZE/2 bytes */
364 if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR)
365 == -1) {
366 endwin ();
367 fprintf (stderr, "\nError moving file pointer "
368 "in back_lines().\n");
369 exit (-1);
370 }
371 page = buf + BUF_SIZE / 2;
372 }
373 if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
374 endwin ();
375 fprintf (stderr, "\nError reading file in back_lines().\n");
376 exit (-1);
377 }
378 buf[bytes_read] = '\0';
379 } else { /* Beginning of file reached */
380 begin_reached = 1;
381 return;
382 }
383 }
384 if (*(--page) != '\n') { /* '--page' here */
385 /* Something's wrong... */
386 endwin ();
387 fprintf (stderr, "\nInternal error in back_lines().\n");
388 exit (-1);
389 }
390 }
391 /* Go back 'n' lines */
392 for (i = 0; i < n; i++)
393 do {
394 if (page == buf) {
395 if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) {
396 endwin ();
397 fprintf (stderr,
398 "\nError moving file pointer in back_lines().\n");
399 exit (-1);
400 }
401 if (fpos > bytes_read) {
402 /* Really possible to move backward BUF_SIZE/2 bytes? */
403 if (fpos < BUF_SIZE / 2 + bytes_read) {
404 /* No, move less then */
405 if (lseek (fd, 0, SEEK_SET) == -1) {
406 endwin ();
407 fprintf (stderr, "\nError moving file pointer "
408 "in back_lines().\n");
409 exit (-1);
410 }
411 page = buf + fpos - bytes_read;
412 } else { /* Move backward BUF_SIZE/2 bytes */
413 if (lseek (fd, -(BUF_SIZE / 2 + bytes_read),
414 SEEK_CUR) == -1) {
415 endwin ();
416 fprintf (stderr, "\nError moving file pointer"
417 " in back_lines().\n");
418 exit (-1);
419 }
420 page = buf + BUF_SIZE / 2;
421 }
422 if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
423 endwin ();
424 fprintf (stderr, "\nError reading file in "
425 "back_lines().\n");
426 exit (-1);
427 }
428 buf[bytes_read] = '\0';
429 } else { /* Beginning of file reached */
430 begin_reached = 1;
431 return;
432 }
433 }
434 } while (*(--page) != '\n');
435 page++;
436}
437
438/*
439 * Print a new page of text. Called by dialog_textbox().
440 */
441static void
442print_page (WINDOW * win, int height, int width)
443{
444 int i, passed_end = 0;
445
446 page_length = 0;
447 for (i = 0; i < height; i++) {
448 print_line (win, i, width);
449 if (!passed_end)
450 page_length++;
451 if (end_reached && !passed_end)
452 passed_end = 1;
453 }
454 wnoutrefresh (win);
455}
456
457/*
458 * Print a new line of text. Called by dialog_textbox() and print_page().
459 */
460static void
461print_line (WINDOW * win, int row, int width)
462{
463 int y, x;
464 char *line;
465
466 line = get_line ();
467 line += MIN (strlen (line), hscroll); /* Scroll horizontally */
468 wmove (win, row, 0); /* move cursor to correct line */
469 waddch (win, ' ');
470 waddnstr (win, line, MIN (strlen (line), width - 2));
471
472 getyx (win, y, x);
473 /* Clear 'residue' of previous line */
474#if OLD_NCURSES
475 {
476 int i;
477 for (i = 0; i < width - x; i++)
478 waddch (win, ' ');
479 }
480#else
481 wclrtoeol(win);
482#endif
483}
484
485/*
486 * Return current line of text. Called by dialog_textbox() and print_line().
487 * 'page' should point to start of current line before calling, and will be
488 * updated to point to start of next line.
489 */
490static char *
491get_line (void)
492{
493 int i = 0, fpos;
494 static char line[MAX_LEN + 1];
495
496 end_reached = 0;
497 while (*page != '\n') {
498 if (*page == '\0') {
499 /* Either end of file or end of buffer reached */
500 if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) {
501 endwin ();
502 fprintf (stderr, "\nError moving file pointer in "
503 "get_line().\n");
504 exit (-1);
505 }
506 if (fpos < file_size) { /* Not end of file yet */
507 /* We've reached end of buffer, but not end of file yet,
508 so read next part of file into buffer */
509 if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) {
510 endwin ();
511 fprintf (stderr, "\nError reading file in get_line().\n");
512 exit (-1);
513 }
514 buf[bytes_read] = '\0';
515 page = buf;
516 } else {
517 if (!end_reached)
518 end_reached = 1;
519 break;
520 }
521 } else if (i < MAX_LEN)
522 line[i++] = *(page++);
523 else {
524 /* Truncate lines longer than MAX_LEN characters */
525 if (i == MAX_LEN)
526 line[i++] = '\0';
527 page++;
528 }
529 }
530 if (i <= MAX_LEN)
531 line[i] = '\0';
532 if (!end_reached)
533 page++; /* move pass '\n' */
534
535 return line;
536}
537
538/*
539 * Print current position
540 */
541static void
542print_position (WINDOW * win, int height, int width)
543{
544 int fpos, percent;
545
546 if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) {
547 endwin ();
548 fprintf (stderr, "\nError moving file pointer in print_position().\n");
549 exit (-1);
550 }
551 wattrset (win, position_indicator_attr);
552 wbkgdset (win, position_indicator_attr & A_COLOR);
553 percent = !file_size ?
554 100 : ((fpos - bytes_read + page - buf) * 100) / file_size;
555 wmove (win, height - 3, width - 9);
556 wprintw (win, "(%3d%%)", percent);
557}
diff --git a/scripts/config/lxdialog/util.c b/scripts/config/lxdialog/util.c
deleted file mode 100644
index 26dd376b9..000000000
--- a/scripts/config/lxdialog/util.c
+++ /dev/null
@@ -1,376 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * util.c
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include "dialog.h"
24
25
26/* use colors by default? */
27bool use_colors = 1;
28
29const char *backtitle = NULL;
30
31const char *dialog_result;
32
33/*
34 * Attribute values, default is for mono display
35 */
36chtype attributes[] =
37{
38 A_NORMAL, /* screen_attr */
39 A_NORMAL, /* shadow_attr */
40 A_NORMAL, /* dialog_attr */
41 A_BOLD, /* title_attr */
42 A_NORMAL, /* border_attr */
43 A_REVERSE, /* button_active_attr */
44 A_DIM, /* button_inactive_attr */
45 A_REVERSE, /* button_key_active_attr */
46 A_BOLD, /* button_key_inactive_attr */
47 A_REVERSE, /* button_label_active_attr */
48 A_NORMAL, /* button_label_inactive_attr */
49 A_NORMAL, /* inputbox_attr */
50 A_NORMAL, /* inputbox_border_attr */
51 A_NORMAL, /* searchbox_attr */
52 A_BOLD, /* searchbox_title_attr */
53 A_NORMAL, /* searchbox_border_attr */
54 A_BOLD, /* position_indicator_attr */
55 A_NORMAL, /* menubox_attr */
56 A_NORMAL, /* menubox_border_attr */
57 A_NORMAL, /* item_attr */
58 A_REVERSE, /* item_selected_attr */
59 A_BOLD, /* tag_attr */
60 A_REVERSE, /* tag_selected_attr */
61 A_BOLD, /* tag_key_attr */
62 A_REVERSE, /* tag_key_selected_attr */
63 A_BOLD, /* check_attr */
64 A_REVERSE, /* check_selected_attr */
65 A_BOLD, /* uarrow_attr */
66 A_BOLD /* darrow_attr */
67};
68
69
70#include "colors.h"
71
72/*
73 * Table of color values
74 */
75int color_table[][3] =
76{
77 {SCREEN_FG, SCREEN_BG, SCREEN_HL},
78 {SHADOW_FG, SHADOW_BG, SHADOW_HL},
79 {DIALOG_FG, DIALOG_BG, DIALOG_HL},
80 {TITLE_FG, TITLE_BG, TITLE_HL},
81 {BORDER_FG, BORDER_BG, BORDER_HL},
82 {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL},
83 {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL},
84 {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL},
85 {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, BUTTON_KEY_INACTIVE_HL},
86 {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, BUTTON_LABEL_ACTIVE_HL},
87 {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG,
88 BUTTON_LABEL_INACTIVE_HL},
89 {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL},
90 {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL},
91 {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL},
92 {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL},
93 {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL},
94 {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL},
95 {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL},
96 {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL},
97 {ITEM_FG, ITEM_BG, ITEM_HL},
98 {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL},
99 {TAG_FG, TAG_BG, TAG_HL},
100 {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL},
101 {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL},
102 {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL},
103 {CHECK_FG, CHECK_BG, CHECK_HL},
104 {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL},
105 {UARROW_FG, UARROW_BG, UARROW_HL},
106 {DARROW_FG, DARROW_BG, DARROW_HL},
107}; /* color_table */
108
109/*
110 * Set window to attribute 'attr'
111 */
112void
113attr_clear (WINDOW * win, int height, int width, chtype attr)
114{
115 int i, j;
116
117 wattrset (win, attr);
118 for (i = 0; i < height; i++) {
119 wmove (win, i, 0);
120 for (j = 0; j < width; j++)
121 waddch (win, ' ');
122 }
123 touchwin (win);
124}
125
126void dialog_clear (void)
127{
128 attr_clear (stdscr, LINES, COLS, screen_attr);
129 /* Display background title if it exists ... - SLH */
130 if (backtitle != NULL) {
131 int i;
132
133 wattrset (stdscr, screen_attr);
134 mvwaddstr (stdscr, 0, 1, (char *)backtitle);
135 wmove (stdscr, 1, 1);
136 for (i = 1; i < COLS - 1; i++)
137 waddch (stdscr, ACS_HLINE);
138 }
139 wnoutrefresh (stdscr);
140}
141
142/*
143 * Do some initialization for dialog
144 */
145void
146init_dialog (void)
147{
148 initscr (); /* Init curses */
149 keypad (stdscr, TRUE);
150 cbreak ();
151 noecho ();
152
153
154 if (use_colors) /* Set up colors */
155 color_setup ();
156
157
158 dialog_clear ();
159}
160
161/*
162 * Setup for color display
163 */
164void
165color_setup (void)
166{
167 int i;
168
169 if (has_colors ()) { /* Terminal supports color? */
170 start_color ();
171
172 /* Initialize color pairs */
173 for (i = 0; i < ATTRIBUTE_COUNT; i++)
174 init_pair (i + 1, color_table[i][0], color_table[i][1]);
175
176 /* Setup color attributes */
177 for (i = 0; i < ATTRIBUTE_COUNT; i++)
178 attributes[i] = C_ATTR (color_table[i][2], i + 1);
179 }
180}
181
182/*
183 * End using dialog functions.
184 */
185void
186end_dialog (void)
187{
188 endwin ();
189}
190
191
192/*
193 * Print a string of text in a window, automatically wrap around to the
194 * next line if the string is too long to fit on one line. Newline
195 * characters '\n' are replaced by spaces. We start on a new line
196 * if there is no room for at least 4 nonblanks following a double-space.
197 */
198void
199print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x)
200{
201 int newl, cur_x, cur_y;
202 int i, prompt_len, room, wlen;
203 char tempstr[MAX_LEN + 1], *word, *sp, *sp2;
204
205 strcpy (tempstr, prompt);
206
207 prompt_len = strlen(tempstr);
208
209 /*
210 * Remove newlines
211 */
212 for(i=0; i<prompt_len; i++) {
213 if(tempstr[i] == '\n') tempstr[i] = ' ';
214 }
215
216 if (prompt_len <= width - x * 2) { /* If prompt is short */
217 wmove (win, y, (width - prompt_len) / 2);
218 waddstr (win, tempstr);
219 } else {
220 cur_x = x;
221 cur_y = y;
222 newl = 1;
223 word = tempstr;
224 while (word && *word) {
225 sp = strchr(word, ' ');
226 if (sp)
227 *sp++ = 0;
228
229 /* Wrap to next line if either the word does not fit,
230 or it is the first word of a new sentence, and it is
231 short, and the next word does not fit. */
232 room = width - cur_x;
233 wlen = strlen(word);
234 if (wlen > room ||
235 (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room
236 && (!(sp2 = strchr(sp, ' ')) || wlen+1+(sp2-sp) > room))) {
237 cur_y++;
238 cur_x = x;
239 }
240 wmove (win, cur_y, cur_x);
241 waddstr (win, word);
242 getyx (win, cur_y, cur_x);
243 cur_x++;
244 if (sp && *sp == ' ') {
245 cur_x++; /* double space */
246 while (*++sp == ' ');
247 newl = 1;
248 } else
249 newl = 0;
250 word = sp;
251 }
252 }
253}
254
255/*
256 * Print a button
257 */
258void
259print_button (WINDOW * win, const char *label, int y, int x, int selected)
260{
261 int i, temp;
262
263 wmove (win, y, x);
264 wattrset (win, selected ? button_active_attr : button_inactive_attr);
265 waddstr (win, "<");
266 temp = strspn (label, " ");
267 label += temp;
268 wattrset (win, selected ? button_label_active_attr
269 : button_label_inactive_attr);
270 for (i = 0; i < temp; i++)
271 waddch (win, ' ');
272 wattrset (win, selected ? button_key_active_attr
273 : button_key_inactive_attr);
274 waddch (win, label[0]);
275 wattrset (win, selected ? button_label_active_attr
276 : button_label_inactive_attr);
277 waddstr (win, (char *)label + 1);
278 wattrset (win, selected ? button_active_attr : button_inactive_attr);
279 waddstr (win, ">");
280 wmove (win, y, x + temp + 1);
281}
282
283/*
284 * Draw a rectangular box with line drawing characters
285 */
286void
287draw_box (WINDOW * win, int y, int x, int height, int width,
288 chtype box, chtype border)
289{
290 int i, j;
291
292 wattrset (win, 0);
293 for (i = 0; i < height; i++) {
294 wmove (win, y + i, x);
295 for (j = 0; j < width; j++)
296 if (!i && !j)
297 waddch (win, border | ACS_ULCORNER);
298 else if (i == height - 1 && !j)
299 waddch (win, border | ACS_LLCORNER);
300 else if (!i && j == width - 1)
301 waddch (win, box | ACS_URCORNER);
302 else if (i == height - 1 && j == width - 1)
303 waddch (win, box | ACS_LRCORNER);
304 else if (!i)
305 waddch (win, border | ACS_HLINE);
306 else if (i == height - 1)
307 waddch (win, box | ACS_HLINE);
308 else if (!j)
309 waddch (win, border | ACS_VLINE);
310 else if (j == width - 1)
311 waddch (win, box | ACS_VLINE);
312 else
313 waddch (win, box | ' ');
314 }
315}
316
317/*
318 * Draw shadows along the right and bottom edge to give a more 3D look
319 * to the boxes
320 */
321void
322draw_shadow (WINDOW * win, int y, int x, int height, int width)
323{
324 int i;
325
326 if (has_colors ()) { /* Whether terminal supports color? */
327 wattrset (win, shadow_attr);
328 wmove (win, y + height, x + 2);
329 for (i = 0; i < width; i++)
330 waddch (win, winch (win) & A_CHARTEXT);
331 for (i = y + 1; i < y + height + 1; i++) {
332 wmove (win, i, x + width);
333 waddch (win, winch (win) & A_CHARTEXT);
334 waddch (win, winch (win) & A_CHARTEXT);
335 }
336 wnoutrefresh (win);
337 }
338}
339
340/*
341 * Return the position of the first alphabetic character in a string.
342 */
343int
344first_alpha(const char *string, const char *exempt)
345{
346 int i, in_paren=0, c;
347
348 for (i = 0; i < strlen(string); i++) {
349 c = tolower(string[i]);
350
351 if (strchr("<[(", c)) ++in_paren;
352 if (strchr(">])", c) && in_paren > 0) --in_paren;
353
354 if ((! in_paren) && isalpha(c) &&
355 strchr(exempt, c) == 0)
356 return i;
357 }
358
359 return 0;
360}
361
362/*
363 * Get the first selected item in the dialog_list_item list.
364 */
365struct dialog_list_item *
366first_sel_item(int item_no, struct dialog_list_item ** items)
367{
368 int i;
369
370 for (i = 0; i < item_no; i++) {
371 if (items[i]->selected)
372 return items[i];
373 }
374
375 return NULL;
376}
diff --git a/scripts/config/lxdialog/yesno.c b/scripts/config/lxdialog/yesno.c
deleted file mode 100644
index 98562d8a9..000000000
--- a/scripts/config/lxdialog/yesno.c
+++ /dev/null
@@ -1,119 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * yesno.c -- implements the yes/no box
4 *
5 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
6 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include "dialog.h"
24
25/*
26 * Display termination buttons
27 */
28static void
29print_buttons(WINDOW *dialog, int height, int width, int selected)
30{
31 int x = width / 2 - 10;
32 int y = height - 2;
33
34 print_button (dialog, " Yes ", y, x, selected == 0);
35 print_button (dialog, " No ", y, x + 13, selected == 1);
36
37 wmove(dialog, y, x+1 + 13*selected );
38 wrefresh (dialog);
39}
40
41/*
42 * Display a dialog box with two buttons - Yes and No
43 */
44int
45dialog_yesno (const char *title, const char *prompt, int height, int width)
46{
47 int i, x, y, key = 0, button = 0;
48 WINDOW *dialog;
49
50 /* center dialog box on screen */
51 x = (COLS - width) / 2;
52 y = (LINES - height) / 2;
53
54 draw_shadow (stdscr, y, x, height, width);
55
56 dialog = newwin (height, width, y, x);
57 keypad (dialog, TRUE);
58
59 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr);
60 wattrset (dialog, border_attr);
61 mvwaddch (dialog, height-3, 0, ACS_LTEE);
62 for (i = 0; i < width - 2; i++)
63 waddch (dialog, ACS_HLINE);
64 wattrset (dialog, dialog_attr);
65 waddch (dialog, ACS_RTEE);
66
67 if (title != NULL && strlen(title) >= width-2 ) {
68 /* truncate long title -- mec */
69 char * title2 = malloc(width-2+1);
70 memcpy( title2, title, width-2 );
71 title2[width-2] = '\0';
72 title = title2;
73 }
74
75 if (title != NULL) {
76 wattrset (dialog, title_attr);
77 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' ');
78 waddstr (dialog, (char *)title);
79 waddch (dialog, ' ');
80 }
81
82 wattrset (dialog, dialog_attr);
83 print_autowrap (dialog, prompt, width - 2, 1, 3);
84
85 print_buttons(dialog, height, width, 0);
86
87 while (key != ESC) {
88 key = wgetch (dialog);
89 switch (key) {
90 case 'Y':
91 case 'y':
92 delwin (dialog);
93 return 0;
94 case 'N':
95 case 'n':
96 delwin (dialog);
97 return 1;
98
99 case TAB:
100 case KEY_LEFT:
101 case KEY_RIGHT:
102 button = ((key == KEY_LEFT ? --button : ++button) < 0)
103 ? 1 : (button > 1 ? 0 : button);
104
105 print_buttons(dialog, height, width, button);
106 wrefresh (dialog);
107 break;
108 case ' ':
109 case '\n':
110 delwin (dialog);
111 return button;
112 case ESC:
113 break;
114 }
115 }
116
117 delwin (dialog);
118 return -1; /* ESC pressed */
119}
diff --git a/scripts/config/mconf.c b/scripts/config/mconf.c
deleted file mode 100644
index b8f27e69c..000000000
--- a/scripts/config/mconf.c
+++ /dev/null
@@ -1,976 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0.
5 *
6 * Introduced single menu mode (show all sub-menus in one large tree).
7 * 2002-11-06 Petr Baudis <pasky@ucw.cz>
8 *
9 * Directly use liblxdialog library routines.
10 * 2002-11-14 Petr Baudis <pasky@ucw.cz>
11 */
12
13#include <sys/ioctl.h>
14#include <sys/wait.h>
15#include <ctype.h>
16#include <errno.h>
17#include <fcntl.h>
18#include <limits.h>
19#include <signal.h>
20#include <stdarg.h>
21#include <stdlib.h>
22#include <string.h>
23#include <termios.h>
24#include <unistd.h>
25
26#include "lxdialog/dialog.h"
27
28#define LKC_DIRECT_LINK
29#include "lkc.h"
30
31static char menu_backtitle[128];
32static const char mconf_readme[] =
33"Overview\n"
34"--------\n"
35"Some features may be built directly into BusyBox. Some features\n"
36"may be completely removed altogether. There are also certain\n"
37"parameters which are not really features, but must be\n"
38"entered in as decimal or hexadecimal numbers or possibly text.\n"
39"\n"
40"Menu items beginning with [*] or [ ] represent features\n"
41"configured to be built in or removed respectively.\n"
42"\n"
43"To change any of these features, highlight it with the cursor\n"
44"keys and press <Y> to build it in or <N> to removed it.\n"
45"You may also press the <Space Bar> to cycle\n"
46"through the available options (ie. Y->N->Y).\n"
47"\n"
48"Some additional keyboard hints:\n"
49"\n"
50"Menus\n"
51"----------\n"
52"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n"
53" you wish to change or submenu wish to select and press <Enter>.\n"
54" Submenus are designated by \"--->\".\n"
55"\n"
56" Shortcut: Press the option's highlighted letter (hotkey).\n"
57" Pressing a hotkey more than once will sequence\n"
58" through all visible items which use that hotkey.\n"
59"\n"
60" You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n"
61" unseen options into view.\n"
62"\n"
63"o To exit a menu use the cursor keys to highlight the <Exit> button\n"
64" and press <ENTER>.\n"
65"\n"
66" Shortcut: Press <ESC><ESC> or <E> or <X> if there is no hotkey\n"
67" using those letters. You may press a single <ESC>, but\n"
68" there is a delayed response which you may find annoying.\n"
69"\n"
70" Also, the <TAB> and cursor keys will cycle between <Select>,\n"
71" <Exit> and <Help>\n"
72"\n"
73"o To get help with an item, use the cursor keys to highlight <Help>\n"
74" and Press <ENTER>.\n"
75"\n"
76" Shortcut: Press <H> or <?>.\n"
77"\n"
78"\n"
79"Radiolists (Choice lists)\n"
80"-----------\n"
81"o Use the cursor keys to select the option you wish to set and press\n"
82" <S> or the <SPACE BAR>.\n"
83"\n"
84" Shortcut: Press the first letter of the option you wish to set then\n"
85" press <S> or <SPACE BAR>.\n"
86"\n"
87"o To see available help for the item, use the cursor keys to highlight\n"
88" <Help> and Press <ENTER>.\n"
89"\n"
90" Shortcut: Press <H> or <?>.\n"
91"\n"
92" Also, the <TAB> and cursor keys will cycle between <Select> and\n"
93" <Help>\n"
94"\n"
95"\n"
96"Data Entry\n"
97"-----------\n"
98"o Enter the requested information and press <ENTER>\n"
99" If you are entering hexadecimal values, it is not necessary to\n"
100" add the '0x' prefix to the entry.\n"
101"\n"
102"o For help, use the <TAB> or cursor keys to highlight the help option\n"
103" and press <ENTER>. You can try <TAB><H> as well.\n"
104"\n"
105"\n"
106"Text Box (Help Window)\n"
107"--------\n"
108"o Use the cursor keys to scroll up/down/left/right. The VI editor\n"
109" keys h,j,k,l function here as do <SPACE BAR> and <B> for those\n"
110" who are familiar with less and lynx.\n"
111"\n"
112"o Press <E>, <X>, <Enter> or <Esc><Esc> to exit.\n"
113"\n"
114"\n"
115"Alternate Configuration Files\n"
116"-----------------------------\n"
117"Menuconfig supports the use of alternate configuration files for\n"
118"those who, for various reasons, find it necessary to switch\n"
119"between different configurations.\n"
120"\n"
121"At the end of the main menu you will find two options. One is\n"
122"for saving the current configuration to a file of your choosing.\n"
123"The other option is for loading a previously saved alternate\n"
124"configuration.\n"
125"\n"
126"Even if you don't use alternate configuration files, but you\n"
127"find during a Menuconfig session that you have completely messed\n"
128"up your settings, you may use the \"Load Alternate...\" option to\n"
129"restore your previously saved settings from \".config\" without\n"
130"restarting Menuconfig.\n"
131"\n"
132"Other information\n"
133"-----------------\n"
134"If you use Menuconfig in an XTERM window make sure you have your\n"
135"$TERM variable set to point to a xterm definition which supports color.\n"
136"Otherwise, Menuconfig will look rather bad. Menuconfig will not\n"
137"display correctly in a RXVT window because rxvt displays only one\n"
138"intensity of color, bright.\n"
139"\n"
140"Menuconfig will display larger menus on screens or xterms which are\n"
141"set to display more than the standard 25 row by 80 column geometry.\n"
142"In order for this to work, the \"stty size\" command must be able to\n"
143"display the screen's current row and column geometry. I STRONGLY\n"
144"RECOMMEND that you make sure you do NOT have the shell variables\n"
145"LINES and COLUMNS exported into your environment. Some distributions\n"
146"export those variables via /etc/profile. Some ncurses programs can\n"
147"become confused when those variables (LINES & COLUMNS) don't reflect\n"
148"the true screen size.\n"
149"\n"
150"Optional personality available\n"
151"------------------------------\n"
152"If you prefer to have all of the options listed in a single\n"
153"menu, rather than the default multimenu hierarchy, run the menuconfig\n"
154"with MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
155"\n"
156"make MENUCONFIG_MODE=single_menu menuconfig\n"
157"\n"
158"<Enter> will then unroll the appropriate category, or enfold it if it\n"
159"is already unrolled.\n"
160"\n"
161"Note that this mode can eventually be a little more CPU expensive\n"
162"(especially with a larger number of unrolled categories) than the\n"
163"default mode.\n",
164menu_instructions[] =
165 "Arrow keys navigate the menu. "
166 "<Enter> selects submenus --->. "
167 "Highlighted letters are hotkeys. "
168 "Pressing <Y> selectes a feature, while <N> will exclude a feature. "
169 "Press <Esc><Esc> to exit, <?> for Help, </> for Search. "
170 "Legend: [*] feature is selected [ ] feature is excluded",
171radiolist_instructions[] =
172 "Use the arrow keys to navigate this window or "
173 "press the hotkey of the item you wish to select "
174 "followed by the <SPACE BAR>. "
175 "Press <?> for additional information about this option.",
176inputbox_instructions_int[] =
177 "Please enter a decimal value. "
178 "Fractions will not be accepted. "
179 "Use the <TAB> key to move from the input field to the buttons below it.",
180inputbox_instructions_hex[] =
181 "Please enter a hexadecimal value. "
182 "Use the <TAB> key to move from the input field to the buttons below it.",
183inputbox_instructions_string[] =
184 "Please enter a string value. "
185 "Use the <TAB> key to move from the input field to the buttons below it.",
186setmod_text[] =
187 "This feature depends on another which has been configured as a module.\n"
188 "As a result, this feature will be built as a module.",
189nohelp_text[] =
190 "There is no help available for this option.\n",
191load_config_text[] =
192 "Enter the name of the configuration file you wish to load. "
193 "Accept the name shown to restore the configuration you "
194 "last retrieved. Leave blank to abort.",
195load_config_help[] =
196 "\n"
197 "For various reasons, one may wish to keep several different BusyBox\n"
198 "configurations available on a single machine.\n"
199 "\n"
200 "If you have saved a previous configuration in a file other than the\n"
201 "BusyBox's default, entering the name of the file here will allow you\n"
202 "to modify that configuration.\n"
203 "\n"
204 "If you are uncertain, then you have probably never used alternate\n"
205 "configuration files. You should therefor leave this blank to abort.\n",
206save_config_text[] =
207 "Enter a filename to which this configuration should be saved "
208 "as an alternate. Leave blank to abort.",
209save_config_help[] =
210 "\n"
211 "For various reasons, one may wish to keep different BusyBox\n"
212 "configurations available on a single machine.\n"
213 "\n"
214 "Entering a file name here will allow you to later retrieve, modify\n"
215 "and use the current configuration as an alternate to whatever\n"
216 "configuration options you have selected at that time.\n"
217 "\n"
218 "If you are uncertain what all this means then you should probably\n"
219 "leave this blank.\n",
220search_help[] =
221 "\n"
222 "Search for CONFIG_ symbols and display their relations.\n"
223 "Example: search for \"^FOO\"\n"
224 "Result:\n"
225 "-----------------------------------------------------------------\n"
226 "Symbol: FOO [=m]\n"
227 "Prompt: Foo bus is used to drive the bar HW\n"
228 "Defined at drivers/pci/Kconfig:47\n"
229 "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
230 "Location:\n"
231 " -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n"
232 " -> PCI support (PCI [=y])\n"
233 " -> PCI access mode (<choice> [=y])\n"
234 "Selects: LIBCRC32\n"
235 "Selected by: BAR\n"
236 "-----------------------------------------------------------------\n"
237 "o The line 'Prompt:' shows the text used in the menu structure for\n"
238 " this CONFIG_ symbol\n"
239 "o The 'Defined at' line tell at what file / line number the symbol\n"
240 " is defined\n"
241 "o The 'Depends on:' line tell what symbols needs to be defined for\n"
242 " this symbol to be visible in the menu (selectable)\n"
243 "o The 'Location:' lines tell where in the menu structure this symbol\n"
244 " is located\n"
245 " A location followed by a [=y] indicate that this is a selectable\n"
246 " menu item - and current value is displayed inside brackets.\n"
247 "o The 'Selects:' line tell what symbol will be automatically\n"
248 " selected if this symbol is selected (y or m)\n"
249 "o The 'Selected by' line tell what symbol has selected this symbol\n"
250 "\n"
251 "Only relevant lines are shown.\n"
252 "\n\n"
253 "Search examples:\n"
254 "Examples: USB => find all CONFIG_ symbols containing USB\n"
255 " ^USB => find all CONFIG_ symbols starting with USB\n"
256 " USB$ => find all CONFIG_ symbols ending with USB\n"
257 "\n";
258
259static char filename[PATH_MAX+1] = ".config";
260static int indent;
261static struct termios ios_org;
262static int rows = 0, cols = 0;
263static struct menu *current_menu;
264static int child_count;
265static int single_menu_mode;
266
267static struct dialog_list_item *items[16384]; /* FIXME: This ought to be dynamic. */
268static int item_no;
269
270static void conf(struct menu *menu);
271static void conf_choice(struct menu *menu);
272static void conf_string(struct menu *menu);
273static void conf_load(void);
274static void conf_save(void);
275static void show_textbox(const char *title, const char *text, int r, int c);
276static void show_helptext(const char *title, const char *text);
277static void show_help(struct menu *menu);
278static void show_file(const char *filename, const char *title, int r, int c);
279
280static void init_wsize(void)
281{
282 struct winsize ws;
283 char *env;
284
285 if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) {
286 rows = ws.ws_row;
287 cols = ws.ws_col;
288 }
289
290 if (!rows) {
291 env = getenv("LINES");
292 if (env)
293 rows = atoi(env);
294 if (!rows)
295 rows = 24;
296 }
297 if (!cols) {
298 env = getenv("COLUMNS");
299 if (env)
300 cols = atoi(env);
301 if (!cols)
302 cols = 80;
303 }
304
305 if (rows < 19 || cols < 80) {
306 fprintf(stderr, "Your display is too small to run Menuconfig!\n");
307 fprintf(stderr, "It must be at least 19 lines by 80 columns.\n");
308 exit(1);
309 }
310
311 rows -= 4;
312 cols -= 5;
313}
314
315static void cinit(void)
316{
317 item_no = 0;
318}
319
320static void cmake(void)
321{
322 items[item_no] = malloc(sizeof(struct dialog_list_item));
323 memset(items[item_no], 0, sizeof(struct dialog_list_item));
324 items[item_no]->tag = malloc(32); items[item_no]->tag[0] = 0;
325 items[item_no]->name = malloc(512); items[item_no]->name[0] = 0;
326 items[item_no]->namelen = 0;
327 item_no++;
328}
329
330static int cprint_name(const char *fmt, ...)
331{
332 va_list ap;
333 int res;
334
335 if (!item_no)
336 cmake();
337 va_start(ap, fmt);
338 res = vsnprintf(items[item_no - 1]->name + items[item_no - 1]->namelen,
339 512 - items[item_no - 1]->namelen, fmt, ap);
340 if (res > 0)
341 items[item_no - 1]->namelen += res;
342 va_end(ap);
343
344 return res;
345}
346
347static int cprint_tag(const char *fmt, ...)
348{
349 va_list ap;
350 int res;
351
352 if (!item_no)
353 cmake();
354 va_start(ap, fmt);
355 res = vsnprintf(items[item_no - 1]->tag, 32, fmt, ap);
356 va_end(ap);
357
358 return res;
359}
360
361static void cdone(void)
362{
363 int i;
364
365 for (i = 0; i < item_no; i++) {
366 free(items[i]->tag);
367 free(items[i]->name);
368 free(items[i]);
369 }
370
371 item_no = 0;
372}
373
374static void get_prompt_str(struct gstr *r, struct property *prop)
375{
376 int i, j;
377 struct menu *submenu[8], *menu;
378
379 str_printf(r, "Prompt: %s\n", prop->text);
380 str_printf(r, " Defined at %s:%d\n", prop->menu->file->name,
381 prop->menu->lineno);
382 if (!expr_is_yes(prop->visible.expr)) {
383 str_append(r, " Depends on: ");
384 expr_gstr_print(prop->visible.expr, r);
385 str_append(r, "\n");
386 }
387 menu = prop->menu->parent;
388 for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
389 submenu[i++] = menu;
390 if (i > 0) {
391 str_printf(r, " Location:\n");
392 for (j = 4; --i >= 0; j += 2) {
393 menu = submenu[i];
394 str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu));
395 if (menu->sym) {
396 str_printf(r, " (%s [=%s])", menu->sym->name ?
397 menu->sym->name : "<choice>",
398 sym_get_string_value(menu->sym));
399 }
400 str_append(r, "\n");
401 }
402 }
403}
404
405static void get_symbol_str(struct gstr *r, struct symbol *sym)
406{
407 bool hit;
408 struct property *prop;
409
410 str_printf(r, "Symbol: %s [=%s]\n", sym->name,
411 sym_get_string_value(sym));
412 for_all_prompts(sym, prop)
413 get_prompt_str(r, prop);
414 hit = false;
415 for_all_properties(sym, prop, P_SELECT) {
416 if (!hit) {
417 str_append(r, " Selects: ");
418 hit = true;
419 } else
420 str_printf(r, " && ");
421 expr_gstr_print(prop->expr, r);
422 }
423 if (hit)
424 str_append(r, "\n");
425 if (sym->rev_dep.expr) {
426 str_append(r, " Selected by: ");
427 expr_gstr_print(sym->rev_dep.expr, r);
428 str_append(r, "\n");
429 }
430 str_append(r, "\n\n");
431}
432
433static struct gstr get_relations_str(struct symbol **sym_arr)
434{
435 struct symbol *sym;
436 struct gstr res = str_new();
437 int i;
438
439 for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
440 get_symbol_str(&res, sym);
441 if (!i)
442 str_append(&res, "No matches found.\n");
443 return res;
444}
445
446static void search_conf(void)
447{
448 struct symbol **sym_arr;
449 struct gstr res;
450
451again:
452 switch (dialog_inputbox("Search Configuration Parameter",
453 "Enter Keyword", 10, 75,
454 NULL)) {
455 case 0:
456 break;
457 case 1:
458 show_helptext("Search Configuration", search_help);
459 goto again;
460 default:
461 return;
462 }
463
464 sym_arr = sym_re_search(dialog_input_result);
465 res = get_relations_str(sym_arr);
466 free(sym_arr);
467 show_textbox("Search Results", str_get(&res), 0, 0);
468 str_free(&res);
469}
470
471static void build_conf(struct menu *menu)
472{
473 struct symbol *sym;
474 struct property *prop;
475 struct menu *child;
476 int type, tmp, doint = 2;
477 tristate val;
478 char ch;
479
480 if (!menu_is_visible(menu))
481 return;
482
483 sym = menu->sym;
484 prop = menu->prompt;
485 if (!sym) {
486 if (prop && menu != current_menu) {
487 const char *prompt = menu_get_prompt(menu);
488 switch (prop->type) {
489 case P_MENU:
490 child_count++;
491 cmake();
492 cprint_tag("m%p", menu);
493
494 if (single_menu_mode) {
495 cprint_name("%s%*c%s",
496 menu->data ? "-->" : "++>",
497 indent + 1, ' ', prompt);
498 } else {
499 cprint_name(" %*c%s --->", indent + 1, ' ', prompt);
500 }
501
502 if (single_menu_mode && menu->data)
503 goto conf_childs;
504 return;
505 default:
506 if (prompt) {
507 child_count++;
508 cmake();
509 cprint_tag(":%p", menu);
510 cprint_name("---%*c%s", indent + 1, ' ', prompt);
511 }
512 }
513 } else
514 doint = 0;
515 goto conf_childs;
516 }
517
518 cmake();
519 type = sym_get_type(sym);
520 if (sym_is_choice(sym)) {
521 struct symbol *def_sym = sym_get_choice_value(sym);
522 struct menu *def_menu = NULL;
523
524 child_count++;
525 for (child = menu->list; child; child = child->next) {
526 if (menu_is_visible(child) && child->sym == def_sym)
527 def_menu = child;
528 }
529
530 val = sym_get_tristate_value(sym);
531 if (sym_is_changable(sym)) {
532 cprint_tag("t%p", menu);
533 switch (type) {
534 case S_BOOLEAN:
535 cprint_name("[%c]", val == no ? ' ' : '*');
536 break;
537 case S_TRISTATE:
538 switch (val) {
539 case yes: ch = '*'; break;
540 case mod: ch = 'M'; break;
541 default: ch = ' '; break;
542 }
543 cprint_name("<%c>", ch);
544 break;
545 }
546 } else {
547 cprint_tag("%c%p", def_menu ? 't' : ':', menu);
548 cprint_name(" ");
549 }
550
551 cprint_name("%*c%s", indent + 1, ' ', menu_get_prompt(menu));
552 if (val == yes) {
553 if (def_menu) {
554 cprint_name(" (%s)", menu_get_prompt(def_menu));
555 cprint_name(" --->");
556 if (def_menu->list) {
557 indent += 2;
558 build_conf(def_menu);
559 indent -= 2;
560 }
561 }
562 return;
563 }
564 } else {
565 if (menu == current_menu) {
566 cprint_tag(":%p", menu);
567 cprint_name("---%*c%s", indent + 1, ' ', menu_get_prompt(menu));
568 goto conf_childs;
569 }
570 child_count++;
571 val = sym_get_tristate_value(sym);
572 if (sym_is_choice_value(sym) && val == yes) {
573 cprint_tag(":%p", menu);
574 cprint_name(" ");
575 } else {
576 switch (type) {
577 case S_BOOLEAN:
578 cprint_tag("t%p", menu);
579 if (sym_is_changable(sym))
580 cprint_name("[%c]", val == no ? ' ' : '*');
581 else
582 cprint_name("---");
583 break;
584 case S_TRISTATE:
585 cprint_tag("t%p", menu);
586 switch (val) {
587 case yes: ch = '*'; break;
588 case mod: ch = 'M'; break;
589 default: ch = ' '; break;
590 }
591 if (sym_is_changable(sym))
592 cprint_name("<%c>", ch);
593 else
594 cprint_name("---");
595 break;
596 default:
597 cprint_tag("s%p", menu);
598 tmp = cprint_name("(%s)", sym_get_string_value(sym));
599 tmp = indent - tmp + 4;
600 if (tmp < 0)
601 tmp = 0;
602 cprint_name("%*c%s%s", tmp, ' ', menu_get_prompt(menu),
603 (sym_has_value(sym) || !sym_is_changable(sym)) ?
604 "" : " (NEW)");
605 goto conf_childs;
606 }
607 }
608 cprint_name("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu),
609 (sym_has_value(sym) || !sym_is_changable(sym)) ?
610 "" : " (NEW)");
611 if (menu->prompt->type == P_MENU) {
612 cprint_name(" --->");
613 return;
614 }
615 }
616
617conf_childs:
618 indent += doint;
619 for (child = menu->list; child; child = child->next)
620 build_conf(child);
621 indent -= doint;
622}
623
624static void conf(struct menu *menu)
625{
626 struct dialog_list_item *active_item = NULL;
627 struct menu *submenu;
628 const char *prompt = menu_get_prompt(menu);
629 struct symbol *sym;
630 char active_entry[40];
631 int stat, type;
632
633 unlink("lxdialog.scrltmp");
634 active_entry[0] = 0;
635 while (1) {
636 indent = 0;
637 child_count = 0;
638 current_menu = menu;
639 cdone(); cinit();
640 build_conf(menu);
641 if (!child_count)
642 break;
643 if (menu == &rootmenu) {
644 cmake(); cprint_tag(":"); cprint_name("--- ");
645 cmake(); cprint_tag("L"); cprint_name("Load an Alternate Configuration File");
646 cmake(); cprint_tag("S"); cprint_name("Save Configuration to an Alternate File");
647 }
648 dialog_clear();
649 stat = dialog_menu(prompt ? prompt : "Main Menu",
650 menu_instructions, rows, cols, rows - 10,
651 active_entry, item_no, items);
652 if (stat < 0)
653 return;
654
655 if (stat == 1 || stat == 255)
656 break;
657
658 active_item = first_sel_item(item_no, items);
659 if (!active_item)
660 continue;
661 active_item->selected = 0;
662 strncpy(active_entry, active_item->tag, sizeof(active_entry));
663 active_entry[sizeof(active_entry)-1] = 0;
664 type = active_entry[0];
665 if (!type)
666 continue;
667
668 sym = NULL;
669 submenu = NULL;
670 if (sscanf(active_entry + 1, "%p", &submenu) == 1)
671 sym = submenu->sym;
672
673 switch (stat) {
674 case 0:
675 switch (type) {
676 case 'm':
677 if (single_menu_mode)
678 submenu->data = (void *) (long) !submenu->data;
679 else
680 conf(submenu);
681 break;
682 case 't':
683 if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
684 conf_choice(submenu);
685 else if (submenu->prompt->type == P_MENU)
686 conf(submenu);
687 break;
688 case 's':
689 conf_string(submenu);
690 break;
691 case 'L':
692 conf_load();
693 break;
694 case 'S':
695 conf_save();
696 break;
697 }
698 break;
699 case 2:
700 if (sym)
701 show_help(submenu);
702 else
703 show_helptext("README", mconf_readme);
704 break;
705 case 3:
706 if (type == 't') {
707 if (sym_set_tristate_value(sym, yes))
708 break;
709 if (sym_set_tristate_value(sym, mod))
710 show_textbox(NULL, setmod_text, 6, 74);
711 }
712 break;
713 case 4:
714 if (type == 't')
715 sym_set_tristate_value(sym, no);
716 break;
717 case 5:
718 if (type == 't')
719 sym_set_tristate_value(sym, mod);
720 break;
721 case 6:
722 if (type == 't')
723 sym_toggle_tristate_value(sym);
724 else if (type == 'm')
725 conf(submenu);
726 break;
727 case 7:
728 search_conf();
729 break;
730 }
731 }
732}
733
734static void show_textbox(const char *title, const char *text, int r, int c)
735{
736 int fd;
737
738 fd = creat(".help.tmp", 0777);
739 write(fd, text, strlen(text));
740 close(fd);
741 show_file(".help.tmp", title, r, c);
742 unlink(".help.tmp");
743}
744
745static void show_helptext(const char *title, const char *text)
746{
747 show_textbox(title, text, 0, 0);
748}
749
750static void show_help(struct menu *menu)
751{
752 struct gstr help = str_new();
753 struct symbol *sym = menu->sym;
754
755 if (sym->help)
756 {
757 if (sym->name) {
758 str_printf(&help, "%s:\n\n", sym->name);
759 str_append(&help, sym->help);
760 str_append(&help, "\n");
761 }
762 } else {
763 str_append(&help, nohelp_text);
764 }
765 get_symbol_str(&help, sym);
766 show_helptext(menu_get_prompt(menu), str_get(&help));
767 str_free(&help);
768}
769
770static void show_file(const char *filename, const char *title, int r, int c)
771{
772 while (dialog_textbox(title, filename, r ? r : rows, c ? c : cols) < 0)
773 ;
774}
775
776static void conf_choice(struct menu *menu)
777{
778 const char *prompt = menu_get_prompt(menu);
779 struct menu *child;
780 struct symbol *active;
781
782 active = sym_get_choice_value(menu->sym);
783 while (1) {
784 current_menu = menu;
785 cdone(); cinit();
786 for (child = menu->list; child; child = child->next) {
787 if (!menu_is_visible(child))
788 continue;
789 cmake();
790 cprint_tag("%p", child);
791 cprint_name("%s", menu_get_prompt(child));
792 if (child->sym == sym_get_choice_value(menu->sym))
793 items[item_no - 1]->selected = 1; /* ON */
794 else if (child->sym == active)
795 items[item_no - 1]->selected = 2; /* SELECTED */
796 else
797 items[item_no - 1]->selected = 0; /* OFF */
798 }
799
800 switch (dialog_checklist(prompt ? prompt : "Main Menu",
801 radiolist_instructions, 15, 70, 6,
802 item_no, items, FLAG_RADIO)) {
803 case 0:
804 if (sscanf(first_sel_item(item_no, items)->tag, "%p", &child) != 1)
805 break;
806 sym_set_tristate_value(child->sym, yes);
807 return;
808 case 1:
809 if (sscanf(first_sel_item(item_no, items)->tag, "%p", &child) == 1) {
810 show_help(child);
811 active = child->sym;
812 } else
813 show_help(menu);
814 break;
815 case 255:
816 return;
817 }
818 }
819}
820
821static void conf_string(struct menu *menu)
822{
823 const char *prompt = menu_get_prompt(menu);
824
825 while (1) {
826 char *heading;
827
828 switch (sym_get_type(menu->sym)) {
829 case S_INT:
830 heading = (char *) inputbox_instructions_int;
831 break;
832 case S_HEX:
833 heading = (char *) inputbox_instructions_hex;
834 break;
835 case S_STRING:
836 heading = (char *) inputbox_instructions_string;
837 break;
838 default:
839 heading = "Internal mconf error!";
840 /* panic? */;
841 }
842
843 switch (dialog_inputbox(prompt ? prompt : "Main Menu",
844 heading, 10, 75,
845 sym_get_string_value(menu->sym))) {
846 case 0:
847 if (sym_set_string_value(menu->sym, dialog_input_result))
848 return;
849 show_textbox(NULL, "You have made an invalid entry.", 5, 43);
850 break;
851 case 1:
852 show_help(menu);
853 break;
854 case 255:
855 return;
856 }
857 }
858}
859
860static void conf_load(void)
861{
862 while (1) {
863 switch (dialog_inputbox(NULL, load_config_text, 11, 55,
864 filename)) {
865 case 0:
866 if (!dialog_input_result[0])
867 return;
868 if (!conf_read(dialog_input_result))
869 return;
870 show_textbox(NULL, "File does not exist!", 5, 38);
871 break;
872 case 1:
873 show_helptext("Load Alternate Configuration", load_config_help);
874 break;
875 case 255:
876 return;
877 }
878 }
879}
880
881static void conf_save(void)
882{
883 while (1) {
884 switch (dialog_inputbox(NULL, save_config_text, 11, 55,
885 filename)) {
886 case 0:
887 if (!dialog_input_result[0])
888 return;
889 if (!conf_write(dialog_input_result))
890 return;
891 show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60);
892 break;
893 case 1:
894 show_helptext("Save Alternate Configuration", save_config_help);
895 break;
896 case 255:
897 return;
898 }
899 }
900}
901
902static void conf_cleanup(void)
903{
904 tcsetattr(1, TCSAFLUSH, &ios_org);
905 unlink(".help.tmp");
906}
907
908static void winch_handler(int sig)
909{
910 struct winsize ws;
911
912 if (ioctl(1, TIOCGWINSZ, &ws) == -1) {
913 rows = 24;
914 cols = 80;
915 } else {
916 rows = ws.ws_row;
917 cols = ws.ws_col;
918 }
919
920 if (rows < 19 || cols < 80) {
921 end_dialog();
922 fprintf(stderr, "Your display is too small to run Menuconfig!\n");
923 fprintf(stderr, "It must be at least 19 lines by 80 columns.\n");
924 exit(1);
925 }
926
927 rows -= 4;
928 cols -= 5;
929
930}
931
932int main(int ac, char **av)
933{
934 struct symbol *sym;
935 char *mode;
936 int stat;
937
938 conf_parse(av[1]);
939 conf_read(NULL);
940
941 sym = sym_lookup("VERSION", 0);
942 sym_calc_value(sym);
943 snprintf(menu_backtitle, 128, "BusyBox v%s Configuration",
944 sym_get_string_value(sym));
945
946 mode = getenv("MENUCONFIG_MODE");
947 if (mode) {
948 if (!strcasecmp(mode, "single_menu"))
949 single_menu_mode = 1;
950 }
951
952 tcgetattr(1, &ios_org);
953 atexit(conf_cleanup);
954 init_wsize();
955 init_dialog();
956 signal(SIGWINCH, winch_handler);
957 conf(&rootmenu);
958 end_dialog();
959
960 /* Restart dialog to act more like when lxdialog was still separate */
961 init_dialog();
962 do {
963 stat = dialog_yesno(NULL,
964 "Do you wish to save your new BusyBox configuration?", 5, 60);
965 } while (stat < 0);
966 end_dialog();
967
968 if (stat == 0) {
969 conf_write(NULL);
970 printf("\n"
971 "*** End of BusyBox configuration.\n");
972 } else
973 printf("\n\nYour BusyBox configuration changes were NOT saved.\n\n");
974
975 return 0;
976}
diff --git a/scripts/config/menu.c b/scripts/config/menu.c
deleted file mode 100644
index 7e97e8330..000000000
--- a/scripts/config/menu.c
+++ /dev/null
@@ -1,391 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0.
5 */
6
7#include <stdlib.h>
8#include <string.h>
9
10#define LKC_DIRECT_LINK
11#include "lkc.h"
12
13struct menu rootmenu;
14static struct menu **last_entry_ptr;
15
16struct file *file_list;
17struct file *current_file;
18
19static void menu_warn(struct menu *menu, const char *fmt, ...)
20{
21 va_list ap;
22 va_start(ap, fmt);
23 fprintf(stderr, "%s:%d:warning: ", menu->file->name, menu->lineno);
24 vfprintf(stderr, fmt, ap);
25 fprintf(stderr, "\n");
26 va_end(ap);
27}
28
29static void prop_warn(struct property *prop, const char *fmt, ...)
30{
31 va_list ap;
32 va_start(ap, fmt);
33 fprintf(stderr, "%s:%d:warning: ", prop->file->name, prop->lineno);
34 vfprintf(stderr, fmt, ap);
35 fprintf(stderr, "\n");
36 va_end(ap);
37}
38
39void menu_init(void)
40{
41 current_entry = current_menu = &rootmenu;
42 last_entry_ptr = &rootmenu.list;
43}
44
45void menu_add_entry(struct symbol *sym)
46{
47 struct menu *menu;
48
49 menu = malloc(sizeof(*menu));
50 memset(menu, 0, sizeof(*menu));
51 menu->sym = sym;
52 menu->parent = current_menu;
53 menu->file = current_file;
54 menu->lineno = zconf_lineno();
55
56 *last_entry_ptr = menu;
57 last_entry_ptr = &menu->next;
58 current_entry = menu;
59}
60
61void menu_end_entry(void)
62{
63}
64
65void menu_add_menu(void)
66{
67 current_menu = current_entry;
68 last_entry_ptr = &current_entry->list;
69}
70
71void menu_end_menu(void)
72{
73 last_entry_ptr = &current_menu->next;
74 current_menu = current_menu->parent;
75}
76
77struct expr *menu_check_dep(struct expr *e)
78{
79 if (!e)
80 return e;
81
82 switch (e->type) {
83 case E_NOT:
84 e->left.expr = menu_check_dep(e->left.expr);
85 break;
86 case E_OR:
87 case E_AND:
88 e->left.expr = menu_check_dep(e->left.expr);
89 e->right.expr = menu_check_dep(e->right.expr);
90 break;
91 case E_SYMBOL:
92 /* change 'm' into 'm' && MODULES */
93 if (e->left.sym == &symbol_mod)
94 return expr_alloc_and(e, expr_alloc_symbol(modules_sym));
95 break;
96 default:
97 break;
98 }
99 return e;
100}
101
102void menu_add_dep(struct expr *dep)
103{
104 current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep));
105}
106
107void menu_set_type(int type)
108{
109 struct symbol *sym = current_entry->sym;
110
111 if (sym->type == type)
112 return;
113 if (sym->type == S_UNKNOWN) {
114 sym->type = type;
115 return;
116 }
117 menu_warn(current_entry, "type of '%s' redefined from '%s' to '%s'\n",
118 sym->name ? sym->name : "<choice>",
119 sym_type_name(sym->type), sym_type_name(type));
120}
121
122struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)
123{
124 struct property *prop = prop_alloc(type, current_entry->sym);
125
126 prop->menu = current_entry;
127 prop->text = prompt;
128 prop->expr = expr;
129 prop->visible.expr = menu_check_dep(dep);
130
131 if (prompt) {
132 if (current_entry->prompt)
133 menu_warn(current_entry, "prompt redefined\n");
134 current_entry->prompt = prop;
135 }
136
137 return prop;
138}
139
140void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep)
141{
142 menu_add_prop(type, prompt, NULL, dep);
143}
144
145void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep)
146{
147 menu_add_prop(type, NULL, expr, dep);
148}
149
150void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
151{
152 menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep);
153}
154
155void sym_check_prop(struct symbol *sym)
156{
157 struct property *prop;
158 struct symbol *sym2;
159 for (prop = sym->prop; prop; prop = prop->next) {
160 switch (prop->type) {
161 case P_DEFAULT:
162 if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) &&
163 prop->expr->type != E_SYMBOL)
164 prop_warn(prop,
165 "default for config symbol '%'"
166 " must be a single symbol", sym->name);
167 break;
168 case P_SELECT:
169 sym2 = prop_get_symbol(prop);
170 if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE)
171 prop_warn(prop,
172 "config symbol '%s' uses select, but is "
173 "not boolean or tristate", sym->name);
174 else if (sym2->type == S_UNKNOWN)
175 prop_warn(prop,
176 "'select' used by config symbol '%s' "
177 "refer to undefined symbol '%s'",
178 sym->name, sym2->name);
179 else if (sym2->type != S_BOOLEAN && sym2->type != S_TRISTATE)
180 prop_warn(prop,
181 "'%s' has wrong type. 'select' only "
182 "accept arguments of boolean and "
183 "tristate type", sym2->name);
184 break;
185 case P_RANGE:
186 if (sym->type != S_INT && sym->type != S_HEX)
187 prop_warn(prop, "range is only allowed "
188 "for int or hex symbols");
189 if (!sym_string_valid(sym, prop->expr->left.sym->name) ||
190 !sym_string_valid(sym, prop->expr->right.sym->name))
191 prop_warn(prop, "range is invalid");
192 break;
193 default:
194 ;
195 }
196 }
197}
198
199void menu_finalize(struct menu *parent)
200{
201 struct menu *menu, *last_menu;
202 struct symbol *sym;
203 struct property *prop;
204 struct expr *parentdep, *basedep, *dep, *dep2, **ep;
205
206 sym = parent->sym;
207 if (parent->list) {
208 if (sym && sym_is_choice(sym)) {
209 /* find the first choice value and find out choice type */
210 for (menu = parent->list; menu; menu = menu->next) {
211 if (menu->sym) {
212 current_entry = parent;
213 menu_set_type(menu->sym->type);
214 current_entry = menu;
215 menu_set_type(sym->type);
216 break;
217 }
218 }
219 parentdep = expr_alloc_symbol(sym);
220 } else if (parent->prompt)
221 parentdep = parent->prompt->visible.expr;
222 else
223 parentdep = parent->dep;
224
225 for (menu = parent->list; menu; menu = menu->next) {
226 basedep = expr_transform(menu->dep);
227 basedep = expr_alloc_and(expr_copy(parentdep), basedep);
228 basedep = expr_eliminate_dups(basedep);
229 menu->dep = basedep;
230 if (menu->sym)
231 prop = menu->sym->prop;
232 else
233 prop = menu->prompt;
234 for (; prop; prop = prop->next) {
235 if (prop->menu != menu)
236 continue;
237 dep = expr_transform(prop->visible.expr);
238 dep = expr_alloc_and(expr_copy(basedep), dep);
239 dep = expr_eliminate_dups(dep);
240 if (menu->sym && menu->sym->type != S_TRISTATE)
241 dep = expr_trans_bool(dep);
242 prop->visible.expr = dep;
243 if (prop->type == P_SELECT) {
244 struct symbol *es = prop_get_symbol(prop);
245 es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr,
246 expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep)));
247 }
248 }
249 }
250 for (menu = parent->list; menu; menu = menu->next)
251 menu_finalize(menu);
252 } else if (sym) {
253 basedep = parent->prompt ? parent->prompt->visible.expr : NULL;
254 basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
255 basedep = expr_eliminate_dups(expr_transform(basedep));
256 last_menu = NULL;
257 for (menu = parent->next; menu; menu = menu->next) {
258 dep = menu->prompt ? menu->prompt->visible.expr : menu->dep;
259 if (!expr_contains_symbol(dep, sym))
260 break;
261 if (expr_depends_symbol(dep, sym))
262 goto next;
263 dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no);
264 dep = expr_eliminate_dups(expr_transform(dep));
265 dep2 = expr_copy(basedep);
266 expr_eliminate_eq(&dep, &dep2);
267 expr_free(dep);
268 if (!expr_is_yes(dep2)) {
269 expr_free(dep2);
270 break;
271 }
272 expr_free(dep2);
273 next:
274 menu_finalize(menu);
275 menu->parent = parent;
276 last_menu = menu;
277 }
278 if (last_menu) {
279 parent->list = parent->next;
280 parent->next = last_menu->next;
281 last_menu->next = NULL;
282 }
283 }
284 for (menu = parent->list; menu; menu = menu->next) {
285 if (sym && sym_is_choice(sym) && menu->sym) {
286 menu->sym->flags |= SYMBOL_CHOICEVAL;
287 if (!menu->prompt)
288 menu_warn(menu, "choice value must have a prompt");
289 for (prop = menu->sym->prop; prop; prop = prop->next) {
290 if (prop->type == P_PROMPT && prop->menu != menu) {
291 prop_warn(prop, "choice values "
292 "currently only support a "
293 "single prompt");
294 }
295 if (prop->type == P_DEFAULT)
296 prop_warn(prop, "defaults for choice "
297 "values not supported");
298 }
299 current_entry = menu;
300 menu_set_type(sym->type);
301 menu_add_symbol(P_CHOICE, sym, NULL);
302 prop = sym_get_choice_prop(sym);
303 for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr)
304 ;
305 *ep = expr_alloc_one(E_CHOICE, NULL);
306 (*ep)->right.sym = menu->sym;
307 }
308 if (menu->list && (!menu->prompt || !menu->prompt->text)) {
309 for (last_menu = menu->list; ; last_menu = last_menu->next) {
310 last_menu->parent = parent;
311 if (!last_menu->next)
312 break;
313 }
314 last_menu->next = menu->next;
315 menu->next = menu->list;
316 menu->list = NULL;
317 }
318 }
319
320 if (sym && !(sym->flags & SYMBOL_WARNED)) {
321 if (sym->type == S_UNKNOWN)
322 menu_warn(parent, "config symbol defined "
323 "without type\n");
324
325 if (sym_is_choice(sym) && !parent->prompt)
326 menu_warn(parent, "choice must have a prompt\n");
327
328 /* Check properties connected to this symbol */
329 sym_check_prop(sym);
330 sym->flags |= SYMBOL_WARNED;
331 }
332
333 if (sym && !sym_is_optional(sym) && parent->prompt) {
334 sym->rev_dep.expr = expr_alloc_or(sym->rev_dep.expr,
335 expr_alloc_and(parent->prompt->visible.expr,
336 expr_alloc_symbol(&symbol_mod)));
337 }
338}
339
340bool menu_is_visible(struct menu *menu)
341{
342 struct menu *child;
343 struct symbol *sym;
344 tristate visible;
345
346 if (!menu->prompt)
347 return false;
348 sym = menu->sym;
349 if (sym) {
350 sym_calc_value(sym);
351 visible = menu->prompt->visible.tri;
352 } else
353 visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr);
354
355 if (visible != no)
356 return true;
357 if (!sym || sym_get_tristate_value(menu->sym) == no)
358 return false;
359
360 for (child = menu->list; child; child = child->next)
361 if (menu_is_visible(child))
362 return true;
363 return false;
364}
365
366const char *menu_get_prompt(struct menu *menu)
367{
368 if (menu->prompt)
369 return menu->prompt->text;
370 else if (menu->sym)
371 return menu->sym->name;
372 return NULL;
373}
374
375struct menu *menu_get_root_menu(struct menu *menu)
376{
377 return &rootmenu;
378}
379
380struct menu *menu_get_parent_menu(struct menu *menu)
381{
382 enum prop_type type;
383
384 for (; menu != &rootmenu; menu = menu->parent) {
385 type = menu->prompt ? menu->prompt->type : 0;
386 if (type == P_MENU)
387 break;
388 }
389 return menu;
390}
391
diff --git a/scripts/config/mkconfigs b/scripts/config/mkconfigs
deleted file mode 100755
index fda9de72f..000000000
--- a/scripts/config/mkconfigs
+++ /dev/null
@@ -1,51 +0,0 @@
1#!/bin/sh
2#
3# Copyright (C) 2002 Khalid Aziz <khalid_aziz at hp.com>
4# Copyright (C) 2002 Randy Dunlap <rddunlap at osdl.org>
5# Copyright (C) 2002 Al Stone <ahs3 at fc.hp.com>
6# Copyright (C) 2002 Hewlett-Packard Company
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21#
22# Busybox version by Matteo Croce <3297627799 at wind.it>
23#
24# Rules to generate bbconfig.h from .config:
25# - Retain lines that begin with "CONFIG_"
26# - Retain lines that begin with "# CONFIG_"
27# - lines that use double-quotes must \\-escape-quote them
28
29if [ $# -lt 1 ]
30then
31 config=.config
32else config=$1
33fi
34
35echo "#ifndef _BBCONFIGOPTS_H"
36echo "#define _BBCONFIGOPTS_H"
37echo \
38"/*
39 * busybox configuration settings.
40 *
41 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
42 *
43 * This file is generated automatically by scripts/config/mkconfigs.
44 * Do not edit.
45 *
46 */"
47
48echo "static const char * const bbconfig_config ="
49echo "`sed 's/\"/\\\\\"/g' $config | grep "^#\? \?CONFIG_" | awk '{print "\\"" $0 "\\\\n\\"";}'`"
50echo ";"
51echo "#endif /* _BBCONFIGOPTS_H */"
diff --git a/scripts/config/symbol.c b/scripts/config/symbol.c
deleted file mode 100644
index aeea4cc9f..000000000
--- a/scripts/config/symbol.c
+++ /dev/null
@@ -1,810 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0.
5 */
6
7#include <ctype.h>
8#include <stdlib.h>
9#include <string.h>
10#include <regex.h>
11#include <sys/utsname.h>
12
13#define LKC_DIRECT_LINK
14#include "lkc.h"
15
16struct symbol symbol_yes = {
17 .name = "y",
18 .curr = { "y", yes },
19 .flags = SYMBOL_YES|SYMBOL_VALID,
20}, symbol_mod = {
21 .name = "m",
22 .curr = { "m", mod },
23 .flags = SYMBOL_MOD|SYMBOL_VALID,
24}, symbol_no = {
25 .name = "n",
26 .curr = { "n", no },
27 .flags = SYMBOL_NO|SYMBOL_VALID,
28}, symbol_empty = {
29 .name = "",
30 .curr = { "", no },
31 .flags = SYMBOL_VALID,
32};
33
34int sym_change_count;
35struct symbol *modules_sym;
36tristate modules_val;
37
38void sym_add_default(struct symbol *sym, const char *def)
39{
40 struct property *prop = prop_alloc(P_DEFAULT, sym);
41
42 prop->expr = expr_alloc_symbol(sym_lookup(def, 1));
43}
44
45void sym_init(void)
46{
47 struct symbol *sym;
48 char *p;
49 static bool inited = false;
50
51 if (inited)
52 return;
53 inited = true;
54
55 sym = sym_lookup("VERSION", 0);
56 sym->type = S_STRING;
57 sym->flags |= SYMBOL_AUTO;
58 p = getenv("VERSION");
59 if (p)
60 sym_add_default(sym, p);
61
62 sym = sym_lookup("TARGET_ARCH", 0);
63 sym->type = S_STRING;
64 sym->flags |= SYMBOL_AUTO;
65 p = getenv("TARGET_ARCH");
66 if (p)
67 sym_add_default(sym, p);
68
69}
70
71enum symbol_type sym_get_type(struct symbol *sym)
72{
73 enum symbol_type type = sym->type;
74
75 if (type == S_TRISTATE) {
76 if (sym_is_choice_value(sym) && sym->visible == yes)
77 type = S_BOOLEAN;
78 else if (modules_val == no)
79 type = S_BOOLEAN;
80 }
81 return type;
82}
83
84const char *sym_type_name(enum symbol_type type)
85{
86 switch (type) {
87 case S_BOOLEAN:
88 return "boolean";
89 case S_TRISTATE:
90 return "tristate";
91 case S_INT:
92 return "integer";
93 case S_HEX:
94 return "hex";
95 case S_STRING:
96 return "string";
97 case S_UNKNOWN:
98 return "unknown";
99 case S_OTHER:
100 break;
101 }
102 return "???";
103}
104
105struct property *sym_get_choice_prop(struct symbol *sym)
106{
107 struct property *prop;
108
109 for_all_choices(sym, prop)
110 return prop;
111 return NULL;
112}
113
114struct property *sym_get_default_prop(struct symbol *sym)
115{
116 struct property *prop;
117
118 for_all_defaults(sym, prop) {
119 prop->visible.tri = expr_calc_value(prop->visible.expr);
120 if (prop->visible.tri != no)
121 return prop;
122 }
123 return NULL;
124}
125
126struct property *sym_get_range_prop(struct symbol *sym)
127{
128 struct property *prop;
129
130 for_all_properties(sym, prop, P_RANGE) {
131 prop->visible.tri = expr_calc_value(prop->visible.expr);
132 if (prop->visible.tri != no)
133 return prop;
134 }
135 return NULL;
136}
137
138static void sym_calc_visibility(struct symbol *sym)
139{
140 struct property *prop;
141 tristate tri;
142
143 /* any prompt visible? */
144 tri = no;
145 for_all_prompts(sym, prop) {
146 prop->visible.tri = expr_calc_value(prop->visible.expr);
147 tri = E_OR(tri, prop->visible.tri);
148 }
149 if (tri == mod && (sym->type != S_TRISTATE || modules_val == no))
150 tri = yes;
151 if (sym->visible != tri) {
152 sym->visible = tri;
153 sym_set_changed(sym);
154 }
155 if (sym_is_choice_value(sym))
156 return;
157 tri = no;
158 if (sym->rev_dep.expr)
159 tri = expr_calc_value(sym->rev_dep.expr);
160 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
161 tri = yes;
162 if (sym->rev_dep.tri != tri) {
163 sym->rev_dep.tri = tri;
164 sym_set_changed(sym);
165 }
166}
167
168static struct symbol *sym_calc_choice(struct symbol *sym)
169{
170 struct symbol *def_sym;
171 struct property *prop;
172 struct expr *e;
173
174 /* is the user choice visible? */
175 def_sym = sym->user.val;
176 if (def_sym) {
177 sym_calc_visibility(def_sym);
178 if (def_sym->visible != no)
179 return def_sym;
180 }
181
182 /* any of the defaults visible? */
183 for_all_defaults(sym, prop) {
184 prop->visible.tri = expr_calc_value(prop->visible.expr);
185 if (prop->visible.tri == no)
186 continue;
187 def_sym = prop_get_symbol(prop);
188 sym_calc_visibility(def_sym);
189 if (def_sym->visible != no)
190 return def_sym;
191 }
192
193 /* just get the first visible value */
194 prop = sym_get_choice_prop(sym);
195 for (e = prop->expr; e; e = e->left.expr) {
196 def_sym = e->right.sym;
197 sym_calc_visibility(def_sym);
198 if (def_sym->visible != no)
199 return def_sym;
200 }
201
202 /* no choice? reset tristate value */
203 sym->curr.tri = no;
204 return NULL;
205}
206
207void sym_calc_value(struct symbol *sym)
208{
209 struct symbol_value newval, oldval;
210 struct property *prop;
211 struct expr *e;
212
213 if (!sym)
214 return;
215
216 if (sym->flags & SYMBOL_VALID)
217 return;
218 sym->flags |= SYMBOL_VALID;
219
220 oldval = sym->curr;
221
222 switch (sym->type) {
223 case S_INT:
224 case S_HEX:
225 case S_STRING:
226 newval = symbol_empty.curr;
227 break;
228 case S_BOOLEAN:
229 case S_TRISTATE:
230 newval = symbol_no.curr;
231 break;
232 default:
233 sym->curr.val = sym->name;
234 sym->curr.tri = no;
235 return;
236 }
237 if (!sym_is_choice_value(sym))
238 sym->flags &= ~SYMBOL_WRITE;
239
240 sym_calc_visibility(sym);
241
242 /* set default if recursively called */
243 sym->curr = newval;
244
245 switch (sym_get_type(sym)) {
246 case S_BOOLEAN:
247 case S_TRISTATE:
248 if (sym_is_choice_value(sym) && sym->visible == yes) {
249 prop = sym_get_choice_prop(sym);
250 newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
251 } else if (E_OR(sym->visible, sym->rev_dep.tri) != no) {
252 sym->flags |= SYMBOL_WRITE;
253 if (sym_has_value(sym))
254 newval.tri = sym->user.tri;
255 else if (!sym_is_choice(sym)) {
256 prop = sym_get_default_prop(sym);
257 if (prop)
258 newval.tri = expr_calc_value(prop->expr);
259 }
260 newval.tri = E_OR(E_AND(newval.tri, sym->visible), sym->rev_dep.tri);
261 } else if (!sym_is_choice(sym)) {
262 prop = sym_get_default_prop(sym);
263 if (prop) {
264 sym->flags |= SYMBOL_WRITE;
265 newval.tri = expr_calc_value(prop->expr);
266 }
267 }
268 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
269 newval.tri = yes;
270 break;
271 case S_STRING:
272 case S_HEX:
273 case S_INT:
274 if (sym->visible != no) {
275 sym->flags |= SYMBOL_WRITE;
276 if (sym_has_value(sym)) {
277 newval.val = sym->user.val;
278 break;
279 }
280 }
281 prop = sym_get_default_prop(sym);
282 if (prop) {
283 struct symbol *ds = prop_get_symbol(prop);
284 if (ds) {
285 sym->flags |= SYMBOL_WRITE;
286 sym_calc_value(ds);
287 newval.val = ds->curr.val;
288 }
289 }
290 break;
291 default:
292 ;
293 }
294
295 sym->curr = newval;
296 if (sym_is_choice(sym) && newval.tri == yes)
297 sym->curr.val = sym_calc_choice(sym);
298
299 if (memcmp(&oldval, &sym->curr, sizeof(oldval)))
300 sym_set_changed(sym);
301 if (modules_sym == sym)
302 modules_val = modules_sym->curr.tri;
303
304 if (sym_is_choice(sym)) {
305 int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
306 prop = sym_get_choice_prop(sym);
307 for (e = prop->expr; e; e = e->left.expr) {
308 e->right.sym->flags |= flags;
309 if (flags & SYMBOL_CHANGED)
310 sym_set_changed(e->right.sym);
311 }
312 }
313}
314
315void sym_clear_all_valid(void)
316{
317 struct symbol *sym;
318 int i;
319
320 for_all_symbols(i, sym)
321 sym->flags &= ~SYMBOL_VALID;
322 sym_change_count++;
323 if (modules_sym)
324 sym_calc_value(modules_sym);
325}
326
327void sym_set_changed(struct symbol *sym)
328{
329 struct property *prop;
330
331 sym->flags |= SYMBOL_CHANGED;
332 for (prop = sym->prop; prop; prop = prop->next) {
333 if (prop->menu)
334 prop->menu->flags |= MENU_CHANGED;
335 }
336}
337
338void sym_set_all_changed(void)
339{
340 struct symbol *sym;
341 int i;
342
343 for_all_symbols(i, sym)
344 sym_set_changed(sym);
345}
346
347bool sym_tristate_within_range(struct symbol *sym, tristate val)
348{
349 int type = sym_get_type(sym);
350
351 if (sym->visible == no)
352 return false;
353
354 if (type != S_BOOLEAN && type != S_TRISTATE)
355 return false;
356
357 if (type == S_BOOLEAN && val == mod)
358 return false;
359 if (sym->visible <= sym->rev_dep.tri)
360 return false;
361 if (sym_is_choice_value(sym) && sym->visible == yes)
362 return val == yes;
363 return val >= sym->rev_dep.tri && val <= sym->visible;
364}
365
366bool sym_set_tristate_value(struct symbol *sym, tristate val)
367{
368 tristate oldval = sym_get_tristate_value(sym);
369
370 if (oldval != val && !sym_tristate_within_range(sym, val))
371 return false;
372
373 if (sym->flags & SYMBOL_NEW) {
374 sym->flags &= ~SYMBOL_NEW;
375 sym_set_changed(sym);
376 }
377 if (sym_is_choice_value(sym) && val == yes) {
378 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
379
380 cs->user.val = sym;
381 cs->flags &= ~SYMBOL_NEW;
382 }
383
384 sym->user.tri = val;
385 if (oldval != val) {
386 sym_clear_all_valid();
387 if (sym == modules_sym)
388 sym_set_all_changed();
389 }
390
391 return true;
392}
393
394tristate sym_toggle_tristate_value(struct symbol *sym)
395{
396 tristate oldval, newval;
397
398 oldval = newval = sym_get_tristate_value(sym);
399 do {
400 switch (newval) {
401 case no:
402 newval = mod;
403 break;
404 case mod:
405 newval = yes;
406 break;
407 case yes:
408 newval = no;
409 break;
410 }
411 if (sym_set_tristate_value(sym, newval))
412 break;
413 } while (oldval != newval);
414 return newval;
415}
416
417bool sym_string_valid(struct symbol *sym, const char *str)
418{
419 signed char ch;
420
421 switch (sym->type) {
422 case S_STRING:
423 return true;
424 case S_INT:
425 ch = *str++;
426 if (ch == '-')
427 ch = *str++;
428 if (!isdigit(ch))
429 return false;
430 if (ch == '0' && *str != 0)
431 return false;
432 while ((ch = *str++)) {
433 if (!isdigit(ch))
434 return false;
435 }
436 return true;
437 case S_HEX:
438 if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
439 str += 2;
440 ch = *str++;
441 do {
442 if (!isxdigit(ch))
443 return false;
444 } while ((ch = *str++));
445 return true;
446 case S_BOOLEAN:
447 case S_TRISTATE:
448 switch (str[0]) {
449 case 'y': case 'Y':
450 case 'm': case 'M':
451 case 'n': case 'N':
452 return true;
453 }
454 return false;
455 default:
456 return false;
457 }
458}
459
460bool sym_string_within_range(struct symbol *sym, const char *str)
461{
462 struct property *prop;
463 int val;
464
465 switch (sym->type) {
466 case S_STRING:
467 return sym_string_valid(sym, str);
468 case S_INT:
469 if (!sym_string_valid(sym, str))
470 return false;
471 prop = sym_get_range_prop(sym);
472 if (!prop)
473 return true;
474 val = strtol(str, NULL, 10);
475 return val >= strtol(prop->expr->left.sym->name, NULL, 10) &&
476 val <= strtol(prop->expr->right.sym->name, NULL, 10);
477 case S_HEX:
478 if (!sym_string_valid(sym, str))
479 return false;
480 prop = sym_get_range_prop(sym);
481 if (!prop)
482 return true;
483 val = strtol(str, NULL, 16);
484 return val >= strtol(prop->expr->left.sym->name, NULL, 16) &&
485 val <= strtol(prop->expr->right.sym->name, NULL, 16);
486 case S_BOOLEAN:
487 case S_TRISTATE:
488 switch (str[0]) {
489 case 'y': case 'Y':
490 return sym_tristate_within_range(sym, yes);
491 case 'm': case 'M':
492 return sym_tristate_within_range(sym, mod);
493 case 'n': case 'N':
494 return sym_tristate_within_range(sym, no);
495 }
496 return false;
497 default:
498 return false;
499 }
500}
501
502bool sym_set_string_value(struct symbol *sym, const char *newval)
503{
504 const char *oldval;
505 char *val;
506 int size;
507
508 switch (sym->type) {
509 case S_BOOLEAN:
510 case S_TRISTATE:
511 switch (newval[0]) {
512 case 'y': case 'Y':
513 return sym_set_tristate_value(sym, yes);
514 case 'm': case 'M':
515 return sym_set_tristate_value(sym, mod);
516 case 'n': case 'N':
517 return sym_set_tristate_value(sym, no);
518 }
519 return false;
520 default:
521 ;
522 }
523
524 if (!sym_string_within_range(sym, newval))
525 return false;
526
527 if (sym->flags & SYMBOL_NEW) {
528 sym->flags &= ~SYMBOL_NEW;
529 sym_set_changed(sym);
530 }
531
532 oldval = sym->user.val;
533 size = strlen(newval) + 1;
534 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
535 size += 2;
536 sym->user.val = val = malloc(size);
537 *val++ = '0';
538 *val++ = 'x';
539 } else if (!oldval || strcmp(oldval, newval))
540 sym->user.val = val = malloc(size);
541 else
542 return true;
543
544 strcpy(val, newval);
545 free((void *)oldval);
546 sym_clear_all_valid();
547
548 return true;
549}
550
551const char *sym_get_string_value(struct symbol *sym)
552{
553 tristate val;
554
555 switch (sym->type) {
556 case S_BOOLEAN:
557 case S_TRISTATE:
558 val = sym_get_tristate_value(sym);
559 switch (val) {
560 case no:
561 return "n";
562 case mod:
563 return "m";
564 case yes:
565 return "y";
566 }
567 break;
568 default:
569 ;
570 }
571 return (const char *)sym->curr.val;
572}
573
574bool sym_is_changable(struct symbol *sym)
575{
576 return sym->visible > sym->rev_dep.tri;
577}
578
579struct symbol *sym_lookup(const char *name, int isconst)
580{
581 struct symbol *symbol;
582 const char *ptr;
583 char *new_name;
584 int hash = 0;
585
586 if (name) {
587 if (name[0] && !name[1]) {
588 switch (name[0]) {
589 case 'y': return &symbol_yes;
590 case 'm': return &symbol_mod;
591 case 'n': return &symbol_no;
592 }
593 }
594 for (ptr = name; *ptr; ptr++)
595 hash += *ptr;
596 hash &= 0xff;
597
598 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
599 if (!strcmp(symbol->name, name)) {
600 if ((isconst && symbol->flags & SYMBOL_CONST) ||
601 (!isconst && !(symbol->flags & SYMBOL_CONST)))
602 return symbol;
603 }
604 }
605 new_name = strdup(name);
606 } else {
607 new_name = NULL;
608 hash = 256;
609 }
610
611 symbol = malloc(sizeof(*symbol));
612 memset(symbol, 0, sizeof(*symbol));
613 symbol->name = new_name;
614 symbol->type = S_UNKNOWN;
615 symbol->flags = SYMBOL_NEW;
616 if (isconst)
617 symbol->flags |= SYMBOL_CONST;
618
619 symbol->next = symbol_hash[hash];
620 symbol_hash[hash] = symbol;
621
622 return symbol;
623}
624
625struct symbol *sym_find(const char *name)
626{
627 struct symbol *symbol = NULL;
628 const char *ptr;
629 int hash = 0;
630
631 if (!name)
632 return NULL;
633
634 if (name[0] && !name[1]) {
635 switch (name[0]) {
636 case 'y': return &symbol_yes;
637 case 'm': return &symbol_mod;
638 case 'n': return &symbol_no;
639 }
640 }
641 for (ptr = name; *ptr; ptr++)
642 hash += *ptr;
643 hash &= 0xff;
644
645 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
646 if (!strcmp(symbol->name, name) &&
647 !(symbol->flags & SYMBOL_CONST))
648 break;
649 }
650
651 return symbol;
652}
653
654struct symbol **sym_re_search(const char *pattern)
655{
656 struct symbol *sym, **sym_arr = NULL;
657 int i, cnt, size;
658 regex_t re;
659
660 cnt = size = 0;
661 /* Skip if empty */
662 if (strlen(pattern) == 0)
663 return NULL;
664 if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE))
665 return NULL;
666
667 for_all_symbols(i, sym) {
668 if (sym->flags & SYMBOL_CONST || !sym->name)
669 continue;
670 if (regexec(&re, sym->name, 0, NULL, 0))
671 continue;
672 if (cnt + 1 >= size) {
673 void *tmp = sym_arr;
674 size += 16;
675 sym_arr = realloc(sym_arr, size * sizeof(struct symbol *));
676 if (!sym_arr) {
677 free(tmp);
678 return NULL;
679 }
680 }
681 sym_arr[cnt++] = sym;
682 }
683 if (sym_arr)
684 sym_arr[cnt] = NULL;
685 regfree(&re);
686
687 return sym_arr;
688}
689
690
691struct symbol *sym_check_deps(struct symbol *sym);
692
693static struct symbol *sym_check_expr_deps(struct expr *e)
694{
695 struct symbol *sym;
696
697 if (!e)
698 return NULL;
699 switch (e->type) {
700 case E_OR:
701 case E_AND:
702 sym = sym_check_expr_deps(e->left.expr);
703 if (sym)
704 return sym;
705 return sym_check_expr_deps(e->right.expr);
706 case E_NOT:
707 return sym_check_expr_deps(e->left.expr);
708 case E_EQUAL:
709 case E_UNEQUAL:
710 sym = sym_check_deps(e->left.sym);
711 if (sym)
712 return sym;
713 return sym_check_deps(e->right.sym);
714 case E_SYMBOL:
715 return sym_check_deps(e->left.sym);
716 default:
717 break;
718 }
719 printf("Oops! How to check %d?\n", e->type);
720 return NULL;
721}
722
723struct symbol *sym_check_deps(struct symbol *sym)
724{
725 struct symbol *sym2;
726 struct property *prop;
727
728 if (sym->flags & SYMBOL_CHECK_DONE)
729 return NULL;
730 if (sym->flags & SYMBOL_CHECK) {
731 printf("Warning! Found recursive dependency: %s", sym->name);
732 return sym;
733 }
734
735 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
736 sym2 = sym_check_expr_deps(sym->rev_dep.expr);
737 if (sym2)
738 goto out;
739
740 for (prop = sym->prop; prop; prop = prop->next) {
741 if (prop->type == P_CHOICE || prop->type == P_SELECT)
742 continue;
743 sym2 = sym_check_expr_deps(prop->visible.expr);
744 if (sym2)
745 goto out;
746 if (prop->type != P_DEFAULT || sym_is_choice(sym))
747 continue;
748 sym2 = sym_check_expr_deps(prop->expr);
749 if (sym2)
750 goto out;
751 }
752out:
753 if (sym2)
754 printf(" %s", sym->name);
755 sym->flags &= ~SYMBOL_CHECK;
756 return sym2;
757}
758
759struct property *prop_alloc(enum prop_type type, struct symbol *sym)
760{
761 struct property *prop;
762 struct property **propp;
763
764 prop = malloc(sizeof(*prop));
765 memset(prop, 0, sizeof(*prop));
766 prop->type = type;
767 prop->sym = sym;
768 prop->file = current_file;
769 prop->lineno = zconf_lineno();
770
771 /* append property to the prop list of symbol */
772 if (sym) {
773 for (propp = &sym->prop; *propp; propp = &(*propp)->next)
774 ;
775 *propp = prop;
776 }
777
778 return prop;
779}
780
781struct symbol *prop_get_symbol(struct property *prop)
782{
783 if (prop->expr && (prop->expr->type == E_SYMBOL ||
784 prop->expr->type == E_CHOICE))
785 return prop->expr->left.sym;
786 return NULL;
787}
788
789const char *prop_get_type_name(enum prop_type type)
790{
791 switch (type) {
792 case P_PROMPT:
793 return "prompt";
794 case P_COMMENT:
795 return "comment";
796 case P_MENU:
797 return "menu";
798 case P_DEFAULT:
799 return "default";
800 case P_CHOICE:
801 return "choice";
802 case P_SELECT:
803 return "select";
804 case P_RANGE:
805 return "range";
806 case P_UNKNOWN:
807 break;
808 }
809 return "unknown";
810}
diff --git a/scripts/config/util.c b/scripts/config/util.c
deleted file mode 100644
index dbf23edef..000000000
--- a/scripts/config/util.c
+++ /dev/null
@@ -1,110 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Copyright (C) 2002-2005 Roman Zippel <zippel@linux-m68k.org>
4 * Copyright (C) 2002-2005 Sam Ravnborg <sam@ravnborg.org>
5 *
6 * Released under the terms of the GNU GPL v2.0.
7 */
8
9#include <string.h>
10#include "lkc.h"
11
12/* file already present in list? If not add it */
13struct file *file_lookup(const char *name)
14{
15 struct file *file;
16
17 for (file = file_list; file; file = file->next) {
18 if (!strcmp(name, file->name))
19 return file;
20 }
21
22 file = malloc(sizeof(*file));
23 memset(file, 0, sizeof(*file));
24 file->name = strdup(name);
25 file->next = file_list;
26 file_list = file;
27 return file;
28}
29
30/* write a dependency file as used by kbuild to track dependencies */
31int file_write_dep(const char *name)
32{
33 struct file *file;
34 FILE *out;
35
36 if (!name)
37 name = ".config.cmd";
38 out = fopen(".config.tmp", "w");
39 if (!out)
40 return 1;
41 fprintf(out, "deps_config := \\\n");
42 for (file = file_list; file; file = file->next) {
43 if (file->next)
44 fprintf(out, "\t%s \\\n", file->name);
45 else
46 fprintf(out, "\t%s\n", file->name);
47 }
48 fprintf(out, "\n.config include/config.h: $(deps_config)\n\n$(deps_config):\n");
49 fclose(out);
50 rename(".config.tmp", name);
51 return 0;
52}
53
54
55/* Allocate initial growable sting */
56struct gstr str_new(void)
57{
58 struct gstr gs;
59 gs.s = malloc(sizeof(char) * 64);
60 gs.len = 16;
61 strcpy(gs.s, "\0");
62 return gs;
63}
64
65/* Allocate and assign growable string */
66struct gstr str_assign(const char *s)
67{
68 struct gstr gs;
69 gs.s = strdup(s);
70 gs.len = strlen(s) + 1;
71 return gs;
72}
73
74/* Free storage for growable string */
75void str_free(struct gstr *gs)
76{
77 if (gs->s)
78 free(gs->s);
79 gs->s = NULL;
80 gs->len = 0;
81}
82
83/* Append to growable string */
84void str_append(struct gstr *gs, const char *s)
85{
86 size_t l = strlen(gs->s) + strlen(s) + 1;
87 if (l > gs->len) {
88 gs->s = realloc(gs->s, l);
89 gs->len = l;
90 }
91 strcat(gs->s, s);
92}
93
94/* Append printf formatted string to growable string */
95void str_printf(struct gstr *gs, const char *fmt, ...)
96{
97 va_list ap;
98 char s[10000]; /* big enough... */
99 va_start(ap, fmt);
100 vsnprintf(s, sizeof(s), fmt, ap);
101 str_append(gs, s);
102 va_end(ap);
103}
104
105/* Retreive value of growable string */
106const char *str_get(struct gstr *gs)
107{
108 return gs->s;
109}
110
diff --git a/scripts/config/zconf.l b/scripts/config/zconf.l
deleted file mode 100644
index 55517b287..000000000
--- a/scripts/config/zconf.l
+++ /dev/null
@@ -1,366 +0,0 @@
1%option backup nostdinit noyywrap never-interactive full ecs
2%option 8bit backup nodefault perf-report perf-report
3%x COMMAND HELP STRING PARAM
4%{
5/*
6 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
7 * Released under the terms of the GNU GPL v2.0.
8 */
9
10#include <limits.h>
11#include <stdio.h>
12#include <stdlib.h>
13#include <string.h>
14#include <unistd.h>
15
16#define LKC_DIRECT_LINK
17#include "lkc.h"
18
19#define START_STRSIZE 16
20
21char *text;
22static char *text_ptr;
23static int text_size, text_asize;
24
25struct buffer {
26 struct buffer *parent;
27 YY_BUFFER_STATE state;
28};
29
30struct buffer *current_buf;
31
32static int last_ts, first_ts;
33
34static void zconf_endhelp(void);
35static struct buffer *zconf_endfile(void);
36
37void new_string(void)
38{
39 text = malloc(START_STRSIZE);
40 text_asize = START_STRSIZE;
41 text_ptr = text;
42 text_size = 0;
43 *text_ptr = 0;
44}
45
46void append_string(const char *str, int size)
47{
48 int new_size = text_size + size + 1;
49 if (new_size > text_asize) {
50 text = realloc(text, new_size);
51 text_asize = new_size;
52 text_ptr = text + text_size;
53 }
54 memcpy(text_ptr, str, size);
55 text_ptr += size;
56 text_size += size;
57 *text_ptr = 0;
58}
59
60void alloc_string(const char *str, int size)
61{
62 text = malloc(size + 1);
63 memcpy(text, str, size);
64 text[size] = 0;
65}
66%}
67
68ws [ \n\t]
69n [A-Za-z0-9_]
70
71%%
72 int str = 0;
73 int ts, i;
74
75[ \t]*#.*\n current_file->lineno++;
76[ \t]*#.*
77
78[ \t]*\n current_file->lineno++; return T_EOL;
79
80[ \t]+ {
81 BEGIN(COMMAND);
82}
83
84. {
85 unput(yytext[0]);
86 BEGIN(COMMAND);
87}
88
89
90<COMMAND>{
91 "mainmenu" BEGIN(PARAM); return T_MAINMENU;
92 "menu" BEGIN(PARAM); return T_MENU;
93 "endmenu" BEGIN(PARAM); return T_ENDMENU;
94 "source" BEGIN(PARAM); return T_SOURCE;
95 "choice" BEGIN(PARAM); return T_CHOICE;
96 "endchoice" BEGIN(PARAM); return T_ENDCHOICE;
97 "comment" BEGIN(PARAM); return T_COMMENT;
98 "config" BEGIN(PARAM); return T_CONFIG;
99 "menuconfig" BEGIN(PARAM); return T_MENUCONFIG;
100 "help" BEGIN(PARAM); return T_HELP;
101 "if" BEGIN(PARAM); return T_IF;
102 "endif" BEGIN(PARAM); return T_ENDIF;
103 "depends" BEGIN(PARAM); return T_DEPENDS;
104 "requires" BEGIN(PARAM); return T_REQUIRES;
105 "optional" BEGIN(PARAM); return T_OPTIONAL;
106 "default" BEGIN(PARAM); return T_DEFAULT;
107 "prompt" BEGIN(PARAM); return T_PROMPT;
108 "tristate" BEGIN(PARAM); return T_TRISTATE;
109 "def_tristate" BEGIN(PARAM); return T_DEF_TRISTATE;
110 "bool" 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;
114 "int" BEGIN(PARAM); return T_INT;
115 "hex" BEGIN(PARAM); return T_HEX;
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;
120 {n}+ {
121 alloc_string(yytext, yyleng);
122 zconflval.string = text;
123 return T_WORD;
124 }
125 .
126 \n current_file->lineno++; BEGIN(INITIAL);
127}
128
129<PARAM>{
130 "&&" return T_AND;
131 "||" return T_OR;
132 "(" return T_OPEN_PAREN;
133 ")" return T_CLOSE_PAREN;
134 "!" return T_NOT;
135 "=" return T_EQUAL;
136 "!=" return T_UNEQUAL;
137 "if" return T_IF;
138 "on" return T_ON;
139 \"|\' {
140 str = yytext[0];
141 new_string();
142 BEGIN(STRING);
143 }
144 \n BEGIN(INITIAL); current_file->lineno++; return T_EOL;
145 --- /* ignore */
146 ({n}|[-/.])+ {
147 alloc_string(yytext, yyleng);
148 zconflval.string = text;
149 return T_WORD;
150 }
151 #.* /* comment */
152 \\\n current_file->lineno++;
153 .
154 <<EOF>> {
155 BEGIN(INITIAL);
156 }
157}
158
159<STRING>{
160 [^'"\\\n]+/\n {
161 append_string(yytext, yyleng);
162 zconflval.string = text;
163 return T_WORD_QUOTE;
164 }
165 [^'"\\\n]+ {
166 append_string(yytext, yyleng);
167 }
168 \\.?/\n {
169 append_string(yytext + 1, yyleng - 1);
170 zconflval.string = text;
171 return T_WORD_QUOTE;
172 }
173 \\.? {
174 append_string(yytext + 1, yyleng - 1);
175 }
176 \'|\" {
177 if (str == yytext[0]) {
178 BEGIN(PARAM);
179 zconflval.string = text;
180 return T_WORD_QUOTE;
181 } else
182 append_string(yytext, 1);
183 }
184 \n {
185 printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno());
186 current_file->lineno++;
187 BEGIN(INITIAL);
188 return T_EOL;
189 }
190 <<EOF>> {
191 BEGIN(INITIAL);
192 }
193}
194
195<HELP>{
196 [ \t]+ {
197 ts = 0;
198 for (i = 0; i < yyleng; i++) {
199 if (yytext[i] == '\t')
200 ts = (ts & ~7) + 8;
201 else
202 ts++;
203 }
204 last_ts = ts;
205 if (first_ts) {
206 if (ts < first_ts) {
207 zconf_endhelp();
208 return T_HELPTEXT;
209 }
210 ts -= first_ts;
211 while (ts > 8) {
212 append_string(" ", 8);
213 ts -= 8;
214 }
215 append_string(" ", ts);
216 }
217 }
218 [ \t]*\n/[^ \t\n] {
219 current_file->lineno++;
220 zconf_endhelp();
221 return T_HELPTEXT;
222 }
223 [ \t]*\n {
224 current_file->lineno++;
225 append_string("\n", 1);
226 }
227 [^ \t\n].* {
228 append_string(yytext, yyleng);
229 if (!first_ts)
230 first_ts = last_ts;
231 }
232 <<EOF>> {
233 zconf_endhelp();
234 return T_HELPTEXT;
235 }
236}
237
238<<EOF>> {
239 if (current_buf) {
240 zconf_endfile();
241 return T_EOF;
242 }
243 fclose(yyin);
244 yyterminate();
245}
246
247%%
248void zconf_starthelp(void)
249{
250 new_string();
251 last_ts = first_ts = 0;
252 BEGIN(HELP);
253}
254
255static void zconf_endhelp(void)
256{
257 zconflval.string = text;
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;
284}
285
286void zconf_initscan(const char *name)
287{
288 yyin = zconf_fopen(name);
289 if (!yyin) {
290 printf("can't find file %s\n", name);
291 exit(1);
292 }
293
294 current_buf = malloc(sizeof(*current_buf));
295 memset(current_buf, 0, sizeof(*current_buf));
296
297 current_file = file_lookup(name);
298 current_file->lineno = 1;
299 current_file->flags = FILE_BUSY;
300}
301
302void zconf_nextfile(const char *name)
303{
304 struct file *file = file_lookup(name);
305 struct buffer *buf = malloc(sizeof(*buf));
306 memset(buf, 0, sizeof(*buf));
307
308 current_buf->state = YY_CURRENT_BUFFER;
309 yyin = zconf_fopen(name);
310 if (!yyin) {
311 printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name);
312 exit(1);
313 }
314 yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
315 buf->parent = current_buf;
316 current_buf = buf;
317
318 if (file->flags & FILE_BUSY) {
319 printf("recursive scan (%s)?\n", name);
320 exit(1);
321 }
322 if (file->flags & FILE_SCANNED) {
323 printf("file %s already scanned?\n", name);
324 exit(1);
325 }
326 file->flags |= FILE_BUSY;
327 file->lineno = 1;
328 file->parent = current_file;
329 current_file = file;
330}
331
332static struct buffer *zconf_endfile(void)
333{
334 struct buffer *parent;
335
336 current_file->flags |= FILE_SCANNED;
337 current_file->flags &= ~FILE_BUSY;
338 current_file = current_file->parent;
339
340 parent = current_buf->parent;
341 if (parent) {
342 fclose(yyin);
343 yy_delete_buffer(YY_CURRENT_BUFFER);
344 yy_switch_to_buffer(parent->state);
345 }
346 free(current_buf);
347 current_buf = parent;
348
349 return parent;
350}
351
352int zconf_lineno(void)
353{
354 if (current_buf)
355 return current_file->lineno - 1;
356 else
357 return 0;
358}
359
360char *zconf_curname(void)
361{
362 if (current_buf)
363 return current_file->name;
364 else
365 return "<none>";
366}
diff --git a/scripts/config/zconf.tab.c_shipped b/scripts/config/zconf.tab.c_shipped
deleted file mode 100644
index 0bf511e30..000000000
--- a/scripts/config/zconf.tab.c_shipped
+++ /dev/null
@@ -1,2130 +0,0 @@
1/* A Bison parser, made by GNU Bison 1.875a. */
2
3/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29/* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36/* Identify Bison output. */
37#define YYBISON 1
38
39/* Skeleton name. */
40#define YYSKELETON_NAME "yacc.c"
41
42/* Pure parsers. */
43#define YYPURE 0
44
45/* Using locations. */
46#define YYLSP_NEEDED 0
47
48/* If NAME_PREFIX is specified substitute the variables and functions
49 names. */
50#define yyparse zconfparse
51#define yylex zconflex
52#define yyerror zconferror
53#define yylval zconflval
54#define yychar zconfchar
55#define yydebug zconfdebug
56#define yynerrs zconfnerrs
57
58
59/* Tokens. */
60#ifndef YYTOKENTYPE
61# define YYTOKENTYPE
62 /* Put the tokens into the symbol table, so that GDB and other debuggers
63 know about them. */
64 enum yytokentype {
65 T_MAINMENU = 258,
66 T_MENU = 259,
67 T_ENDMENU = 260,
68 T_SOURCE = 261,
69 T_CHOICE = 262,
70 T_ENDCHOICE = 263,
71 T_COMMENT = 264,
72 T_CONFIG = 265,
73 T_MENUCONFIG = 266,
74 T_HELP = 267,
75 T_HELPTEXT = 268,
76 T_IF = 269,
77 T_ENDIF = 270,
78 T_DEPENDS = 271,
79 T_REQUIRES = 272,
80 T_OPTIONAL = 273,
81 T_PROMPT = 274,
82 T_DEFAULT = 275,
83 T_TRISTATE = 276,
84 T_DEF_TRISTATE = 277,
85 T_BOOLEAN = 278,
86 T_DEF_BOOLEAN = 279,
87 T_STRING = 280,
88 T_INT = 281,
89 T_HEX = 282,
90 T_WORD = 283,
91 T_WORD_QUOTE = 284,
92 T_UNEQUAL = 285,
93 T_EOF = 286,
94 T_EOL = 287,
95 T_CLOSE_PAREN = 288,
96 T_OPEN_PAREN = 289,
97 T_ON = 290,
98 T_SELECT = 291,
99 T_RANGE = 292,
100 T_OR = 293,
101 T_AND = 294,
102 T_EQUAL = 295,
103 T_NOT = 296
104 };
105#endif
106#define T_MAINMENU 258
107#define T_MENU 259
108#define T_ENDMENU 260
109#define T_SOURCE 261
110#define T_CHOICE 262
111#define T_ENDCHOICE 263
112#define T_COMMENT 264
113#define T_CONFIG 265
114#define T_MENUCONFIG 266
115#define T_HELP 267
116#define T_HELPTEXT 268
117#define T_IF 269
118#define T_ENDIF 270
119#define T_DEPENDS 271
120#define T_REQUIRES 272
121#define T_OPTIONAL 273
122#define T_PROMPT 274
123#define T_DEFAULT 275
124#define T_TRISTATE 276
125#define T_DEF_TRISTATE 277
126#define T_BOOLEAN 278
127#define T_DEF_BOOLEAN 279
128#define T_STRING 280
129#define T_INT 281
130#define T_HEX 282
131#define T_WORD 283
132#define T_WORD_QUOTE 284
133#define T_UNEQUAL 285
134#define T_EOF 286
135#define T_EOL 287
136#define T_CLOSE_PAREN 288
137#define T_OPEN_PAREN 289
138#define T_ON 290
139#define T_SELECT 291
140#define T_RANGE 292
141#define T_OR 293
142#define T_AND 294
143#define T_EQUAL 295
144#define T_NOT 296
145
146
147
148
149/* Copy the first part of user declarations. */
150
151
152/*
153 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
154 * Released under the terms of the GNU GPL v2.0.
155 */
156
157#include <ctype.h>
158#include <stdarg.h>
159#include <stdio.h>
160#include <stdlib.h>
161#include <string.h>
162#include <stdbool.h>
163
164#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
165
166#define PRINTD 0x0001
167#define DEBUG_PARSE 0x0002
168
169int cdebug = PRINTD;
170
171extern int zconflex(void);
172static void zconfprint(const char *err, ...);
173static void zconferror(const char *err);
174static bool zconf_endtoken(int token, int starttoken, int endtoken);
175
176struct symbol *symbol_hash[257];
177
178static struct menu *current_menu, *current_entry;
179
180#define YYERROR_VERBOSE
181
182
183/* Enabling traces. */
184#ifndef YYDEBUG
185# define YYDEBUG 0
186#endif
187
188/* Enabling verbose error messages. */
189#ifdef YYERROR_VERBOSE
190# undef YYERROR_VERBOSE
191# define YYERROR_VERBOSE 1
192#else
193# define YYERROR_VERBOSE 0
194#endif
195
196#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
197
198typedef union YYSTYPE {
199 int token;
200 char *string;
201 struct symbol *symbol;
202 struct expr *expr;
203 struct menu *menu;
204} YYSTYPE;
205/* Line 191 of yacc.c. */
206
207# define yystype YYSTYPE /* obsolescent; will be withdrawn */
208# define YYSTYPE_IS_DECLARED 1
209# define YYSTYPE_IS_TRIVIAL 1
210#endif
211
212
213
214/* Copy the second part of user declarations. */
215
216
217#define LKC_DIRECT_LINK
218#include "lkc.h"
219
220
221/* Line 214 of yacc.c. */
222
223
224#if ! defined (yyoverflow) || YYERROR_VERBOSE
225
226/* The parser invokes alloca or malloc; define the necessary symbols. */
227
228# if YYSTACK_USE_ALLOCA
229# define YYSTACK_ALLOC alloca
230# else
231# ifndef YYSTACK_USE_ALLOCA
232# if defined (alloca) || (defined (_ALLOCA_H) && defined (__GNUC__))
233# define YYSTACK_ALLOC alloca
234# else
235# ifdef __GNUC__
236# define YYSTACK_ALLOC __builtin_alloca
237# endif
238# endif
239# endif
240# endif
241
242# ifdef YYSTACK_ALLOC
243 /* Pacify GCC's `empty if-body' warning. */
244# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
245# else
246# if defined (__STDC__) || defined (__cplusplus)
247# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
248# define YYSIZE_T size_t
249# endif
250# define YYSTACK_ALLOC malloc
251# define YYSTACK_FREE free
252# endif
253#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
254
255
256#if (! defined (yyoverflow) \
257 && (! defined (__cplusplus) \
258 || (YYSTYPE_IS_TRIVIAL)))
259
260/* A type that is properly aligned for any stack member. */
261union yyalloc
262{
263 short yyss;
264 YYSTYPE yyvs;
265 };
266
267/* The size of the maximum gap between one aligned stack and the next. */
268# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
269
270/* The size of an array large to enough to hold all stacks, each with
271 N elements. */
272# define YYSTACK_BYTES(N) \
273 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
274 + YYSTACK_GAP_MAXIMUM)
275
276/* Copy COUNT objects from FROM to TO. The source and destination do
277 not overlap. */
278# ifndef YYCOPY
279# if 1 < __GNUC__
280# define YYCOPY(To, From, Count) \
281 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
282# else
283# define YYCOPY(To, From, Count) \
284 do \
285 { \
286 register YYSIZE_T yyi; \
287 for (yyi = 0; yyi < (Count); yyi++) \
288 (To)[yyi] = (From)[yyi]; \
289 } \
290 while (0)
291# endif
292# endif
293
294/* Relocate STACK from its old location to the new one. The
295 local variables YYSIZE and YYSTACKSIZE give the old and new number of
296 elements in the stack, and YYPTR gives the new location of the
297 stack. Advance YYPTR to a properly aligned location for the next
298 stack. */
299# define YYSTACK_RELOCATE(Stack) \
300 do \
301 { \
302 YYSIZE_T yynewbytes; \
303 YYCOPY (&yyptr->Stack, Stack, yysize); \
304 Stack = &yyptr->Stack; \
305 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
306 yyptr += yynewbytes / sizeof (*yyptr); \
307 } \
308 while (0)
309
310#endif
311
312#if defined (__STDC__) || defined (__cplusplus)
313 typedef signed char yysigned_char;
314#else
315 typedef short yysigned_char;
316#endif
317
318/* YYFINAL -- State number of the termination state. */
319#define YYFINAL 2
320/* YYLAST -- Last index in YYTABLE. */
321#define YYLAST 201
322
323/* YYNTOKENS -- Number of terminals. */
324#define YYNTOKENS 42
325/* YYNNTS -- Number of nonterminals. */
326#define YYNNTS 41
327/* YYNRULES -- Number of rules. */
328#define YYNRULES 104
329/* YYNRULES -- Number of states. */
330#define YYNSTATES 182
331
332/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
333#define YYUNDEFTOK 2
334#define YYMAXUTOK 296
335
336#define YYTRANSLATE(YYX) \
337 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
338
339/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
340static const unsigned char yytranslate[] =
341{
342 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
343 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
344 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
345 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
346 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
347 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
348 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
349 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
350 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
351 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
352 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
353 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
354 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
355 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
356 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
357 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
358 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
359 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
360 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
361 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
362 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
363 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
364 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
365 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
366 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
367 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
368 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
369 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
370 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
371 35, 36, 37, 38, 39, 40, 41
372};
373
374#if YYDEBUG
375/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
376 YYRHS. */
377static const unsigned short yyprhs[] =
378{
379 0, 0, 3, 4, 7, 9, 11, 13, 17, 19,
380 21, 23, 26, 28, 30, 32, 34, 36, 38, 42,
381 45, 49, 52, 53, 56, 59, 62, 65, 69, 74,
382 78, 83, 87, 91, 95, 100, 105, 110, 116, 119,
383 122, 124, 128, 131, 132, 135, 138, 141, 144, 149,
384 153, 157, 160, 165, 166, 169, 173, 175, 179, 182,
385 183, 186, 189, 192, 196, 199, 201, 205, 208, 209,
386 212, 215, 218, 222, 226, 228, 232, 235, 238, 241,
387 242, 245, 248, 253, 257, 261, 262, 265, 267, 269,
388 272, 275, 278, 280, 282, 283, 286, 288, 292, 296,
389 300, 303, 307, 311, 313
390};
391
392/* YYRHS -- A `-1'-separated list of the rules' RHS. */
393static const yysigned_char yyrhs[] =
394{
395 43, 0, -1, -1, 43, 44, -1, 45, -1, 55,
396 -1, 66, -1, 3, 77, 79, -1, 5, -1, 15,
397 -1, 8, -1, 1, 79, -1, 61, -1, 71, -1,
398 47, -1, 49, -1, 69, -1, 79, -1, 10, 28,
399 32, -1, 46, 50, -1, 11, 28, 32, -1, 48,
400 50, -1, -1, 50, 51, -1, 50, 75, -1, 50,
401 73, -1, 50, 32, -1, 21, 76, 32, -1, 22,
402 81, 80, 32, -1, 23, 76, 32, -1, 24, 81,
403 80, 32, -1, 26, 76, 32, -1, 27, 76, 32,
404 -1, 25, 76, 32, -1, 19, 77, 80, 32, -1,
405 20, 81, 80, 32, -1, 36, 28, 80, 32, -1,
406 37, 82, 82, 80, 32, -1, 7, 32, -1, 52,
407 56, -1, 78, -1, 53, 58, 54, -1, 53, 58,
408 -1, -1, 56, 57, -1, 56, 75, -1, 56, 73,
409 -1, 56, 32, -1, 19, 77, 80, 32, -1, 21,
410 76, 32, -1, 23, 76, 32, -1, 18, 32, -1,
411 20, 28, 80, 32, -1, -1, 58, 45, -1, 14,
412 81, 32, -1, 78, -1, 59, 62, 60, -1, 59,
413 62, -1, -1, 62, 45, -1, 62, 66, -1, 62,
414 55, -1, 4, 77, 32, -1, 63, 74, -1, 78,
415 -1, 64, 67, 65, -1, 64, 67, -1, -1, 67,
416 45, -1, 67, 66, -1, 67, 55, -1, 67, 1,
417 32, -1, 6, 77, 32, -1, 68, -1, 9, 77,
418 32, -1, 70, 74, -1, 12, 32, -1, 72, 13,
419 -1, -1, 74, 75, -1, 74, 32, -1, 16, 35,
420 81, 32, -1, 16, 81, 32, -1, 17, 81, 32,
421 -1, -1, 77, 80, -1, 28, -1, 29, -1, 5,
422 79, -1, 8, 79, -1, 15, 79, -1, 32, -1,
423 31, -1, -1, 14, 81, -1, 82, -1, 82, 40,
424 82, -1, 82, 30, 82, -1, 34, 81, 33, -1,
425 41, 81, -1, 81, 38, 81, -1, 81, 39, 81,
426 -1, 28, -1, 29, -1
427};
428
429/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
430static const unsigned short yyrline[] =
431{
432 0, 94, 94, 95, 98, 99, 100, 101, 102, 103,
433 104, 105, 109, 110, 111, 112, 113, 114, 120, 128,
434 134, 142, 152, 154, 155, 156, 157, 160, 166, 173,
435 179, 186, 192, 198, 204, 210, 216, 222, 230, 239,
436 245, 254, 255, 261, 263, 264, 265, 266, 269, 275,
437 281, 287, 293, 299, 301, 306, 315, 324, 325, 331,
438 333, 334, 335, 340, 347, 353, 362, 363, 369, 371,
439 372, 373, 374, 377, 383, 390, 397, 404, 410, 417,
440 418, 419, 422, 427, 432, 440, 442, 447, 448, 451,
441 452, 453, 457, 457, 459, 460, 463, 464, 465, 466,
442 467, 468, 469, 472, 473
443};
444#endif
445
446#if YYDEBUG || YYERROR_VERBOSE
447/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
448 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
449static const char *const yytname[] =
450{
451 "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU",
452 "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG",
453 "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS",
454 "T_REQUIRES", "T_OPTIONAL", "T_PROMPT", "T_DEFAULT", "T_TRISTATE",
455 "T_DEF_TRISTATE", "T_BOOLEAN", "T_DEF_BOOLEAN", "T_STRING", "T_INT",
456 "T_HEX", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", "T_EOF", "T_EOL",
457 "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_ON", "T_SELECT", "T_RANGE", "T_OR",
458 "T_AND", "T_EQUAL", "T_NOT", "$accept", "input", "block",
459 "common_block", "config_entry_start", "config_stmt",
460 "menuconfig_entry_start", "menuconfig_stmt", "config_option_list",
461 "config_option", "choice", "choice_entry", "choice_end", "choice_stmt",
462 "choice_option_list", "choice_option", "choice_block", "if", "if_end",
463 "if_stmt", "if_block", "menu", "menu_entry", "menu_end", "menu_stmt",
464 "menu_block", "source", "source_stmt", "comment", "comment_stmt",
465 "help_start", "help", "depends_list", "depends", "prompt_stmt_opt",
466 "prompt", "end", "nl_or_eof", "if_expr", "expr", "symbol", 0
467};
468#endif
469
470# ifdef YYPRINT
471/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
472 token YYLEX-NUM. */
473static const unsigned short yytoknum[] =
474{
475 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
476 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
477 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
478 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
479 295, 296
480};
481# endif
482
483/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
484static const unsigned char yyr1[] =
485{
486 0, 42, 43, 43, 44, 44, 44, 44, 44, 44,
487 44, 44, 45, 45, 45, 45, 45, 45, 46, 47,
488 48, 49, 50, 50, 50, 50, 50, 51, 51, 51,
489 51, 51, 51, 51, 51, 51, 51, 51, 52, 53,
490 54, 55, 55, 56, 56, 56, 56, 56, 57, 57,
491 57, 57, 57, 58, 58, 59, 60, 61, 61, 62,
492 62, 62, 62, 63, 64, 65, 66, 66, 67, 67,
493 67, 67, 67, 68, 69, 70, 71, 72, 73, 74,
494 74, 74, 75, 75, 75, 76, 76, 77, 77, 78,
495 78, 78, 79, 79, 80, 80, 81, 81, 81, 81,
496 81, 81, 81, 82, 82
497};
498
499/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
500static const unsigned char yyr2[] =
501{
502 0, 2, 0, 2, 1, 1, 1, 3, 1, 1,
503 1, 2, 1, 1, 1, 1, 1, 1, 3, 2,
504 3, 2, 0, 2, 2, 2, 2, 3, 4, 3,
505 4, 3, 3, 3, 4, 4, 4, 5, 2, 2,
506 1, 3, 2, 0, 2, 2, 2, 2, 4, 3,
507 3, 2, 4, 0, 2, 3, 1, 3, 2, 0,
508 2, 2, 2, 3, 2, 1, 3, 2, 0, 2,
509 2, 2, 3, 3, 1, 3, 2, 2, 2, 0,
510 2, 2, 4, 3, 3, 0, 2, 1, 1, 2,
511 2, 2, 1, 1, 0, 2, 1, 3, 3, 3,
512 2, 3, 3, 1, 1
513};
514
515/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
516 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
517 means the default is an error. */
518static const unsigned char yydefact[] =
519{
520 2, 0, 1, 0, 0, 0, 8, 0, 0, 10,
521 0, 0, 0, 0, 9, 93, 92, 3, 4, 22,
522 14, 22, 15, 43, 53, 5, 59, 12, 79, 68,
523 6, 74, 16, 79, 13, 17, 11, 87, 88, 0,
524 0, 0, 38, 0, 0, 0, 103, 104, 0, 0,
525 0, 96, 19, 21, 39, 42, 58, 64, 0, 76,
526 7, 63, 73, 75, 18, 20, 0, 100, 55, 0,
527 0, 0, 0, 0, 0, 0, 0, 0, 85, 0,
528 85, 0, 85, 85, 85, 26, 0, 0, 23, 0,
529 25, 24, 0, 0, 0, 85, 85, 47, 44, 46,
530 45, 0, 0, 0, 54, 41, 40, 60, 62, 57,
531 61, 56, 81, 80, 0, 69, 71, 66, 70, 65,
532 99, 101, 102, 98, 97, 77, 0, 0, 0, 94,
533 94, 0, 94, 94, 0, 94, 0, 0, 0, 94,
534 0, 78, 51, 94, 94, 0, 0, 89, 90, 91,
535 72, 0, 83, 84, 0, 0, 0, 27, 86, 0,
536 29, 0, 33, 31, 32, 0, 94, 0, 0, 49,
537 50, 82, 95, 34, 35, 28, 30, 36, 0, 48,
538 52, 37
539};
540
541/* YYDEFGOTO[NTERM-NUM]. */
542static const short yydefgoto[] =
543{
544 -1, 1, 17, 18, 19, 20, 21, 22, 52, 88,
545 23, 24, 105, 25, 54, 98, 55, 26, 109, 27,
546 56, 28, 29, 117, 30, 58, 31, 32, 33, 34,
547 89, 90, 57, 91, 131, 132, 106, 35, 155, 50,
548 51
549};
550
551/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
552 STATE-NUM. */
553#define YYPACT_NINF -99
554static const short yypact[] =
555{
556 -99, 48, -99, 38, 46, 46, -99, 46, -29, -99,
557 46, -17, -3, -11, -99, -99, -99, -99, -99, -99,
558 -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
559 -99, -99, -99, -99, -99, -99, -99, -99, -99, 38,
560 12, 15, -99, 18, 51, 62, -99, -99, -11, -11,
561 4, -24, 138, 138, 160, 121, 110, -4, 81, -4,
562 -99, -99, -99, -99, -99, -99, -19, -99, -99, -11,
563 -11, 70, 70, 73, 32, -11, 46, -11, 46, -11,
564 46, -11, 46, 46, 46, -99, 36, 70, -99, 95,
565 -99, -99, 96, 46, 106, 46, 46, -99, -99, -99,
566 -99, 38, 38, 38, -99, -99, -99, -99, -99, -99,
567 -99, -99, -99, -99, 112, -99, -99, -99, -99, -99,
568 -99, 117, -99, -99, -99, -99, -11, 33, 65, 131,
569 1, 119, 131, 1, 136, 1, 153, 154, 155, 131,
570 70, -99, -99, 131, 131, 156, 157, -99, -99, -99,
571 -99, 101, -99, -99, -11, 158, 159, -99, -99, 161,
572 -99, 162, -99, -99, -99, 163, 131, 164, 165, -99,
573 -99, -99, 99, -99, -99, -99, -99, -99, 166, -99,
574 -99, -99
575};
576
577/* YYPGOTO[NTERM-NUM]. */
578static const short yypgoto[] =
579{
580 -99, -99, -99, 111, -99, -99, -99, -99, 178, -99,
581 -99, -99, -99, 91, -99, -99, -99, -99, -99, -99,
582 -99, -99, -99, -99, 115, -99, -99, -99, -99, -99,
583 -99, 146, 168, 89, 27, 0, 126, -1, -98, -48,
584 -63
585};
586
587/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
588 positive, shift that token. If negative, reduce the rule which
589 number is the opposite. If zero, do what YYDEFACT says.
590 If YYTABLE_NINF, syntax error. */
591#define YYTABLE_NINF -68
592static const short yytable[] =
593{
594 66, 67, 36, 42, 39, 40, 71, 41, 123, 124,
595 43, 44, 74, 75, 120, 154, 72, 46, 47, 69,
596 70, 121, 122, 48, 140, 45, 127, 128, 112, 130,
597 49, 133, 156, 135, 158, 159, 68, 161, 60, 69,
598 70, 165, 69, 70, 61, 167, 168, 62, 2, 3,
599 63, 4, 5, 6, 7, 8, 9, 10, 11, 12,
600 46, 47, 13, 14, 139, 152, 48, 126, 178, 15,
601 16, 69, 70, 49, 37, 38, 129, 166, 151, 15,
602 16, -67, 114, 64, -67, 5, 101, 7, 8, 102,
603 10, 11, 12, 143, 65, 13, 103, 153, 46, 47,
604 147, 148, 149, 69, 70, 125, 172, 134, 141, 136,
605 137, 138, 15, 16, 5, 101, 7, 8, 102, 10,
606 11, 12, 145, 146, 13, 103, 101, 7, 142, 102,
607 10, 11, 12, 171, 144, 13, 103, 69, 70, 69,
608 70, 15, 16, 100, 150, 154, 113, 108, 113, 116,
609 73, 157, 15, 16, 74, 75, 70, 76, 77, 78,
610 79, 80, 81, 82, 83, 84, 104, 107, 160, 115,
611 85, 110, 73, 118, 86, 87, 74, 75, 92, 93,
612 94, 95, 111, 96, 119, 162, 163, 164, 169, 170,
613 173, 174, 97, 175, 176, 177, 179, 180, 181, 53,
614 99, 59
615};
616
617static const unsigned char yycheck[] =
618{
619 48, 49, 3, 32, 4, 5, 30, 7, 71, 72,
620 10, 28, 16, 17, 33, 14, 40, 28, 29, 38,
621 39, 69, 70, 34, 87, 28, 74, 75, 32, 77,
622 41, 79, 130, 81, 132, 133, 32, 135, 39, 38,
623 39, 139, 38, 39, 32, 143, 144, 32, 0, 1,
624 32, 3, 4, 5, 6, 7, 8, 9, 10, 11,
625 28, 29, 14, 15, 28, 32, 34, 35, 166, 31,
626 32, 38, 39, 41, 28, 29, 76, 140, 126, 31,
627 32, 0, 1, 32, 3, 4, 5, 6, 7, 8,
628 9, 10, 11, 93, 32, 14, 15, 32, 28, 29,
629 101, 102, 103, 38, 39, 32, 154, 80, 13, 82,
630 83, 84, 31, 32, 4, 5, 6, 7, 8, 9,
631 10, 11, 95, 96, 14, 15, 5, 6, 32, 8,
632 9, 10, 11, 32, 28, 14, 15, 38, 39, 38,
633 39, 31, 32, 54, 32, 14, 57, 56, 59, 58,
634 12, 32, 31, 32, 16, 17, 39, 19, 20, 21,
635 22, 23, 24, 25, 26, 27, 55, 56, 32, 58,
636 32, 56, 12, 58, 36, 37, 16, 17, 18, 19,
637 20, 21, 56, 23, 58, 32, 32, 32, 32, 32,
638 32, 32, 32, 32, 32, 32, 32, 32, 32, 21,
639 54, 33
640};
641
642/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
643 symbol of state STATE-NUM. */
644static const unsigned char yystos[] =
645{
646 0, 43, 0, 1, 3, 4, 5, 6, 7, 8,
647 9, 10, 11, 14, 15, 31, 32, 44, 45, 46,
648 47, 48, 49, 52, 53, 55, 59, 61, 63, 64,
649 66, 68, 69, 70, 71, 79, 79, 28, 29, 77,
650 77, 77, 32, 77, 28, 28, 28, 29, 34, 41,
651 81, 82, 50, 50, 56, 58, 62, 74, 67, 74,
652 79, 32, 32, 32, 32, 32, 81, 81, 32, 38,
653 39, 30, 40, 12, 16, 17, 19, 20, 21, 22,
654 23, 24, 25, 26, 27, 32, 36, 37, 51, 72,
655 73, 75, 18, 19, 20, 21, 23, 32, 57, 73,
656 75, 5, 8, 15, 45, 54, 78, 45, 55, 60,
657 66, 78, 32, 75, 1, 45, 55, 65, 66, 78,
658 33, 81, 81, 82, 82, 32, 35, 81, 81, 77,
659 81, 76, 77, 81, 76, 81, 76, 76, 76, 28,
660 82, 13, 32, 77, 28, 76, 76, 79, 79, 79,
661 32, 81, 32, 32, 14, 80, 80, 32, 80, 80,
662 32, 80, 32, 32, 32, 80, 82, 80, 80, 32,
663 32, 32, 81, 32, 32, 32, 32, 32, 80, 32,
664 32, 32
665};
666
667#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
668# define YYSIZE_T __SIZE_TYPE__
669#endif
670#if ! defined (YYSIZE_T) && defined (size_t)
671# define YYSIZE_T size_t
672#endif
673#if ! defined (YYSIZE_T)
674# if defined (__STDC__) || defined (__cplusplus)
675# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
676# define YYSIZE_T size_t
677# endif
678#endif
679#if ! defined (YYSIZE_T)
680# define YYSIZE_T unsigned int
681#endif
682
683#define yyerrok (yyerrstatus = 0)
684#define yyclearin (yychar = YYEMPTY)
685#define YYEMPTY (-2)
686#define YYEOF 0
687
688#define YYACCEPT goto yyacceptlab
689#define YYABORT goto yyabortlab
690#define YYERROR goto yyerrlab1
691
692
693/* Like YYERROR except do call yyerror. This remains here temporarily
694 to ease the transition to the new meaning of YYERROR, for GCC.
695 Once GCC version 2 has supplanted version 1, this can go. */
696
697#define YYFAIL goto yyerrlab
698
699#define YYRECOVERING() (!!yyerrstatus)
700
701#define YYBACKUP(Token, Value) \
702do \
703 if (yychar == YYEMPTY && yylen == 1) \
704 { \
705 yychar = (Token); \
706 yylval = (Value); \
707 yytoken = YYTRANSLATE (yychar); \
708 YYPOPSTACK; \
709 goto yybackup; \
710 } \
711 else \
712 { \
713 yyerror ("syntax error: cannot back up");\
714 YYERROR; \
715 } \
716while (0)
717
718#define YYTERROR 1
719#define YYERRCODE 256
720
721/* YYLLOC_DEFAULT -- Compute the default location (before the actions
722 are run). */
723
724#ifndef YYLLOC_DEFAULT
725# define YYLLOC_DEFAULT(Current, Rhs, N) \
726 Current.first_line = Rhs[1].first_line; \
727 Current.first_column = Rhs[1].first_column; \
728 Current.last_line = Rhs[N].last_line; \
729 Current.last_column = Rhs[N].last_column;
730#endif
731
732/* YYLEX -- calling `yylex' with the right arguments. */
733
734#ifdef YYLEX_PARAM
735# define YYLEX yylex (YYLEX_PARAM)
736#else
737# define YYLEX yylex ()
738#endif
739
740/* Enable debugging if requested. */
741#if YYDEBUG
742
743# ifndef YYFPRINTF
744# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
745# define YYFPRINTF fprintf
746# endif
747
748# define YYDPRINTF(Args) \
749do { \
750 if (yydebug) \
751 YYFPRINTF Args; \
752} while (0)
753
754# define YYDSYMPRINT(Args) \
755do { \
756 if (yydebug) \
757 yysymprint Args; \
758} while (0)
759
760# define YYDSYMPRINTF(Title, Token, Value, Location) \
761do { \
762 if (yydebug) \
763 { \
764 YYFPRINTF (stderr, "%s ", Title); \
765 yysymprint (stderr, \
766 Token, Value); \
767 YYFPRINTF (stderr, "\n"); \
768 } \
769} while (0)
770
771/*------------------------------------------------------------------.
772| yy_stack_print -- Print the state stack from its BOTTOM up to its |
773| TOP (cinluded). |
774`------------------------------------------------------------------*/
775
776#if defined (__STDC__) || defined (__cplusplus)
777static void
778yy_stack_print (short *bottom, short *top)
779#else
780static void
781yy_stack_print (bottom, top)
782 short *bottom;
783 short *top;
784#endif
785{
786 YYFPRINTF (stderr, "Stack now");
787 for (/* Nothing. */; bottom <= top; ++bottom)
788 YYFPRINTF (stderr, " %d", *bottom);
789 YYFPRINTF (stderr, "\n");
790}
791
792# define YY_STACK_PRINT(Bottom, Top) \
793do { \
794 if (yydebug) \
795 yy_stack_print ((Bottom), (Top)); \
796} while (0)
797
798
799/*------------------------------------------------.
800| Report that the YYRULE is going to be reduced. |
801`------------------------------------------------*/
802
803#if defined (__STDC__) || defined (__cplusplus)
804static void
805yy_reduce_print (int yyrule)
806#else
807static void
808yy_reduce_print (yyrule)
809 int yyrule;
810#endif
811{
812 int yyi;
813 unsigned int yylineno = yyrline[yyrule];
814 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
815 yyrule - 1, yylineno);
816 /* Print the symbols being reduced, and their result. */
817 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
818 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
819 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
820}
821
822# define YY_REDUCE_PRINT(Rule) \
823do { \
824 if (yydebug) \
825 yy_reduce_print (Rule); \
826} while (0)
827
828/* Nonzero means print parse trace. It is left uninitialized so that
829 multiple parsers can coexist. */
830int yydebug;
831#else /* !YYDEBUG */
832# define YYDPRINTF(Args)
833# define YYDSYMPRINT(Args)
834# define YYDSYMPRINTF(Title, Token, Value, Location)
835# define YY_STACK_PRINT(Bottom, Top)
836# define YY_REDUCE_PRINT(Rule)
837#endif /* !YYDEBUG */
838
839
840/* YYINITDEPTH -- initial size of the parser's stacks. */
841#ifndef YYINITDEPTH
842# define YYINITDEPTH 200
843#endif
844
845/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
846 if the built-in stack extension method is used).
847
848 Do not make this value too large; the results are undefined if
849 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
850 evaluated with infinite-precision integer arithmetic. */
851
852#if YYMAXDEPTH == 0
853# undef YYMAXDEPTH
854#endif
855
856#ifndef YYMAXDEPTH
857# define YYMAXDEPTH 10000
858#endif
859
860
861
862#if YYERROR_VERBOSE
863
864# ifndef yystrlen
865# if defined (__GLIBC__) && defined (_STRING_H)
866# define yystrlen strlen
867# else
868/* Return the length of YYSTR. */
869static YYSIZE_T
870# if defined (__STDC__) || defined (__cplusplus)
871yystrlen (const char *yystr)
872# else
873yystrlen (yystr)
874 const char *yystr;
875# endif
876{
877 register const char *yys = yystr;
878
879 while (*yys++ != '\0')
880 continue;
881
882 return yys - yystr - 1;
883}
884# endif
885# endif
886
887# ifndef yystpcpy
888# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
889# define yystpcpy stpcpy
890# else
891/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
892 YYDEST. */
893static char *
894# if defined (__STDC__) || defined (__cplusplus)
895yystpcpy (char *yydest, const char *yysrc)
896# else
897yystpcpy (yydest, yysrc)
898 char *yydest;
899 const char *yysrc;
900# endif
901{
902 register char *yyd = yydest;
903 register const char *yys = yysrc;
904
905 while ((*yyd++ = *yys++) != '\0')
906 continue;
907
908 return yyd - 1;
909}
910# endif
911# endif
912
913#endif /* !YYERROR_VERBOSE */
914
915
916
917#if YYDEBUG
918/*--------------------------------.
919| Print this symbol on YYOUTPUT. |
920`--------------------------------*/
921
922#if defined (__STDC__) || defined (__cplusplus)
923static void
924yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
925#else
926static void
927yysymprint (yyoutput, yytype, yyvaluep)
928 FILE *yyoutput;
929 int yytype;
930 YYSTYPE *yyvaluep;
931#endif
932{
933 /* Pacify ``unused variable'' warnings. */
934 (void) yyvaluep;
935
936 if (yytype < YYNTOKENS)
937 {
938 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
939# ifdef YYPRINT
940 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
941# endif
942 }
943 else
944 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
945
946 switch (yytype)
947 {
948 default:
949 break;
950 }
951 YYFPRINTF (yyoutput, ")");
952}
953
954#endif /* ! YYDEBUG */
955/*-----------------------------------------------.
956| Release the memory associated to this symbol. |
957`-----------------------------------------------*/
958
959#if defined (__STDC__) || defined (__cplusplus)
960static void
961yydestruct (int yytype, YYSTYPE *yyvaluep)
962#else
963static void
964yydestruct (yytype, yyvaluep)
965 int yytype;
966 YYSTYPE *yyvaluep;
967#endif
968{
969 /* Pacify ``unused variable'' warnings. */
970 (void) yyvaluep;
971
972 switch (yytype)
973 {
974
975 default:
976 break;
977 }
978}
979
980
981/* Prevent warnings from -Wmissing-prototypes. */
982
983#ifdef YYPARSE_PARAM
984# if defined (__STDC__) || defined (__cplusplus)
985int yyparse (void *YYPARSE_PARAM);
986# else
987int yyparse ();
988# endif
989#else /* ! YYPARSE_PARAM */
990#if defined (__STDC__) || defined (__cplusplus)
991int yyparse (void);
992#else
993int yyparse ();
994#endif
995#endif /* ! YYPARSE_PARAM */
996
997
998
999/* The lookahead symbol. */
1000int yychar;
1001
1002/* The semantic value of the lookahead symbol. */
1003YYSTYPE yylval;
1004
1005/* Number of syntax errors so far. */
1006int yynerrs;
1007
1008
1009
1010/*----------.
1011| yyparse. |
1012`----------*/
1013
1014#ifdef YYPARSE_PARAM
1015# if defined (__STDC__) || defined (__cplusplus)
1016int yyparse (void *YYPARSE_PARAM)
1017# else
1018int yyparse (YYPARSE_PARAM)
1019 void *YYPARSE_PARAM;
1020# endif
1021#else /* ! YYPARSE_PARAM */
1022#if defined (__STDC__) || defined (__cplusplus)
1023int
1024yyparse (void)
1025#else
1026int
1027yyparse ()
1028
1029#endif
1030#endif
1031{
1032
1033 register int yystate;
1034 register int yyn;
1035 int yyresult;
1036 /* Number of tokens to shift before error messages enabled. */
1037 int yyerrstatus;
1038 /* Lookahead token as an internal (translated) token number. */
1039 int yytoken = 0;
1040
1041 /* Three stacks and their tools:
1042 `yyss': related to states,
1043 `yyvs': related to semantic values,
1044 `yyls': related to locations.
1045
1046 Refer to the stacks thru separate pointers, to allow yyoverflow
1047 to reallocate them elsewhere. */
1048
1049 /* The state stack. */
1050 short yyssa[YYINITDEPTH];
1051 short *yyss = yyssa;
1052 register short *yyssp;
1053
1054 /* The semantic value stack. */
1055 YYSTYPE yyvsa[YYINITDEPTH];
1056 YYSTYPE *yyvs = yyvsa;
1057 register YYSTYPE *yyvsp;
1058
1059
1060
1061#define YYPOPSTACK (yyvsp--, yyssp--)
1062
1063 YYSIZE_T yystacksize = YYINITDEPTH;
1064
1065 /* The variables used to return semantic value and location from the
1066 action routines. */
1067 YYSTYPE yyval;
1068
1069
1070 /* When reducing, the number of symbols on the RHS of the reduced
1071 rule. */
1072 int yylen;
1073
1074 YYDPRINTF ((stderr, "Starting parse\n"));
1075
1076 yystate = 0;
1077 yyerrstatus = 0;
1078 yynerrs = 0;
1079 yychar = YYEMPTY; /* Cause a token to be read. */
1080
1081 /* Initialize stack pointers.
1082 Waste one element of value and location stack
1083 so that they stay on the same level as the state stack.
1084 The wasted elements are never initialized. */
1085
1086 yyssp = yyss;
1087 yyvsp = yyvs;
1088
1089 goto yysetstate;
1090
1091/*------------------------------------------------------------.
1092| yynewstate -- Push a new state, which is found in yystate. |
1093`------------------------------------------------------------*/
1094 yynewstate:
1095 /* In all cases, when you get here, the value and location stacks
1096 have just been pushed. so pushing a state here evens the stacks.
1097 */
1098 yyssp++;
1099
1100 yysetstate:
1101 *yyssp = yystate;
1102
1103 if (yyss + yystacksize - 1 <= yyssp)
1104 {
1105 /* Get the current used size of the three stacks, in elements. */
1106 YYSIZE_T yysize = yyssp - yyss + 1;
1107
1108#ifdef yyoverflow
1109 {
1110 /* Give user a chance to reallocate the stack. Use copies of
1111 these so that the &'s don't force the real ones into
1112 memory. */
1113 YYSTYPE *yyvs1 = yyvs;
1114 short *yyss1 = yyss;
1115
1116
1117 /* Each stack pointer address is followed by the size of the
1118 data in use in that stack, in bytes. This used to be a
1119 conditional around just the two extra args, but that might
1120 be undefined if yyoverflow is a macro. */
1121 yyoverflow ("parser stack overflow",
1122 &yyss1, yysize * sizeof (*yyssp),
1123 &yyvs1, yysize * sizeof (*yyvsp),
1124
1125 &yystacksize);
1126
1127 yyss = yyss1;
1128 yyvs = yyvs1;
1129 }
1130#else /* no yyoverflow */
1131# ifndef YYSTACK_RELOCATE
1132 goto yyoverflowlab;
1133# else
1134 /* Extend the stack our own way. */
1135 if (YYMAXDEPTH <= yystacksize)
1136 goto yyoverflowlab;
1137 yystacksize *= 2;
1138 if (YYMAXDEPTH < yystacksize)
1139 yystacksize = YYMAXDEPTH;
1140
1141 {
1142 short *yyss1 = yyss;
1143 union yyalloc *yyptr =
1144 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1145 if (! yyptr)
1146 goto yyoverflowlab;
1147 YYSTACK_RELOCATE (yyss);
1148 YYSTACK_RELOCATE (yyvs);
1149
1150# undef YYSTACK_RELOCATE
1151 if (yyss1 != yyssa)
1152 YYSTACK_FREE (yyss1);
1153 }
1154# endif
1155#endif /* no yyoverflow */
1156
1157 yyssp = yyss + yysize - 1;
1158 yyvsp = yyvs + yysize - 1;
1159
1160
1161 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1162 (unsigned long int) yystacksize));
1163
1164 if (yyss + yystacksize - 1 <= yyssp)
1165 YYABORT;
1166 }
1167
1168 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1169
1170 goto yybackup;
1171
1172/*-----------.
1173| yybackup. |
1174`-----------*/
1175yybackup:
1176
1177/* Do appropriate processing given the current state. */
1178/* Read a lookahead token if we need one and don't already have one. */
1179/* yyresume: */
1180
1181 /* First try to decide what to do without reference to lookahead token. */
1182
1183 yyn = yypact[yystate];
1184 if (yyn == YYPACT_NINF)
1185 goto yydefault;
1186
1187 /* Not known => get a lookahead token if don't already have one. */
1188
1189 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1190 if (yychar == YYEMPTY)
1191 {
1192 YYDPRINTF ((stderr, "Reading a token: "));
1193 yychar = YYLEX;
1194 }
1195
1196 if (yychar <= YYEOF)
1197 {
1198 yychar = yytoken = YYEOF;
1199 YYDPRINTF ((stderr, "Now at end of input.\n"));
1200 }
1201 else
1202 {
1203 yytoken = YYTRANSLATE (yychar);
1204 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1205 }
1206
1207 /* If the proper action on seeing token YYTOKEN is to reduce or to
1208 detect an error, take that action. */
1209 yyn += yytoken;
1210 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1211 goto yydefault;
1212 yyn = yytable[yyn];
1213 if (yyn <= 0)
1214 {
1215 if (yyn == 0 || yyn == YYTABLE_NINF)
1216 goto yyerrlab;
1217 yyn = -yyn;
1218 goto yyreduce;
1219 }
1220
1221 if (yyn == YYFINAL)
1222 YYACCEPT;
1223
1224 /* Shift the lookahead token. */
1225 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1226
1227 /* Discard the token being shifted unless it is eof. */
1228 if (yychar != YYEOF)
1229 yychar = YYEMPTY;
1230
1231 *++yyvsp = yylval;
1232
1233
1234 /* Count tokens shifted since error; after three, turn off error
1235 status. */
1236 if (yyerrstatus)
1237 yyerrstatus--;
1238
1239 yystate = yyn;
1240 goto yynewstate;
1241
1242
1243/*-----------------------------------------------------------.
1244| yydefault -- do the default action for the current state. |
1245`-----------------------------------------------------------*/
1246yydefault:
1247 yyn = yydefact[yystate];
1248 if (yyn == 0)
1249 goto yyerrlab;
1250 goto yyreduce;
1251
1252
1253/*-----------------------------.
1254| yyreduce -- Do a reduction. |
1255`-----------------------------*/
1256yyreduce:
1257 /* yyn is the number of a rule to reduce with. */
1258 yylen = yyr2[yyn];
1259
1260 /* If YYLEN is nonzero, implement the default value of the action:
1261 `$$ = $1'.
1262
1263 Otherwise, the following line sets YYVAL to garbage.
1264 This behavior is undocumented and Bison
1265 users should not rely upon it. Assigning to YYVAL
1266 unconditionally makes the parser a bit smaller, and it avoids a
1267 GCC warning that YYVAL may be used uninitialized. */
1268 yyval = yyvsp[1-yylen];
1269
1270
1271 YY_REDUCE_PRINT (yyn);
1272 switch (yyn)
1273 {
1274 case 8:
1275
1276 { zconfprint("unexpected 'endmenu' statement"); ;}
1277 break;
1278
1279 case 9:
1280
1281 { zconfprint("unexpected 'endif' statement"); ;}
1282 break;
1283
1284 case 10:
1285
1286 { zconfprint("unexpected 'endchoice' statement"); ;}
1287 break;
1288
1289 case 11:
1290
1291 { zconfprint("syntax error"); yyerrok; ;}
1292 break;
1293
1294 case 18:
1295
1296 {
1297 struct symbol *sym = sym_lookup(yyvsp[-1].string, 0);
1298 sym->flags |= SYMBOL_OPTIONAL;
1299 menu_add_entry(sym);
1300 printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string);
1301;}
1302 break;
1303
1304 case 19:
1305
1306 {
1307 menu_end_entry();
1308 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
1309;}
1310 break;
1311
1312 case 20:
1313
1314 {
1315 struct symbol *sym = sym_lookup(yyvsp[-1].string, 0);
1316 sym->flags |= SYMBOL_OPTIONAL;
1317 menu_add_entry(sym);
1318 printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string);
1319;}
1320 break;
1321
1322 case 21:
1323
1324 {
1325 if (current_entry->prompt)
1326 current_entry->prompt->type = P_MENU;
1327 else
1328 zconfprint("warning: menuconfig statement without prompt");
1329 menu_end_entry();
1330 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
1331;}
1332 break;
1333
1334 case 27:
1335
1336 {
1337 menu_set_type(S_TRISTATE);
1338 printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno());
1339;}
1340 break;
1341
1342 case 28:
1343
1344 {
1345 menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr);
1346 menu_set_type(S_TRISTATE);
1347 printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno());
1348;}
1349 break;
1350
1351 case 29:
1352
1353 {
1354 menu_set_type(S_BOOLEAN);
1355 printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno());
1356;}
1357 break;
1358
1359 case 30:
1360
1361 {
1362 menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr);
1363 menu_set_type(S_BOOLEAN);
1364 printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno());
1365;}
1366 break;
1367
1368 case 31:
1369
1370 {
1371 menu_set_type(S_INT);
1372 printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno());
1373;}
1374 break;
1375
1376 case 32:
1377
1378 {
1379 menu_set_type(S_HEX);
1380 printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno());
1381;}
1382 break;
1383
1384 case 33:
1385
1386 {
1387 menu_set_type(S_STRING);
1388 printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno());
1389;}
1390 break;
1391
1392 case 34:
1393
1394 {
1395 menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr);
1396 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
1397;}
1398 break;
1399
1400 case 35:
1401
1402 {
1403 menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr);
1404 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno());
1405;}
1406 break;
1407
1408 case 36:
1409
1410 {
1411 menu_add_symbol(P_SELECT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr);
1412 printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
1413;}
1414 break;
1415
1416 case 37:
1417
1418 {
1419 menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,yyvsp[-3].symbol, yyvsp[-2].symbol), yyvsp[-1].expr);
1420 printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
1421;}
1422 break;
1423
1424 case 38:
1425
1426 {
1427 struct symbol *sym = sym_lookup(NULL, 0);
1428 sym->flags |= SYMBOL_CHOICE;
1429 menu_add_entry(sym);
1430 menu_add_expr(P_CHOICE, NULL, NULL);
1431 printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
1432;}
1433 break;
1434
1435 case 39:
1436
1437 {
1438 menu_end_entry();
1439 menu_add_menu();
1440;}
1441 break;
1442
1443 case 40:
1444
1445 {
1446 if (zconf_endtoken(yyvsp[0].token, T_CHOICE, T_ENDCHOICE)) {
1447 menu_end_menu();
1448 printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
1449 }
1450;}
1451 break;
1452
1453 case 42:
1454
1455 {
1456 printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno);
1457 zconfnerrs++;
1458;}
1459 break;
1460
1461 case 48:
1462
1463 {
1464 menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr);
1465 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
1466;}
1467 break;
1468
1469 case 49:
1470
1471 {
1472 menu_set_type(S_TRISTATE);
1473 printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno());
1474;}
1475 break;
1476
1477 case 50:
1478
1479 {
1480 menu_set_type(S_BOOLEAN);
1481 printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno());
1482;}
1483 break;
1484
1485 case 51:
1486
1487 {
1488 current_entry->sym->flags |= SYMBOL_OPTIONAL;
1489 printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
1490;}
1491 break;
1492
1493 case 52:
1494
1495 {
1496 menu_add_symbol(P_DEFAULT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr);
1497 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno());
1498;}
1499 break;
1500
1501 case 55:
1502
1503 {
1504 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
1505 menu_add_entry(NULL);
1506 menu_add_dep(yyvsp[-1].expr);
1507 menu_end_entry();
1508 menu_add_menu();
1509;}
1510 break;
1511
1512 case 56:
1513
1514 {
1515 if (zconf_endtoken(yyvsp[0].token, T_IF, T_ENDIF)) {
1516 menu_end_menu();
1517 printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
1518 }
1519;}
1520 break;
1521
1522 case 58:
1523
1524 {
1525 printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno);
1526 zconfnerrs++;
1527;}
1528 break;
1529
1530 case 63:
1531
1532 {
1533 menu_add_entry(NULL);
1534 menu_add_prop(P_MENU, yyvsp[-1].string, NULL, NULL);
1535 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
1536;}
1537 break;
1538
1539 case 64:
1540
1541 {
1542 menu_end_entry();
1543 menu_add_menu();
1544;}
1545 break;
1546
1547 case 65:
1548
1549 {
1550 if (zconf_endtoken(yyvsp[0].token, T_MENU, T_ENDMENU)) {
1551 menu_end_menu();
1552 printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
1553 }
1554;}
1555 break;
1556
1557 case 67:
1558
1559 {
1560 printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno);
1561 zconfnerrs++;
1562;}
1563 break;
1564
1565 case 72:
1566
1567 { zconfprint("invalid menu option"); yyerrok; ;}
1568 break;
1569
1570 case 73:
1571
1572 {
1573 yyval.string = yyvsp[-1].string;
1574 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string);
1575;}
1576 break;
1577
1578 case 74:
1579
1580 {
1581 zconf_nextfile(yyvsp[0].string);
1582;}
1583 break;
1584
1585 case 75:
1586
1587 {
1588 menu_add_entry(NULL);
1589 menu_add_prop(P_COMMENT, yyvsp[-1].string, NULL, NULL);
1590 printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
1591;}
1592 break;
1593
1594 case 76:
1595
1596 {
1597 menu_end_entry();
1598;}
1599 break;
1600
1601 case 77:
1602
1603 {
1604 printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
1605 zconf_starthelp();
1606;}
1607 break;
1608
1609 case 78:
1610
1611 {
1612 current_entry->sym->help = yyvsp[0].string;
1613;}
1614 break;
1615
1616 case 82:
1617
1618 {
1619 menu_add_dep(yyvsp[-1].expr);
1620 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
1621;}
1622 break;
1623
1624 case 83:
1625
1626 {
1627 menu_add_dep(yyvsp[-1].expr);
1628 printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno());
1629;}
1630 break;
1631
1632 case 84:
1633
1634 {
1635 menu_add_dep(yyvsp[-1].expr);
1636 printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno());
1637;}
1638 break;
1639
1640 case 86:
1641
1642 {
1643 menu_add_prop(P_PROMPT, yyvsp[-1].string, NULL, yyvsp[0].expr);
1644;}
1645 break;
1646
1647 case 89:
1648
1649 { yyval.token = T_ENDMENU; ;}
1650 break;
1651
1652 case 90:
1653
1654 { yyval.token = T_ENDCHOICE; ;}
1655 break;
1656
1657 case 91:
1658
1659 { yyval.token = T_ENDIF; ;}
1660 break;
1661
1662 case 94:
1663
1664 { yyval.expr = NULL; ;}
1665 break;
1666
1667 case 95:
1668
1669 { yyval.expr = yyvsp[0].expr; ;}
1670 break;
1671
1672 case 96:
1673
1674 { yyval.expr = expr_alloc_symbol(yyvsp[0].symbol); ;}
1675 break;
1676
1677 case 97:
1678
1679 { yyval.expr = expr_alloc_comp(E_EQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;}
1680 break;
1681
1682 case 98:
1683
1684 { yyval.expr = expr_alloc_comp(E_UNEQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;}
1685 break;
1686
1687 case 99:
1688
1689 { yyval.expr = yyvsp[-1].expr; ;}
1690 break;
1691
1692 case 100:
1693
1694 { yyval.expr = expr_alloc_one(E_NOT, yyvsp[0].expr); ;}
1695 break;
1696
1697 case 101:
1698
1699 { yyval.expr = expr_alloc_two(E_OR, yyvsp[-2].expr, yyvsp[0].expr); ;}
1700 break;
1701
1702 case 102:
1703
1704 { yyval.expr = expr_alloc_two(E_AND, yyvsp[-2].expr, yyvsp[0].expr); ;}
1705 break;
1706
1707 case 103:
1708
1709 { yyval.symbol = sym_lookup(yyvsp[0].string, 0); free(yyvsp[0].string); ;}
1710 break;
1711
1712 case 104:
1713
1714 { yyval.symbol = sym_lookup(yyvsp[0].string, 1); free(yyvsp[0].string); ;}
1715 break;
1716
1717
1718 }
1719
1720/* Line 999 of yacc.c. */
1721
1722
1723 yyvsp -= yylen;
1724 yyssp -= yylen;
1725
1726
1727 YY_STACK_PRINT (yyss, yyssp);
1728
1729 *++yyvsp = yyval;
1730
1731
1732 /* Now `shift' the result of the reduction. Determine what state
1733 that goes to, based on the state we popped back to and the rule
1734 number reduced by. */
1735
1736 yyn = yyr1[yyn];
1737
1738 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1739 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1740 yystate = yytable[yystate];
1741 else
1742 yystate = yydefgoto[yyn - YYNTOKENS];
1743
1744 goto yynewstate;
1745
1746
1747/*------------------------------------.
1748| yyerrlab -- here on detecting error |
1749`------------------------------------*/
1750yyerrlab:
1751 /* If not already recovering from an error, report this error. */
1752 if (!yyerrstatus)
1753 {
1754 ++yynerrs;
1755#if YYERROR_VERBOSE
1756 yyn = yypact[yystate];
1757
1758 if (YYPACT_NINF < yyn && yyn < YYLAST)
1759 {
1760 YYSIZE_T yysize = 0;
1761 int yytype = YYTRANSLATE (yychar);
1762 char *yymsg;
1763 int yyx, yycount;
1764
1765 yycount = 0;
1766 /* Start YYX at -YYN if negative to avoid negative indexes in
1767 YYCHECK. */
1768 for (yyx = yyn < 0 ? -yyn : 0;
1769 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1770 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1771 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1772 yysize += yystrlen ("syntax error, unexpected ") + 1;
1773 yysize += yystrlen (yytname[yytype]);
1774 yymsg = (char *) YYSTACK_ALLOC (yysize);
1775 if (yymsg != 0)
1776 {
1777 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1778 yyp = yystpcpy (yyp, yytname[yytype]);
1779
1780 if (yycount < 5)
1781 {
1782 yycount = 0;
1783 for (yyx = yyn < 0 ? -yyn : 0;
1784 yyx < (int) (sizeof (yytname) / sizeof (char *));
1785 yyx++)
1786 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1787 {
1788 const char *yyq = ! yycount ? ", expecting " : " or ";
1789 yyp = yystpcpy (yyp, yyq);
1790 yyp = yystpcpy (yyp, yytname[yyx]);
1791 yycount++;
1792 }
1793 }
1794 yyerror (yymsg);
1795 YYSTACK_FREE (yymsg);
1796 }
1797 else
1798 yyerror ("syntax error; also virtual memory exhausted");
1799 }
1800 else
1801#endif /* YYERROR_VERBOSE */
1802 yyerror ("syntax error");
1803 }
1804
1805
1806
1807 if (yyerrstatus == 3)
1808 {
1809 /* If just tried and failed to reuse lookahead token after an
1810 error, discard it. */
1811
1812 /* Return failure if at end of input. */
1813 if (yychar == YYEOF)
1814 {
1815 /* Pop the error token. */
1816 YYPOPSTACK;
1817 /* Pop the rest of the stack. */
1818 while (yyss < yyssp)
1819 {
1820 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1821 yydestruct (yystos[*yyssp], yyvsp);
1822 YYPOPSTACK;
1823 }
1824 YYABORT;
1825 }
1826
1827 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1828 yydestruct (yytoken, &yylval);
1829 yychar = YYEMPTY;
1830
1831 }
1832
1833 /* Else will try to reuse lookahead token after shifting the error
1834 token. */
1835 goto yyerrlab1;
1836
1837
1838/*----------------------------------------------------.
1839| yyerrlab1 -- error raised explicitly by an action. |
1840`----------------------------------------------------*/
1841yyerrlab1:
1842 yyerrstatus = 3; /* Each real token shifted decrements this. */
1843
1844 for (;;)
1845 {
1846 yyn = yypact[yystate];
1847 if (yyn != YYPACT_NINF)
1848 {
1849 yyn += YYTERROR;
1850 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1851 {
1852 yyn = yytable[yyn];
1853 if (0 < yyn)
1854 break;
1855 }
1856 }
1857
1858 /* Pop the current state because it cannot handle the error token. */
1859 if (yyssp == yyss)
1860 YYABORT;
1861
1862 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1863 yydestruct (yystos[yystate], yyvsp);
1864 yyvsp--;
1865 yystate = *--yyssp;
1866
1867 YY_STACK_PRINT (yyss, yyssp);
1868 }
1869
1870 if (yyn == YYFINAL)
1871 YYACCEPT;
1872
1873 YYDPRINTF ((stderr, "Shifting error token, "));
1874
1875 *++yyvsp = yylval;
1876
1877
1878 yystate = yyn;
1879 goto yynewstate;
1880
1881
1882/*-------------------------------------.
1883| yyacceptlab -- YYACCEPT comes here. |
1884`-------------------------------------*/
1885yyacceptlab:
1886 yyresult = 0;
1887 goto yyreturn;
1888
1889/*-----------------------------------.
1890| yyabortlab -- YYABORT comes here. |
1891`-----------------------------------*/
1892yyabortlab:
1893 yyresult = 1;
1894 goto yyreturn;
1895
1896#ifndef yyoverflow
1897/*----------------------------------------------.
1898| yyoverflowlab -- parser overflow comes here. |
1899`----------------------------------------------*/
1900yyoverflowlab:
1901 yyerror ("parser stack overflow");
1902 yyresult = 2;
1903 /* Fall through. */
1904#endif
1905
1906yyreturn:
1907#ifndef yyoverflow
1908 if (yyss != yyssa)
1909 YYSTACK_FREE (yyss);
1910#endif
1911 return yyresult;
1912}
1913
1914
1915
1916
1917
1918void conf_parse(const char *name)
1919{
1920 struct symbol *sym;
1921 int i;
1922
1923 zconf_initscan(name);
1924
1925 sym_init();
1926 menu_init();
1927 modules_sym = sym_lookup("MODULES", 0);
1928 rootmenu.prompt = menu_add_prop(P_MENU, "BusyBox Configuration", NULL, NULL);
1929
1930 //zconfdebug = 1;
1931 zconfparse();
1932 if (zconfnerrs)
1933 exit(1);
1934 menu_finalize(&rootmenu);
1935 for_all_symbols(i, sym) {
1936 if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym))
1937 printf("\n");
1938 else
1939 sym->flags |= SYMBOL_CHECK_DONE;
1940 }
1941
1942 sym_change_count = 1;
1943}
1944
1945const char *zconf_tokenname(int token)
1946{
1947 switch (token) {
1948 case T_MENU: return "menu";
1949 case T_ENDMENU: return "endmenu";
1950 case T_CHOICE: return "choice";
1951 case T_ENDCHOICE: return "endchoice";
1952 case T_IF: return "if";
1953 case T_ENDIF: return "endif";
1954 }
1955 return "<token>";
1956}
1957
1958static bool zconf_endtoken(int token, int starttoken, int endtoken)
1959{
1960 if (token != endtoken) {
1961 zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken));
1962 zconfnerrs++;
1963 return false;
1964 }
1965 if (current_menu->file != current_file) {
1966 zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken));
1967 zconfprint("location of the '%s'", zconf_tokenname(starttoken));
1968 zconfnerrs++;
1969 return false;
1970 }
1971 return true;
1972}
1973
1974static void zconfprint(const char *err, ...)
1975{
1976 va_list ap;
1977
1978 fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno() + 1);
1979 va_start(ap, err);
1980 vfprintf(stderr, err, ap);
1981 va_end(ap);
1982 fprintf(stderr, "\n");
1983}
1984
1985static void zconferror(const char *err)
1986{
1987 fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
1988}
1989
1990void print_quoted_string(FILE *out, const char *str)
1991{
1992 const char *p;
1993 int len;
1994
1995 putc('"', out);
1996 while ((p = strchr(str, '"'))) {
1997 len = p - str;
1998 if (len)
1999 fprintf(out, "%.*s", len, str);
2000 fputs("\\\"", out);
2001 str = p + 1;
2002 }
2003 fputs(str, out);
2004 putc('"', out);
2005}
2006
2007void print_symbol(FILE *out, struct menu *menu)
2008{
2009 struct symbol *sym = menu->sym;
2010 struct property *prop;
2011
2012 if (sym_is_choice(sym))
2013 fprintf(out, "choice\n");
2014 else
2015 fprintf(out, "config %s\n", sym->name);
2016 switch (sym->type) {
2017 case S_BOOLEAN:
2018 fputs(" boolean\n", out);
2019 break;
2020 case S_TRISTATE:
2021 fputs(" tristate\n", out);
2022 break;
2023 case S_STRING:
2024 fputs(" string\n", out);
2025 break;
2026 case S_INT:
2027 fputs(" integer\n", out);
2028 break;
2029 case S_HEX:
2030 fputs(" hex\n", out);
2031 break;
2032 default:
2033 fputs(" ???\n", out);
2034 break;
2035 }
2036 for (prop = sym->prop; prop; prop = prop->next) {
2037 if (prop->menu != menu)
2038 continue;
2039 switch (prop->type) {
2040 case P_PROMPT:
2041 fputs(" prompt ", out);
2042 print_quoted_string(out, prop->text);
2043 if (!expr_is_yes(prop->visible.expr)) {
2044 fputs(" if ", out);
2045 expr_fprint(prop->visible.expr, out);
2046 }
2047 fputc('\n', out);
2048 break;
2049 case P_DEFAULT:
2050 fputs( " default ", out);
2051 expr_fprint(prop->expr, out);
2052 if (!expr_is_yes(prop->visible.expr)) {
2053 fputs(" if ", out);
2054 expr_fprint(prop->visible.expr, out);
2055 }
2056 fputc('\n', out);
2057 break;
2058 case P_CHOICE:
2059 fputs(" #choice value\n", out);
2060 break;
2061 default:
2062 fprintf(out, " unknown prop %d!\n", prop->type);
2063 break;
2064 }
2065 }
2066 if (sym->help) {
2067 int len = strlen(sym->help);
2068 while (sym->help[--len] == '\n')
2069 sym->help[len] = 0;
2070 fprintf(out, " help\n%s\n", sym->help);
2071 }
2072 fputc('\n', out);
2073}
2074
2075void zconfdump(FILE *out)
2076{
2077 struct property *prop;
2078 struct symbol *sym;
2079 struct menu *menu;
2080
2081 menu = rootmenu.list;
2082 while (menu) {
2083 if ((sym = menu->sym))
2084 print_symbol(out, menu);
2085 else if ((prop = menu->prompt)) {
2086 switch (prop->type) {
2087 case P_COMMENT:
2088 fputs("\ncomment ", out);
2089 print_quoted_string(out, prop->text);
2090 fputs("\n", out);
2091 break;
2092 case P_MENU:
2093 fputs("\nmenu ", out);
2094 print_quoted_string(out, prop->text);
2095 fputs("\n", out);
2096 break;
2097 default:
2098 ;
2099 }
2100 if (!expr_is_yes(prop->visible.expr)) {
2101 fputs(" depends ", out);
2102 expr_fprint(prop->visible.expr, out);
2103 fputc('\n', out);
2104 }
2105 fputs("\n", out);
2106 }
2107
2108 if (menu->list)
2109 menu = menu->list;
2110 else if (menu->next)
2111 menu = menu->next;
2112 else while ((menu = menu->parent)) {
2113 if (menu->prompt && menu->prompt->type == P_MENU)
2114 fputs("\nendmenu\n", out);
2115 if (menu->next) {
2116 menu = menu->next;
2117 break;
2118 }
2119 }
2120 }
2121}
2122
2123#include "lex.zconf.c"
2124#include "util.c"
2125#include "confdata.c"
2126#include "expr.c"
2127#include "symbol.c"
2128#include "menu.c"
2129
2130
diff --git a/scripts/config/zconf.tab.h_shipped b/scripts/config/zconf.tab.h_shipped
deleted file mode 100644
index 3b191ef59..000000000
--- a/scripts/config/zconf.tab.h_shipped
+++ /dev/null
@@ -1,125 +0,0 @@
1/* A Bison parser, made from zconf.y, by GNU bison 1.75. */
2
3/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26#ifndef BISON_ZCONF_TAB_H
27# define BISON_ZCONF_TAB_H
28
29/* Tokens. */
30#ifndef YYTOKENTYPE
31# define YYTOKENTYPE
32 /* Put the tokens into the symbol table, so that GDB and other debuggers
33 know about them. */
34 enum yytokentype {
35 T_MAINMENU = 258,
36 T_MENU = 259,
37 T_ENDMENU = 260,
38 T_SOURCE = 261,
39 T_CHOICE = 262,
40 T_ENDCHOICE = 263,
41 T_COMMENT = 264,
42 T_CONFIG = 265,
43 T_HELP = 266,
44 T_HELPTEXT = 267,
45 T_IF = 268,
46 T_ENDIF = 269,
47 T_DEPENDS = 270,
48 T_REQUIRES = 271,
49 T_OPTIONAL = 272,
50 T_PROMPT = 273,
51 T_DEFAULT = 274,
52 T_TRISTATE = 275,
53 T_BOOLEAN = 276,
54 T_INT = 277,
55 T_HEX = 278,
56 T_WORD = 279,
57 T_STRING = 280,
58 T_UNEQUAL = 281,
59 T_EOF = 282,
60 T_EOL = 283,
61 T_CLOSE_PAREN = 284,
62 T_OPEN_PAREN = 285,
63 T_ON = 286,
64 T_OR = 287,
65 T_AND = 288,
66 T_EQUAL = 289,
67 T_NOT = 290
68 };
69#endif
70#define T_MAINMENU 258
71#define T_MENU 259
72#define T_ENDMENU 260
73#define T_SOURCE 261
74#define T_CHOICE 262
75#define T_ENDCHOICE 263
76#define T_COMMENT 264
77#define T_CONFIG 265
78#define T_HELP 266
79#define T_HELPTEXT 267
80#define T_IF 268
81#define T_ENDIF 269
82#define T_DEPENDS 270
83#define T_REQUIRES 271
84#define T_OPTIONAL 272
85#define T_PROMPT 273
86#define T_DEFAULT 274
87#define T_TRISTATE 275
88#define T_BOOLEAN 276
89#define T_INT 277
90#define T_HEX 278
91#define T_WORD 279
92#define T_STRING 280
93#define T_UNEQUAL 281
94#define T_EOF 282
95#define T_EOL 283
96#define T_CLOSE_PAREN 284
97#define T_OPEN_PAREN 285
98#define T_ON 286
99#define T_OR 287
100#define T_AND 288
101#define T_EQUAL 289
102#define T_NOT 290
103
104
105
106
107#ifndef YYSTYPE
108#line 33 "zconf.y"
109typedef union {
110 int token;
111 char *string;
112 struct symbol *symbol;
113 struct expr *expr;
114 struct menu *menu;
115} yystype;
116/* Line 1281 of /usr/share/bison/yacc.c. */
117#line 118 "zconf.tab.h"
118# define YYSTYPE yystype
119#endif
120
121extern YYSTYPE zconflval;
122
123
124#endif /* not BISON_ZCONF_TAB_H */
125
diff --git a/scripts/config/zconf.y b/scripts/config/zconf.y
deleted file mode 100644
index 5ebaf0a78..000000000
--- a/scripts/config/zconf.y
+++ /dev/null
@@ -1,690 +0,0 @@
1%{
2/*
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
4 * Released under the terms of the GNU GPL v2.0.
5 */
6
7#include <ctype.h>
8#include <stdarg.h>
9#include <stdio.h>
10#include <stdlib.h>
11#include <string.h>
12#include <stdbool.h>
13
14#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
15
16#define PRINTD 0x0001
17#define DEBUG_PARSE 0x0002
18
19int cdebug = PRINTD;
20
21extern int zconflex(void);
22static void zconfprint(const char *err, ...);
23static void zconferror(const char *err);
24static bool zconf_endtoken(int token, int starttoken, int endtoken);
25
26struct symbol *symbol_hash[257];
27
28static struct menu *current_menu, *current_entry;
29
30#define YYERROR_VERBOSE
31%}
32%expect 40
33
34%union
35{
36 int token;
37 char *string;
38 struct symbol *symbol;
39 struct expr *expr;
40 struct menu *menu;
41}
42
43%token T_MAINMENU
44%token T_MENU
45%token T_ENDMENU
46%token T_SOURCE
47%token T_CHOICE
48%token T_ENDCHOICE
49%token T_COMMENT
50%token T_CONFIG
51%token T_MENUCONFIG
52%token T_HELP
53%token <string> T_HELPTEXT
54%token T_IF
55%token T_ENDIF
56%token T_DEPENDS
57%token T_REQUIRES
58%token T_OPTIONAL
59%token T_PROMPT
60%token T_DEFAULT
61%token T_TRISTATE
62%token T_DEF_TRISTATE
63%token T_BOOLEAN
64%token T_DEF_BOOLEAN
65%token T_STRING
66%token T_INT
67%token T_HEX
68%token <string> T_WORD
69%token <string> T_WORD_QUOTE
70%token T_UNEQUAL
71%token T_EOF
72%token T_EOL
73%token T_CLOSE_PAREN
74%token T_OPEN_PAREN
75%token T_ON
76%token T_SELECT
77%token T_RANGE
78
79%left T_OR
80%left T_AND
81%left T_EQUAL T_UNEQUAL
82%nonassoc T_NOT
83
84%type <string> prompt
85%type <string> source
86%type <symbol> symbol
87%type <expr> expr
88%type <expr> if_expr
89%type <token> end
90
91%{
92#define LKC_DIRECT_LINK
93#include "lkc.h"
94%}
95%%
96input: /* empty */
97 | input block
98;
99
100block: common_block
101 | choice_stmt
102 | menu_stmt
103 | T_MAINMENU prompt nl_or_eof
104 | T_ENDMENU { zconfprint("unexpected 'endmenu' statement"); }
105 | T_ENDIF { zconfprint("unexpected 'endif' statement"); }
106 | T_ENDCHOICE { zconfprint("unexpected 'endchoice' statement"); }
107 | error nl_or_eof { zconfprint("syntax error"); yyerrok; }
108;
109
110common_block:
111 if_stmt
112 | comment_stmt
113 | config_stmt
114 | menuconfig_stmt
115 | source_stmt
116 | nl_or_eof
117;
118
119
120/* config/menuconfig entry */
121
122config_entry_start: T_CONFIG T_WORD T_EOL
123{
124 struct symbol *sym = sym_lookup($2, 0);
125 sym->flags |= SYMBOL_OPTIONAL;
126 menu_add_entry(sym);
127 printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2);
128};
129
130config_stmt: config_entry_start config_option_list
131{
132 menu_end_entry();
133 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
134};
135
136menuconfig_entry_start: T_MENUCONFIG T_WORD T_EOL
137{
138 struct symbol *sym = sym_lookup($2, 0);
139 sym->flags |= SYMBOL_OPTIONAL;
140 menu_add_entry(sym);
141 printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2);
142};
143
144menuconfig_stmt: menuconfig_entry_start config_option_list
145{
146 if (current_entry->prompt)
147 current_entry->prompt->type = P_MENU;
148 else
149 zconfprint("warning: menuconfig statement without prompt");
150 menu_end_entry();
151 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
152};
153
154config_option_list:
155 /* empty */
156 | config_option_list config_option
157 | config_option_list depends
158 | config_option_list help
159 | config_option_list T_EOL
160;
161
162config_option: T_TRISTATE prompt_stmt_opt T_EOL
163{
164 menu_set_type(S_TRISTATE);
165 printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno());
166};
167
168config_option: T_DEF_TRISTATE expr if_expr T_EOL
169{
170 menu_add_expr(P_DEFAULT, $2, $3);
171 menu_set_type(S_TRISTATE);
172 printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno());
173};
174
175config_option: T_BOOLEAN prompt_stmt_opt T_EOL
176{
177 menu_set_type(S_BOOLEAN);
178 printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno());
179};
180
181config_option: T_DEF_BOOLEAN expr if_expr T_EOL
182{
183 menu_add_expr(P_DEFAULT, $2, $3);
184 menu_set_type(S_BOOLEAN);
185 printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno());
186};
187
188config_option: T_INT prompt_stmt_opt T_EOL
189{
190 menu_set_type(S_INT);
191 printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno());
192};
193
194config_option: T_HEX prompt_stmt_opt T_EOL
195{
196 menu_set_type(S_HEX);
197 printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno());
198};
199
200config_option: T_STRING prompt_stmt_opt T_EOL
201{
202 menu_set_type(S_STRING);
203 printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno());
204};
205
206config_option: T_PROMPT prompt if_expr T_EOL
207{
208 menu_add_prompt(P_PROMPT, $2, $3);
209 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
210};
211
212config_option: T_DEFAULT expr if_expr T_EOL
213{
214 menu_add_expr(P_DEFAULT, $2, $3);
215 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno());
216};
217
218config_option: T_SELECT T_WORD if_expr T_EOL
219{
220 menu_add_symbol(P_SELECT, sym_lookup($2, 0), $3);
221 printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
222};
223
224config_option: T_RANGE symbol symbol if_expr T_EOL
225{
226 menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4);
227 printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
228};
229
230/* choice entry */
231
232choice: T_CHOICE T_EOL
233{
234 struct symbol *sym = sym_lookup(NULL, 0);
235 sym->flags |= SYMBOL_CHOICE;
236 menu_add_entry(sym);
237 menu_add_expr(P_CHOICE, NULL, NULL);
238 printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
239};
240
241choice_entry: choice choice_option_list
242{
243 menu_end_entry();
244 menu_add_menu();
245};
246
247choice_end: end
248{
249 if (zconf_endtoken($1, T_CHOICE, T_ENDCHOICE)) {
250 menu_end_menu();
251 printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
252 }
253};
254
255choice_stmt:
256 choice_entry choice_block choice_end
257 | choice_entry choice_block
258{
259 printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno);
260 zconfnerrs++;
261};
262
263choice_option_list:
264 /* empty */
265 | choice_option_list choice_option
266 | choice_option_list depends
267 | choice_option_list help
268 | choice_option_list T_EOL
269;
270
271choice_option: T_PROMPT prompt if_expr T_EOL
272{
273 menu_add_prompt(P_PROMPT, $2, $3);
274 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
275};
276
277choice_option: T_TRISTATE prompt_stmt_opt T_EOL
278{
279 menu_set_type(S_TRISTATE);
280 printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno());
281};
282
283choice_option: T_BOOLEAN prompt_stmt_opt T_EOL
284{
285 menu_set_type(S_BOOLEAN);
286 printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno());
287};
288
289choice_option: T_OPTIONAL T_EOL
290{
291 current_entry->sym->flags |= SYMBOL_OPTIONAL;
292 printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
293};
294
295choice_option: T_DEFAULT T_WORD if_expr T_EOL
296{
297 menu_add_symbol(P_DEFAULT, sym_lookup($2, 0), $3);
298 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno());
299};
300
301choice_block:
302 /* empty */
303 | choice_block common_block
304;
305
306/* if entry */
307
308if: T_IF expr T_EOL
309{
310 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
311 menu_add_entry(NULL);
312 menu_add_dep($2);
313 menu_end_entry();
314 menu_add_menu();
315};
316
317if_end: end
318{
319 if (zconf_endtoken($1, T_IF, T_ENDIF)) {
320 menu_end_menu();
321 printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
322 }
323};
324
325if_stmt:
326 if if_block if_end
327 | if if_block
328{
329 printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno);
330 zconfnerrs++;
331};
332
333if_block:
334 /* empty */
335 | if_block common_block
336 | if_block menu_stmt
337 | if_block choice_stmt
338;
339
340/* menu entry */
341
342menu: T_MENU prompt T_EOL
343{
344 menu_add_entry(NULL);
345 menu_add_prop(P_MENU, $2, NULL, NULL);
346 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
347};
348
349menu_entry: menu depends_list
350{
351 menu_end_entry();
352 menu_add_menu();
353};
354
355menu_end: end
356{
357 if (zconf_endtoken($1, T_MENU, T_ENDMENU)) {
358 menu_end_menu();
359 printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
360 }
361};
362
363menu_stmt:
364 menu_entry menu_block menu_end
365 | menu_entry menu_block
366{
367 printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno);
368 zconfnerrs++;
369};
370
371menu_block:
372 /* empty */
373 | menu_block common_block
374 | menu_block menu_stmt
375 | menu_block choice_stmt
376 | menu_block error T_EOL { zconfprint("invalid menu option"); yyerrok; }
377;
378
379source: T_SOURCE prompt T_EOL
380{
381 $$ = $2;
382 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2);
383};
384
385source_stmt: source
386{
387 zconf_nextfile($1);
388};
389
390/* comment entry */
391
392comment: T_COMMENT prompt T_EOL
393{
394 menu_add_entry(NULL);
395 menu_add_prop(P_COMMENT, $2, NULL, NULL);
396 printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
397};
398
399comment_stmt: comment depends_list
400{
401 menu_end_entry();
402};
403
404/* help option */
405
406help_start: T_HELP T_EOL
407{
408 printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
409 zconf_starthelp();
410};
411
412help: help_start T_HELPTEXT
413{
414 current_entry->sym->help = $2;
415};
416
417/* depends option */
418
419depends_list: /* empty */
420 | depends_list depends
421 | depends_list T_EOL
422;
423
424depends: T_DEPENDS T_ON expr T_EOL
425{
426 menu_add_dep($3);
427 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
428}
429 | T_DEPENDS expr T_EOL
430{
431 menu_add_dep($2);
432 printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno());
433}
434 | T_REQUIRES expr T_EOL
435{
436 menu_add_dep($2);
437 printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno());
438};
439
440/* prompt statement */
441
442prompt_stmt_opt:
443 /* empty */
444 | prompt if_expr
445{
446 menu_add_prop(P_PROMPT, $1, NULL, $2);
447};
448
449prompt: T_WORD
450 | T_WORD_QUOTE
451;
452
453end: T_ENDMENU nl_or_eof { $$ = T_ENDMENU; }
454 | T_ENDCHOICE nl_or_eof { $$ = T_ENDCHOICE; }
455 | T_ENDIF nl_or_eof { $$ = T_ENDIF; }
456;
457
458nl_or_eof:
459 T_EOL | T_EOF;
460
461if_expr: /* empty */ { $$ = NULL; }
462 | T_IF expr { $$ = $2; }
463;
464
465expr: symbol { $$ = expr_alloc_symbol($1); }
466 | symbol T_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); }
467 | symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); }
468 | T_OPEN_PAREN expr T_CLOSE_PAREN { $$ = $2; }
469 | T_NOT expr { $$ = expr_alloc_one(E_NOT, $2); }
470 | expr T_OR expr { $$ = expr_alloc_two(E_OR, $1, $3); }
471 | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); }
472;
473
474symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); }
475 | T_WORD_QUOTE { $$ = sym_lookup($1, 1); free($1); }
476;
477
478%%
479
480void conf_parse(const char *name)
481{
482 struct symbol *sym;
483 int i;
484
485 zconf_initscan(name);
486
487 sym_init();
488 menu_init();
489 modules_sym = sym_lookup("MODULES", 0);
490 rootmenu.prompt = menu_add_prop(P_MENU, "BusyBox Configuration", NULL, NULL);
491
492 //zconfdebug = 1;
493 zconfparse();
494 if (zconfnerrs)
495 exit(1);
496 menu_finalize(&rootmenu);
497 for_all_symbols(i, sym) {
498 if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym))
499 printf("\n");
500 else
501 sym->flags |= SYMBOL_CHECK_DONE;
502 }
503
504 sym_change_count = 1;
505}
506
507const char *zconf_tokenname(int token)
508{
509 switch (token) {
510 case T_MENU: return "menu";
511 case T_ENDMENU: return "endmenu";
512 case T_CHOICE: return "choice";
513 case T_ENDCHOICE: return "endchoice";
514 case T_IF: return "if";
515 case T_ENDIF: return "endif";
516 }
517 return "<token>";
518}
519
520static bool zconf_endtoken(int token, int starttoken, int endtoken)
521{
522 if (token != endtoken) {
523 zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken));
524 zconfnerrs++;
525 return false;
526 }
527 if (current_menu->file != current_file) {
528 zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken));
529 zconfprint("location of the '%s'", zconf_tokenname(starttoken));
530 zconfnerrs++;
531 return false;
532 }
533 return true;
534}
535
536static void zconfprint(const char *err, ...)
537{
538 va_list ap;
539
540 fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno() + 1);
541 va_start(ap, err);
542 vfprintf(stderr, err, ap);
543 va_end(ap);
544 fprintf(stderr, "\n");
545}
546
547static void zconferror(const char *err)
548{
549 fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
550}
551
552void print_quoted_string(FILE *out, const char *str)
553{
554 const char *p;
555 int len;
556
557 putc('"', out);
558 while ((p = strchr(str, '"'))) {
559 len = p - str;
560 if (len)
561 fprintf(out, "%.*s", len, str);
562 fputs("\\\"", out);
563 str = p + 1;
564 }
565 fputs(str, out);
566 putc('"', out);
567}
568
569void print_symbol(FILE *out, struct menu *menu)
570{
571 struct symbol *sym = menu->sym;
572 struct property *prop;
573
574 if (sym_is_choice(sym))
575 fprintf(out, "choice\n");
576 else
577 fprintf(out, "config %s\n", sym->name);
578 switch (sym->type) {
579 case S_BOOLEAN:
580 fputs(" boolean\n", out);
581 break;
582 case S_TRISTATE:
583 fputs(" tristate\n", out);
584 break;
585 case S_STRING:
586 fputs(" string\n", out);
587 break;
588 case S_INT:
589 fputs(" integer\n", out);
590 break;
591 case S_HEX:
592 fputs(" hex\n", out);
593 break;
594 default:
595 fputs(" ???\n", out);
596 break;
597 }
598 for (prop = sym->prop; prop; prop = prop->next) {
599 if (prop->menu != menu)
600 continue;
601 switch (prop->type) {
602 case P_PROMPT:
603 fputs(" prompt ", out);
604 print_quoted_string(out, prop->text);
605 if (!expr_is_yes(prop->visible.expr)) {
606 fputs(" if ", out);
607 expr_fprint(prop->visible.expr, out);
608 }
609 fputc('\n', out);
610 break;
611 case P_DEFAULT:
612 fputs( " default ", out);
613 expr_fprint(prop->expr, out);
614 if (!expr_is_yes(prop->visible.expr)) {
615 fputs(" if ", out);
616 expr_fprint(prop->visible.expr, out);
617 }
618 fputc('\n', out);
619 break;
620 case P_CHOICE:
621 fputs(" #choice value\n", out);
622 break;
623 default:
624 fprintf(out, " unknown prop %d!\n", prop->type);
625 break;
626 }
627 }
628 if (sym->help) {
629 int len = strlen(sym->help);
630 while (sym->help[--len] == '\n')
631 sym->help[len] = 0;
632 fprintf(out, " help\n%s\n", sym->help);
633 }
634 fputc('\n', out);
635}
636
637void zconfdump(FILE *out)
638{
639 struct property *prop;
640 struct symbol *sym;
641 struct menu *menu;
642
643 menu = rootmenu.list;
644 while (menu) {
645 if ((sym = menu->sym))
646 print_symbol(out, menu);
647 else if ((prop = menu->prompt)) {
648 switch (prop->type) {
649 case P_COMMENT:
650 fputs("\ncomment ", out);
651 print_quoted_string(out, prop->text);
652 fputs("\n", out);
653 break;
654 case P_MENU:
655 fputs("\nmenu ", out);
656 print_quoted_string(out, prop->text);
657 fputs("\n", out);
658 break;
659 default:
660 ;
661 }
662 if (!expr_is_yes(prop->visible.expr)) {
663 fputs(" depends ", out);
664 expr_fprint(prop->visible.expr, out);
665 fputc('\n', out);
666 }
667 fputs("\n", out);
668 }
669
670 if (menu->list)
671 menu = menu->list;
672 else if (menu->next)
673 menu = menu->next;
674 else while ((menu = menu->parent)) {
675 if (menu->prompt && menu->prompt->type == P_MENU)
676 fputs("\nendmenu\n", out);
677 if (menu->next) {
678 menu = menu->next;
679 break;
680 }
681 }
682 }
683}
684
685#include "lex.zconf.c"
686#include "util.c"
687#include "confdata.c"
688#include "expr.c"
689#include "symbol.c"
690#include "menu.c"