diff options
Diffstat (limited to 'scripts')
62 files changed, 13232 insertions, 7645 deletions
diff --git a/scripts/Kbuild b/scripts/Kbuild new file mode 100644 index 000000000..80c60733e --- /dev/null +++ b/scripts/Kbuild | |||
@@ -0,0 +1,11 @@ | |||
1 | ### | ||
2 | # scripts contains sources for various helper programs used throughout | ||
3 | # the kernel for the build process. | ||
4 | # --------------------------------------------------------------------------- | ||
5 | |||
6 | hostprogs-y += usage | ||
7 | |||
8 | always := $(hostprogs-y) | ||
9 | |||
10 | # Let clean descend into subdirs | ||
11 | subdir- += basic kconfig | ||
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include new file mode 100644 index 000000000..b0d067be7 --- /dev/null +++ b/scripts/Kbuild.include | |||
@@ -0,0 +1,148 @@ | |||
1 | #### | ||
2 | # kbuild: Generic definitions | ||
3 | |||
4 | # Convinient variables | ||
5 | comma := , | ||
6 | squote := ' | ||
7 | empty := | ||
8 | space := $(empty) $(empty) | ||
9 | |||
10 | ### | ||
11 | # The temporary file to save gcc -MD generated dependencies must not | ||
12 | # contain a comma | ||
13 | depfile = $(subst $(comma),_,$(@D)/.$(@F).d) | ||
14 | |||
15 | ### | ||
16 | # Escape single quote for use in echo statements | ||
17 | escsq = $(subst $(squote),'\$(squote)',$1) | ||
18 | |||
19 | ### | ||
20 | # filechk is used to check if the content of a generated file is updated. | ||
21 | # Sample usage: | ||
22 | # define filechk_sample | ||
23 | # echo $KERNELRELEASE | ||
24 | # endef | ||
25 | # version.h : Makefile | ||
26 | # $(call filechk,sample) | ||
27 | # The rule defined shall write to stdout the content of the new file. | ||
28 | # The existing file will be compared with the new one. | ||
29 | # - If no file exist it is created | ||
30 | # - If the content differ the new file is used | ||
31 | # - If they are equal no change, and no timestamp update | ||
32 | # - stdin is piped in from the first prerequisite ($<) so one has | ||
33 | # to specify a valid file as first prerequisite (often the kbuild file) | ||
34 | define filechk | ||
35 | $(Q)set -e; \ | ||
36 | echo ' CHK $@'; \ | ||
37 | mkdir -p $(dir $@); \ | ||
38 | $(filechk_$(1)) < $< > $@.tmp; \ | ||
39 | if [ -r $@ ] && cmp -s $@ $@.tmp; then \ | ||
40 | rm -f $@.tmp; \ | ||
41 | else \ | ||
42 | echo ' UPD $@'; \ | ||
43 | mv -f $@.tmp $@; \ | ||
44 | fi | ||
45 | endef | ||
46 | |||
47 | ###### | ||
48 | # gcc support functions | ||
49 | # See documentation in Documentation/kbuild/makefiles.txt | ||
50 | |||
51 | # as-option | ||
52 | # Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,) | ||
53 | |||
54 | as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \ | ||
55 | -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \ | ||
56 | else echo "$(2)"; fi ;) | ||
57 | |||
58 | # cc-option | ||
59 | # Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586) | ||
60 | |||
61 | cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ | ||
62 | > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) | ||
63 | |||
64 | # cc-option-yn | ||
65 | # Usage: flag := $(call cc-option-yn, -march=winchip-c6) | ||
66 | cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ | ||
67 | > /dev/null 2>&1; then echo "y"; else echo "n"; fi;) | ||
68 | |||
69 | # cc-option-align | ||
70 | # Prefix align with either -falign or -malign | ||
71 | cc-option-align = $(subst -functions=0,,\ | ||
72 | $(call cc-option,-falign-functions=0,-malign-functions=0)) | ||
73 | |||
74 | # cc-version | ||
75 | # Usage gcc-ver := $(call cc-version, $(CC)) | ||
76 | cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \ | ||
77 | $(if $(1), $(1), $(CC))) | ||
78 | |||
79 | # cc-ifversion | ||
80 | # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) | ||
81 | cc-ifversion = $(shell if [ $(call cc-version, $(CC)) $(1) $(2) ]; then \ | ||
82 | echo $(3); fi;) | ||
83 | |||
84 | ### | ||
85 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= | ||
86 | # Usage: | ||
87 | # $(Q)$(MAKE) $(build)=dir | ||
88 | build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj | ||
89 | |||
90 | # Prefix -I with $(srctree) if it is not an absolute path | ||
91 | addtree = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1) | ||
92 | # Find all -I options and call addtree | ||
93 | flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) | ||
94 | |||
95 | # If quiet is set, only print short version of command | ||
96 | cmd = @$(echo-cmd) $(cmd_$(1)) | ||
97 | |||
98 | # Add $(obj)/ for paths that is not absolute | ||
99 | objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) | ||
100 | |||
101 | ### | ||
102 | # if_changed - execute command if any prerequisite is newer than | ||
103 | # target, or command line has changed | ||
104 | # if_changed_dep - as if_changed, but uses fixdep to reveal dependencies | ||
105 | # including used config symbols | ||
106 | # if_changed_rule - as if_changed but execute rule instead | ||
107 | # See Documentation/kbuild/makefiles.txt for more info | ||
108 | |||
109 | ifneq ($(KBUILD_NOCMDDEP),1) | ||
110 | # Check if both arguments has same arguments. Result in empty string if equal | ||
111 | # User may override this check using make KBUILD_NOCMDDEP=1 | ||
112 | arg-check = $(strip $(filter-out $(1), $(2)) $(filter-out $(2), $(1)) ) | ||
113 | endif | ||
114 | |||
115 | # echo command. Short version is $(quiet) equals quiet, otherwise full command | ||
116 | echo-cmd = $(if $($(quiet)cmd_$(1)), \ | ||
117 | echo ' $(call escsq,$($(quiet)cmd_$(1)))';) | ||
118 | |||
119 | make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))) | ||
120 | |||
121 | # function to only execute the passed command if necessary | ||
122 | # >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file | ||
123 | # note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars | ||
124 | # | ||
125 | if_changed = $(if $(strip $(filter-out $(PHONY),$?) \ | ||
126 | $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ | ||
127 | @set -e; \ | ||
128 | $(echo-cmd) $(cmd_$(1)); \ | ||
129 | echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd) | ||
130 | |||
131 | # execute the command and also postprocess generated .d dependencies | ||
132 | # file | ||
133 | if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \ | ||
134 | $(filter-out FORCE $(wildcard $^),$^) \ | ||
135 | $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ | ||
136 | @set -e; \ | ||
137 | $(echo-cmd) $(cmd_$(1)); \ | ||
138 | scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \ | ||
139 | rm -f $(depfile); \ | ||
140 | mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) | ||
141 | |||
142 | # Usage: $(call if_changed_rule,foo) | ||
143 | # will check if $(cmd_foo) changed, or any of the prequisites changed, | ||
144 | # and if so will execute $(rule_foo) | ||
145 | if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?) \ | ||
146 | $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ | ||
147 | @set -e; \ | ||
148 | $(rule_$(1))) | ||
diff --git a/scripts/Makefile.build b/scripts/Makefile.build new file mode 100644 index 000000000..e48e60da3 --- /dev/null +++ b/scripts/Makefile.build | |||
@@ -0,0 +1,338 @@ | |||
1 | # ========================================================================== | ||
2 | # Building | ||
3 | # ========================================================================== | ||
4 | |||
5 | src := $(obj) | ||
6 | |||
7 | PHONY := __build | ||
8 | __build: | ||
9 | |||
10 | # Read .config if it exist, otherwise ignore | ||
11 | -include .config | ||
12 | |||
13 | include scripts/Kbuild.include | ||
14 | |||
15 | # The filename Kbuild has precedence over Makefile | ||
16 | kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) | ||
17 | include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) | ||
18 | |||
19 | include scripts/Makefile.lib | ||
20 | |||
21 | ifdef host-progs | ||
22 | ifneq ($(hostprogs-y),$(host-progs)) | ||
23 | $(warning kbuild: $(obj)/Makefile - Usage of host-progs is deprecated. Please replace with hostprogs-y!) | ||
24 | hostprogs-y += $(host-progs) | ||
25 | endif | ||
26 | endif | ||
27 | |||
28 | # Do not include host rules unles needed | ||
29 | ifneq ($(hostprogs-y)$(hostprogs-m),) | ||
30 | include scripts/Makefile.host | ||
31 | endif | ||
32 | |||
33 | ifneq ($(KBUILD_SRC),) | ||
34 | # Create output directory if not already present | ||
35 | _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) | ||
36 | |||
37 | # Create directories for object files if directory does not exist | ||
38 | # Needed when obj-y := dir/file.o syntax is used | ||
39 | _dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) | ||
40 | endif | ||
41 | |||
42 | |||
43 | ifdef EXTRA_TARGETS | ||
44 | $(warning kbuild: $(obj)/Makefile - Usage of EXTRA_TARGETS is obsolete in 2.6. Please fix!) | ||
45 | endif | ||
46 | |||
47 | ifdef build-targets | ||
48 | $(warning kbuild: $(obj)/Makefile - Usage of build-targets is obsolete in 2.6. Please fix!) | ||
49 | endif | ||
50 | |||
51 | ifdef export-objs | ||
52 | $(warning kbuild: $(obj)/Makefile - Usage of export-objs is obsolete in 2.6. Please fix!) | ||
53 | endif | ||
54 | |||
55 | ifdef O_TARGET | ||
56 | $(warning kbuild: $(obj)/Makefile - Usage of O_TARGET := $(O_TARGET) is obsolete in 2.6. Please fix!) | ||
57 | endif | ||
58 | |||
59 | ifdef L_TARGET | ||
60 | $(error kbuild: $(obj)/Makefile - Use of L_TARGET is replaced by lib-y in 2.6. Please fix!) | ||
61 | endif | ||
62 | |||
63 | ifdef list-multi | ||
64 | $(warning kbuild: $(obj)/Makefile - list-multi := $(list-multi) is obsolete in 2.6. Please fix!) | ||
65 | endif | ||
66 | |||
67 | ifndef obj | ||
68 | $(warning kbuild: Makefile.build is included improperly) | ||
69 | endif | ||
70 | |||
71 | # =========================================================================== | ||
72 | |||
73 | ifneq ($(strip $(lib-y) $(lib-m) $(lib-n) $(lib-)),) | ||
74 | lib-target := $(obj)/lib.a | ||
75 | endif | ||
76 | |||
77 | ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(lib-target)),) | ||
78 | builtin-target := $(obj)/built-in.o | ||
79 | endif | ||
80 | |||
81 | # We keep a list of all modules in $(MODVERDIR) | ||
82 | |||
83 | __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ | ||
84 | $(if $(KBUILD_MODULES),$(obj-m)) \ | ||
85 | $(subdir-ym) $(always) | ||
86 | @: | ||
87 | |||
88 | # Linus' kernel sanity checking tool | ||
89 | ifneq ($(KBUILD_CHECKSRC),0) | ||
90 | ifeq ($(KBUILD_CHECKSRC),2) | ||
91 | quiet_cmd_force_checksrc = CHECK $< | ||
92 | cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; | ||
93 | else | ||
94 | quiet_cmd_checksrc = CHECK $< | ||
95 | cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; | ||
96 | endif | ||
97 | endif | ||
98 | |||
99 | |||
100 | # Compile C sources (.c) | ||
101 | # --------------------------------------------------------------------------- | ||
102 | |||
103 | # Default is built-in, unless we know otherwise | ||
104 | modkern_cflags := $(CFLAGS_KERNEL) | ||
105 | quiet_modtag := $(empty) $(empty) | ||
106 | |||
107 | $(real-objs-m) : modkern_cflags := $(CFLAGS_MODULE) | ||
108 | $(real-objs-m:.o=.i) : modkern_cflags := $(CFLAGS_MODULE) | ||
109 | $(real-objs-m:.o=.s) : modkern_cflags := $(CFLAGS_MODULE) | ||
110 | $(real-objs-m:.o=.lst): modkern_cflags := $(CFLAGS_MODULE) | ||
111 | |||
112 | $(real-objs-m) : quiet_modtag := [M] | ||
113 | $(real-objs-m:.o=.i) : quiet_modtag := [M] | ||
114 | $(real-objs-m:.o=.s) : quiet_modtag := [M] | ||
115 | $(real-objs-m:.o=.lst): quiet_modtag := [M] | ||
116 | |||
117 | $(obj-m) : quiet_modtag := [M] | ||
118 | |||
119 | # Default for not multi-part modules | ||
120 | modname = $(*F) | ||
121 | |||
122 | $(multi-objs-m) : modname = $(modname-multi) | ||
123 | $(multi-objs-m:.o=.i) : modname = $(modname-multi) | ||
124 | $(multi-objs-m:.o=.s) : modname = $(modname-multi) | ||
125 | $(multi-objs-m:.o=.lst) : modname = $(modname-multi) | ||
126 | $(multi-objs-y) : modname = $(modname-multi) | ||
127 | $(multi-objs-y:.o=.i) : modname = $(modname-multi) | ||
128 | $(multi-objs-y:.o=.s) : modname = $(modname-multi) | ||
129 | $(multi-objs-y:.o=.lst) : modname = $(modname-multi) | ||
130 | |||
131 | quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ | ||
132 | cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< | ||
133 | |||
134 | %.s: %.c FORCE | ||
135 | $(call if_changed_dep,cc_s_c) | ||
136 | |||
137 | quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@ | ||
138 | cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $< | ||
139 | |||
140 | %.i: %.c FORCE | ||
141 | $(call if_changed_dep,cc_i_c) | ||
142 | |||
143 | # C (.c) files | ||
144 | # The C file is compiled and updated dependency information is generated. | ||
145 | # (See cmd_cc_o_c + relevant part of rule_cc_o_c) | ||
146 | |||
147 | quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ | ||
148 | |||
149 | ifndef CONFIG_MODVERSIONS | ||
150 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< | ||
151 | |||
152 | else | ||
153 | # When module versioning is enabled the following steps are executed: | ||
154 | # o compile a .tmp_<file>.o from <file>.c | ||
155 | # o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does | ||
156 | # not export symbols, we just rename .tmp_<file>.o to <file>.o and | ||
157 | # are done. | ||
158 | # o otherwise, we calculate symbol versions using the good old | ||
159 | # genksyms on the preprocessed source and postprocess them in a way | ||
160 | # that they are usable as a linker script | ||
161 | # o generate <file>.o from .tmp_<file>.o using the linker to | ||
162 | # replace the unresolved symbols __crc_exported_symbol with | ||
163 | # the actual value of the checksum generated by genksyms | ||
164 | |||
165 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< | ||
166 | cmd_modversions = \ | ||
167 | if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ | ||
168 | $(CPP) -D__GENKSYMS__ $(c_flags) $< \ | ||
169 | | $(GENKSYMS) -a $(ARCH) \ | ||
170 | > $(@D)/.tmp_$(@F:.o=.ver); \ | ||
171 | \ | ||
172 | $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ | ||
173 | -T $(@D)/.tmp_$(@F:.o=.ver); \ | ||
174 | rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ | ||
175 | else \ | ||
176 | mv -f $(@D)/.tmp_$(@F) $@; \ | ||
177 | fi; | ||
178 | endif | ||
179 | |||
180 | define rule_cc_o_c | ||
181 | $(call echo-cmd,checksrc) $(cmd_checksrc) \ | ||
182 | $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ | ||
183 | $(cmd_modversions) \ | ||
184 | scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > $(@D)/.$(@F).tmp; \ | ||
185 | rm -f $(depfile); \ | ||
186 | mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd | ||
187 | endef | ||
188 | |||
189 | # Built-in and composite module parts | ||
190 | |||
191 | %.o: %.c FORCE | ||
192 | $(call cmd,force_checksrc) | ||
193 | $(call if_changed_rule,cc_o_c) | ||
194 | |||
195 | # Single-part modules are special since we need to mark them in $(MODVERDIR) | ||
196 | |||
197 | $(single-used-m): %.o: %.c FORCE | ||
198 | $(call cmd,force_checksrc) | ||
199 | $(call if_changed_rule,cc_o_c) | ||
200 | @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod) | ||
201 | |||
202 | quiet_cmd_cc_lst_c = MKLST $@ | ||
203 | cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ | ||
204 | $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ | ||
205 | System.map $(OBJDUMP) > $@ | ||
206 | |||
207 | %.lst: %.c FORCE | ||
208 | $(call if_changed_dep,cc_lst_c) | ||
209 | |||
210 | # Compile assembler sources (.S) | ||
211 | # --------------------------------------------------------------------------- | ||
212 | |||
213 | modkern_aflags := $(AFLAGS_KERNEL) | ||
214 | |||
215 | $(real-objs-m) : modkern_aflags := $(AFLAGS_MODULE) | ||
216 | $(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE) | ||
217 | |||
218 | quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ | ||
219 | cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< | ||
220 | |||
221 | %.s: %.S FORCE | ||
222 | $(call if_changed_dep,as_s_S) | ||
223 | |||
224 | quiet_cmd_as_o_S = AS $(quiet_modtag) $@ | ||
225 | cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< | ||
226 | |||
227 | %.o: %.S FORCE | ||
228 | $(call if_changed_dep,as_o_S) | ||
229 | |||
230 | targets += $(real-objs-y) $(real-objs-m) $(lib-y) | ||
231 | targets += $(extra-y) $(MAKECMDGOALS) $(always) | ||
232 | |||
233 | # Linker scripts preprocessor (.lds.S -> .lds) | ||
234 | # --------------------------------------------------------------------------- | ||
235 | quiet_cmd_cpp_lds_S = LDS $@ | ||
236 | cmd_cpp_lds_S = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -o $@ $< | ||
237 | |||
238 | %.lds: %.lds.S FORCE | ||
239 | $(call if_changed_dep,cpp_lds_S) | ||
240 | |||
241 | # Build the compiled-in targets | ||
242 | # --------------------------------------------------------------------------- | ||
243 | |||
244 | # To build objects in subdirs, we need to descend into the directories | ||
245 | $(sort $(subdir-obj-y)): $(subdir-ym) ; | ||
246 | |||
247 | # | ||
248 | # Rule to compile a set of .o files into one .o file | ||
249 | # | ||
250 | ifdef builtin-target | ||
251 | quiet_cmd_link_o_target = LD $@ | ||
252 | # If the list of objects to link is empty, just create an empty built-in.o | ||
253 | cmd_link_o_target = $(if $(strip $(obj-y)),\ | ||
254 | $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\ | ||
255 | rm -f $@; $(AR) rcs $@) | ||
256 | |||
257 | $(builtin-target): $(obj-y) FORCE | ||
258 | $(call if_changed,link_o_target) | ||
259 | |||
260 | targets += $(builtin-target) | ||
261 | endif # builtin-target | ||
262 | |||
263 | # | ||
264 | # Rule to compile a set of .o files into one .a file | ||
265 | # | ||
266 | ifdef lib-target | ||
267 | quiet_cmd_link_l_target = AR $@ | ||
268 | cmd_link_l_target = rm -f $@; $(AR) $(EXTRA_ARFLAGS) rcs $@ $(lib-y) | ||
269 | |||
270 | $(lib-target): $(lib-y) FORCE | ||
271 | $(call if_changed,link_l_target) | ||
272 | |||
273 | targets += $(lib-target) | ||
274 | endif | ||
275 | |||
276 | # | ||
277 | # Rule to link composite objects | ||
278 | # | ||
279 | # Composite objects are specified in kbuild makefile as follows: | ||
280 | # <composite-object>-objs := <list of .o files> | ||
281 | # or | ||
282 | # <composite-object>-y := <list of .o files> | ||
283 | link_multi_deps = \ | ||
284 | $(filter $(addprefix $(obj)/, \ | ||
285 | $($(subst $(obj)/,,$(@:.o=-objs))) \ | ||
286 | $($(subst $(obj)/,,$(@:.o=-y)))), $^) | ||
287 | |||
288 | quiet_cmd_link_multi-y = LD $@ | ||
289 | cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) | ||
290 | |||
291 | quiet_cmd_link_multi-m = LD [M] $@ | ||
292 | cmd_link_multi-m = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps) | ||
293 | |||
294 | # We would rather have a list of rules like | ||
295 | # foo.o: $(foo-objs) | ||
296 | # but that's not so easy, so we rather make all composite objects depend | ||
297 | # on the set of all their parts | ||
298 | $(multi-used-y) : %.o: $(multi-objs-y) FORCE | ||
299 | $(call if_changed,link_multi-y) | ||
300 | |||
301 | $(multi-used-m) : %.o: $(multi-objs-m) FORCE | ||
302 | $(call if_changed,link_multi-m) | ||
303 | @{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod) | ||
304 | |||
305 | targets += $(multi-used-y) $(multi-used-m) | ||
306 | |||
307 | |||
308 | # Descending | ||
309 | # --------------------------------------------------------------------------- | ||
310 | |||
311 | PHONY += $(subdir-ym) | ||
312 | $(subdir-ym): | ||
313 | $(Q)$(MAKE) $(build)=$@ | ||
314 | |||
315 | # Add FORCE to the prequisites of a target to force it to be always rebuilt. | ||
316 | # --------------------------------------------------------------------------- | ||
317 | |||
318 | PHONY += FORCE | ||
319 | |||
320 | FORCE: | ||
321 | |||
322 | # Read all saved command lines and dependencies for the $(targets) we | ||
323 | # may be building above, using $(if_changed{,_dep}). As an | ||
324 | # optimization, we don't need to read them if the target does not | ||
325 | # exist, we will rebuild anyway in that case. | ||
326 | |||
327 | targets := $(wildcard $(sort $(targets))) | ||
328 | cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) | ||
329 | |||
330 | ifneq ($(cmd_files),) | ||
331 | include $(cmd_files) | ||
332 | endif | ||
333 | |||
334 | |||
335 | # Declare the contents of the .PHONY variable as phony. We keep that | ||
336 | # information in a variable se we can use it in if_changed and friends. | ||
337 | |||
338 | .PHONY: $(PHONY) | ||
diff --git a/scripts/Makefile.host b/scripts/Makefile.host new file mode 100644 index 000000000..2d519704b --- /dev/null +++ b/scripts/Makefile.host | |||
@@ -0,0 +1,156 @@ | |||
1 | # ========================================================================== | ||
2 | # Building binaries on the host system | ||
3 | # Binaries are used during the compilation of the kernel, for example | ||
4 | # to preprocess a data file. | ||
5 | # | ||
6 | # Both C and C++ is supported, but preferred language is C for such utilities. | ||
7 | # | ||
8 | # Samle syntax (see Documentation/kbuild/makefile.txt for reference) | ||
9 | # hostprogs-y := bin2hex | ||
10 | # Will compile bin2hex.c and create an executable named bin2hex | ||
11 | # | ||
12 | # hostprogs-y := lxdialog | ||
13 | # lxdialog-objs := checklist.o lxdialog.o | ||
14 | # Will compile lxdialog.c and checklist.c, and then link the executable | ||
15 | # lxdialog, based on checklist.o and lxdialog.o | ||
16 | # | ||
17 | # hostprogs-y := qconf | ||
18 | # qconf-cxxobjs := qconf.o | ||
19 | # qconf-objs := menu.o | ||
20 | # Will compile qconf as a C++ program, and menu as a C program. | ||
21 | # They are linked as C++ code to the executable qconf | ||
22 | |||
23 | # hostprogs-y := conf | ||
24 | # conf-objs := conf.o libkconfig.so | ||
25 | # libkconfig-objs := expr.o type.o | ||
26 | # Will create a shared library named libkconfig.so that consist of | ||
27 | # expr.o and type.o (they are both compiled as C code and the object file | ||
28 | # are made as position independent code). | ||
29 | # conf.c is compiled as a c program, and conf.o is linked together with | ||
30 | # libkconfig.so as the executable conf. | ||
31 | # Note: Shared libraries consisting of C++ files are not supported | ||
32 | |||
33 | __hostprogs := $(sort $(hostprogs-y)$(hostprogs-m)) | ||
34 | |||
35 | # hostprogs-y := tools/build may have been specified. Retreive directory | ||
36 | obj-dirs += $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f)))) | ||
37 | obj-dirs := $(strip $(sort $(filter-out ./,$(obj-dirs)))) | ||
38 | |||
39 | |||
40 | # C code | ||
41 | # Executables compiled from a single .c file | ||
42 | host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m))) | ||
43 | |||
44 | # C executables linked based on several .o files | ||
45 | host-cmulti := $(foreach m,$(__hostprogs),\ | ||
46 | $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m)))) | ||
47 | |||
48 | # Object (.o) files compiled from .c files | ||
49 | host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs))) | ||
50 | |||
51 | # C++ code | ||
52 | # C++ executables compiled from at least on .cc file | ||
53 | # and zero or more .c files | ||
54 | host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m))) | ||
55 | |||
56 | # C++ Object (.o) files compiled from .cc files | ||
57 | host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) | ||
58 | |||
59 | # Shared libaries (only .c supported) | ||
60 | # Shared libraries (.so) - all .so files referenced in "xxx-objs" | ||
61 | host-cshlib := $(sort $(filter %.so, $(host-cobjs))) | ||
62 | # Remove .so files from "xxx-objs" | ||
63 | host-cobjs := $(filter-out %.so,$(host-cobjs)) | ||
64 | |||
65 | #Object (.o) files used by the shared libaries | ||
66 | host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) | ||
67 | |||
68 | __hostprogs := $(addprefix $(obj)/,$(__hostprogs)) | ||
69 | host-csingle := $(addprefix $(obj)/,$(host-csingle)) | ||
70 | host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) | ||
71 | host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) | ||
72 | host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti)) | ||
73 | host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs)) | ||
74 | host-cshlib := $(addprefix $(obj)/,$(host-cshlib)) | ||
75 | host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs)) | ||
76 | obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) | ||
77 | |||
78 | ##### | ||
79 | # Handle options to gcc. Support building with separate output directory | ||
80 | |||
81 | _hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(*F).o) | ||
82 | _hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) $(HOSTCXXFLAGS_$(*F).o) | ||
83 | |||
84 | ifeq ($(KBUILD_SRC),) | ||
85 | __hostc_flags = $(_hostc_flags) | ||
86 | __hostcxx_flags = $(_hostcxx_flags) | ||
87 | else | ||
88 | __hostc_flags = -I$(obj) $(call flags,_hostc_flags) | ||
89 | __hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) | ||
90 | endif | ||
91 | |||
92 | hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) | ||
93 | hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) | ||
94 | |||
95 | ##### | ||
96 | # Compile programs on the host | ||
97 | |||
98 | # Create executable from a single .c file | ||
99 | # host-csingle -> Executable | ||
100 | quiet_cmd_host-csingle = HOSTCC $@ | ||
101 | cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@ $< \ | ||
102 | $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) | ||
103 | $(host-csingle): %: %.c FORCE | ||
104 | $(call if_changed_dep,host-csingle) | ||
105 | |||
106 | # Link an executable based on list of .o files, all plain c | ||
107 | # host-cmulti -> executable | ||
108 | quiet_cmd_host-cmulti = HOSTLD $@ | ||
109 | cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \ | ||
110 | $(addprefix $(obj)/,$($(@F)-objs)) \ | ||
111 | $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) | ||
112 | $(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE | ||
113 | $(call if_changed,host-cmulti) | ||
114 | |||
115 | # Create .o file from a single .c file | ||
116 | # host-cobjs -> .o | ||
117 | quiet_cmd_host-cobjs = HOSTCC $@ | ||
118 | cmd_host-cobjs = $(HOSTCC) $(hostc_flags) -c -o $@ $< | ||
119 | $(host-cobjs): %.o: %.c FORCE | ||
120 | $(call if_changed_dep,host-cobjs) | ||
121 | |||
122 | # Link an executable based on list of .o files, a mixture of .c and .cc | ||
123 | # host-cxxmulti -> executable | ||
124 | quiet_cmd_host-cxxmulti = HOSTLD $@ | ||
125 | cmd_host-cxxmulti = $(HOSTCXX) $(HOSTLDFLAGS) -o $@ \ | ||
126 | $(foreach o,objs cxxobjs,\ | ||
127 | $(addprefix $(obj)/,$($(@F)-$(o)))) \ | ||
128 | $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) | ||
129 | $(host-cxxmulti): %: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE | ||
130 | $(call if_changed,host-cxxmulti) | ||
131 | |||
132 | # Create .o file from a single .cc (C++) file | ||
133 | quiet_cmd_host-cxxobjs = HOSTCXX $@ | ||
134 | cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx_flags) -c -o $@ $< | ||
135 | $(host-cxxobjs): %.o: %.cc FORCE | ||
136 | $(call if_changed_dep,host-cxxobjs) | ||
137 | |||
138 | # Compile .c file, create position independent .o file | ||
139 | # host-cshobjs -> .o | ||
140 | quiet_cmd_host-cshobjs = HOSTCC -fPIC $@ | ||
141 | cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $< | ||
142 | $(host-cshobjs): %.o: %.c FORCE | ||
143 | $(call if_changed_dep,host-cshobjs) | ||
144 | |||
145 | # Link a shared library, based on position independent .o files | ||
146 | # *.o -> .so shared library (host-cshlib) | ||
147 | quiet_cmd_host-cshlib = HOSTLLD -shared $@ | ||
148 | cmd_host-cshlib = $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \ | ||
149 | $(addprefix $(obj)/,$($(@F:.so=-objs))) \ | ||
150 | $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) | ||
151 | $(host-cshlib): %: $(host-cshobjs) FORCE | ||
152 | $(call if_changed,host-cshlib) | ||
153 | |||
154 | targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\ | ||
155 | $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) | ||
156 | |||
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib new file mode 100644 index 000000000..2cb4935e8 --- /dev/null +++ b/scripts/Makefile.lib | |||
@@ -0,0 +1,165 @@ | |||
1 | # Backward compatibility - to be removed... | ||
2 | extra-y += $(EXTRA_TARGETS) | ||
3 | # Figure out what we need to build from the various variables | ||
4 | # =========================================================================== | ||
5 | |||
6 | # When an object is listed to be built compiled-in and modular, | ||
7 | # only build the compiled-in version | ||
8 | |||
9 | obj-m := $(filter-out $(obj-y),$(obj-m)) | ||
10 | |||
11 | # Libraries are always collected in one lib file. | ||
12 | # Filter out objects already built-in | ||
13 | |||
14 | lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) | ||
15 | |||
16 | |||
17 | # Handle objects in subdirs | ||
18 | # --------------------------------------------------------------------------- | ||
19 | # o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o | ||
20 | # and add the directory to the list of dirs to descend into: $(subdir-y) | ||
21 | # o if we encounter foo/ in $(obj-m), remove it from $(obj-m) | ||
22 | # and add the directory to the list of dirs to descend into: $(subdir-m) | ||
23 | |||
24 | __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) | ||
25 | subdir-y += $(__subdir-y) | ||
26 | __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) | ||
27 | subdir-m += $(__subdir-m) | ||
28 | obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) | ||
29 | obj-m := $(filter-out %/, $(obj-m)) | ||
30 | |||
31 | # Subdirectories we need to descend into | ||
32 | |||
33 | subdir-ym := $(sort $(subdir-y) $(subdir-m)) | ||
34 | |||
35 | # if $(foo-objs) exists, foo.o is a composite object | ||
36 | multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) | ||
37 | multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) | ||
38 | multi-used := $(multi-used-y) $(multi-used-m) | ||
39 | single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m))) | ||
40 | |||
41 | # Build list of the parts of our composite objects, our composite | ||
42 | # objects depend on those (obviously) | ||
43 | multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y))) | ||
44 | multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) | ||
45 | multi-objs := $(multi-objs-y) $(multi-objs-m) | ||
46 | |||
47 | # $(subdir-obj-y) is the list of objects in $(obj-y) which do not live | ||
48 | # in the local directory | ||
49 | subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o))) | ||
50 | |||
51 | # $(obj-dirs) is a list of directories that contain object files | ||
52 | obj-dirs := $(dir $(multi-objs) $(subdir-obj-y)) | ||
53 | |||
54 | # Replace multi-part objects by their individual parts, look at local dir only | ||
55 | real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y) | ||
56 | real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) | ||
57 | |||
58 | # Add subdir path | ||
59 | |||
60 | extra-y := $(addprefix $(obj)/,$(extra-y)) | ||
61 | always := $(addprefix $(obj)/,$(always)) | ||
62 | targets := $(addprefix $(obj)/,$(targets)) | ||
63 | obj-y := $(addprefix $(obj)/,$(obj-y)) | ||
64 | obj-m := $(addprefix $(obj)/,$(obj-m)) | ||
65 | lib-y := $(addprefix $(obj)/,$(lib-y)) | ||
66 | subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) | ||
67 | real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) | ||
68 | real-objs-m := $(addprefix $(obj)/,$(real-objs-m)) | ||
69 | single-used-m := $(addprefix $(obj)/,$(single-used-m)) | ||
70 | multi-used-y := $(addprefix $(obj)/,$(multi-used-y)) | ||
71 | multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) | ||
72 | multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y)) | ||
73 | multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m)) | ||
74 | subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) | ||
75 | obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) | ||
76 | |||
77 | # These flags are needed for modversions and compiling, so we define them here | ||
78 | # already | ||
79 | # $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will | ||
80 | # end up in (or would, if it gets compiled in) | ||
81 | # Note: It's possible that one object gets potentially linked into more | ||
82 | # than one module. In that case KBUILD_MODNAME will be set to foo_bar, | ||
83 | # where foo and bar are the name of the modules. | ||
84 | name-fix = $(subst $(comma),_,$(subst -,_,$1)) | ||
85 | basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(*F)))" | ||
86 | modname_flags = $(if $(filter 1,$(words $(modname))),\ | ||
87 | -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") | ||
88 | |||
89 | _c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) | ||
90 | _a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) | ||
91 | _cpp_flags = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F)) | ||
92 | |||
93 | # If building the kernel in a separate objtree expand all occurrences | ||
94 | # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). | ||
95 | |||
96 | ifeq ($(KBUILD_SRC),) | ||
97 | __c_flags = $(_c_flags) | ||
98 | __a_flags = $(_a_flags) | ||
99 | __cpp_flags = $(_cpp_flags) | ||
100 | else | ||
101 | |||
102 | # -I$(obj) locates generated .h files | ||
103 | # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files | ||
104 | # and locates generated .h files | ||
105 | # FIXME: Replace both with specific CFLAGS* statements in the makefiles | ||
106 | __c_flags = $(call addtree,-I$(obj)) $(call flags,_c_flags) | ||
107 | __a_flags = $(call flags,_a_flags) | ||
108 | __cpp_flags = $(call flags,_cpp_flags) | ||
109 | endif | ||
110 | |||
111 | c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \ | ||
112 | $(__c_flags) $(modkern_cflags) \ | ||
113 | -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) | ||
114 | |||
115 | a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \ | ||
116 | $(__a_flags) $(modkern_aflags) | ||
117 | |||
118 | cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags) | ||
119 | |||
120 | ld_flags = $(LDFLAGS) $(EXTRA_LDFLAGS) | ||
121 | |||
122 | # Finds the multi-part object the current object will be linked into | ||
123 | modname-multi = $(sort $(foreach m,$(multi-used),\ | ||
124 | $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=)))) | ||
125 | |||
126 | # Shipped files | ||
127 | # =========================================================================== | ||
128 | |||
129 | quiet_cmd_shipped = SHIPPED $@ | ||
130 | cmd_shipped = cat $< > $@ | ||
131 | |||
132 | $(obj)/%:: $(src)/%_shipped | ||
133 | $(call cmd,shipped) | ||
134 | |||
135 | # Commands useful for building a boot image | ||
136 | # =========================================================================== | ||
137 | # | ||
138 | # Use as following: | ||
139 | # | ||
140 | # target: source(s) FORCE | ||
141 | # $(if_changed,ld/objcopy/gzip) | ||
142 | # | ||
143 | # and add target to EXTRA_TARGETS so that we know we have to | ||
144 | # read in the saved command line | ||
145 | |||
146 | # Linking | ||
147 | # --------------------------------------------------------------------------- | ||
148 | |||
149 | quiet_cmd_ld = LD $@ | ||
150 | cmd_ld = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) \ | ||
151 | $(filter-out FORCE,$^) -o $@ | ||
152 | |||
153 | # Objcopy | ||
154 | # --------------------------------------------------------------------------- | ||
155 | |||
156 | quiet_cmd_objcopy = OBJCOPY $@ | ||
157 | cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ | ||
158 | |||
159 | # Gzip | ||
160 | # --------------------------------------------------------------------------- | ||
161 | |||
162 | quiet_cmd_gzip = GZIP $@ | ||
163 | cmd_gzip = gzip -f -9 < $< > $@ | ||
164 | |||
165 | |||
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile new file mode 100644 index 000000000..f22e94c3a --- /dev/null +++ b/scripts/basic/Makefile | |||
@@ -0,0 +1,18 @@ | |||
1 | ### | ||
2 | # Makefile.basic list the most basic programs used during the build process. | ||
3 | # The programs listed herein is what is needed to do the basic stuff, | ||
4 | # such as splitting .config and fix dependency file. | ||
5 | # This initial step is needed to avoid files to be recompiled | ||
6 | # when kernel configuration changes (which is what happens when | ||
7 | # .config is included by main Makefile. | ||
8 | # --------------------------------------------------------------------------- | ||
9 | # fixdep: Used to generate dependency information during build process | ||
10 | # split-include: Divide all config symbols up in a number of files in | ||
11 | # include/config/... | ||
12 | # docproc: Used in Documentation/docbook | ||
13 | |||
14 | hostprogs-y := fixdep split-include docproc | ||
15 | always := $(hostprogs-y) | ||
16 | |||
17 | # fixdep is needed to compile other host programs | ||
18 | $(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep | ||
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c new file mode 100644 index 000000000..cb02baa63 --- /dev/null +++ b/scripts/basic/docproc.c | |||
@@ -0,0 +1,398 @@ | |||
1 | /* | ||
2 | * docproc is a simple preprocessor for the template files | ||
3 | * used as placeholders for the kernel internal documentation. | ||
4 | * docproc is used for documentation-frontend and | ||
5 | * dependency-generator. | ||
6 | * The two usages have in common that they require | ||
7 | * some knowledge of the .tmpl syntax, therefore they | ||
8 | * are kept together. | ||
9 | * | ||
10 | * documentation-frontend | ||
11 | * Scans the template file and call kernel-doc for | ||
12 | * all occurrences of ![EIF]file | ||
13 | * Beforehand each referenced file are scanned for | ||
14 | * any exported sympols "EXPORT_SYMBOL()" statements. | ||
15 | * This is used to create proper -function and | ||
16 | * -nofunction arguments in calls to kernel-doc. | ||
17 | * Usage: docproc doc file.tmpl | ||
18 | * | ||
19 | * dependency-generator: | ||
20 | * Scans the template file and list all files | ||
21 | * referenced in a format recognized by make. | ||
22 | * Usage: docproc depend file.tmpl | ||
23 | * Writes dependency information to stdout | ||
24 | * in the following format: | ||
25 | * file.tmpl src.c src2.c | ||
26 | * The filenames are obtained from the following constructs: | ||
27 | * !Efilename | ||
28 | * !Ifilename | ||
29 | * !Dfilename | ||
30 | * !Ffilename | ||
31 | * | ||
32 | */ | ||
33 | |||
34 | #include <stdio.h> | ||
35 | #include <stdlib.h> | ||
36 | #include <string.h> | ||
37 | #include <ctype.h> | ||
38 | #include <unistd.h> | ||
39 | #include <limits.h> | ||
40 | #include <sys/types.h> | ||
41 | #include <sys/wait.h> | ||
42 | |||
43 | /* exitstatus is used to keep track of any failing calls to kernel-doc, | ||
44 | * but execution continues. */ | ||
45 | int exitstatus = 0; | ||
46 | |||
47 | typedef void DFL(char *); | ||
48 | DFL *defaultline; | ||
49 | |||
50 | typedef void FILEONLY(char * file); | ||
51 | FILEONLY *internalfunctions; | ||
52 | FILEONLY *externalfunctions; | ||
53 | FILEONLY *symbolsonly; | ||
54 | |||
55 | typedef void FILELINE(char * file, char * line); | ||
56 | FILELINE * singlefunctions; | ||
57 | FILELINE * entity_system; | ||
58 | |||
59 | #define MAXLINESZ 2048 | ||
60 | #define MAXFILES 250 | ||
61 | #define KERNELDOCPATH "scripts/" | ||
62 | #define KERNELDOC "kernel-doc" | ||
63 | #define DOCBOOK "-docbook" | ||
64 | #define FUNCTION "-function" | ||
65 | #define NOFUNCTION "-nofunction" | ||
66 | |||
67 | void usage (void) | ||
68 | { | ||
69 | fprintf(stderr, "Usage: docproc {doc|depend} file\n"); | ||
70 | fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n"); | ||
71 | fprintf(stderr, "doc: frontend when generating kernel documentation\n"); | ||
72 | fprintf(stderr, "depend: generate list of files referenced within file\n"); | ||
73 | } | ||
74 | |||
75 | /* | ||
76 | * Execute kernel-doc with parameters givin in svec | ||
77 | */ | ||
78 | void exec_kernel_doc(char **svec) | ||
79 | { | ||
80 | pid_t pid; | ||
81 | int ret; | ||
82 | char real_filename[PATH_MAX + 1]; | ||
83 | /* Make sure output generated so far are flushed */ | ||
84 | fflush(stdout); | ||
85 | switch(pid=fork()) { | ||
86 | case -1: | ||
87 | perror("fork"); | ||
88 | exit(1); | ||
89 | case 0: | ||
90 | memset(real_filename, 0, sizeof(real_filename)); | ||
91 | strncat(real_filename, getenv("SRCTREE"), PATH_MAX); | ||
92 | strncat(real_filename, KERNELDOCPATH KERNELDOC, | ||
93 | PATH_MAX - strlen(real_filename)); | ||
94 | execvp(real_filename, svec); | ||
95 | fprintf(stderr, "exec "); | ||
96 | perror(real_filename); | ||
97 | exit(1); | ||
98 | default: | ||
99 | waitpid(pid, &ret ,0); | ||
100 | } | ||
101 | if (WIFEXITED(ret)) | ||
102 | exitstatus |= WEXITSTATUS(ret); | ||
103 | else | ||
104 | exitstatus = 0xff; | ||
105 | } | ||
106 | |||
107 | /* Types used to create list of all exported symbols in a number of files */ | ||
108 | struct symbols | ||
109 | { | ||
110 | char *name; | ||
111 | }; | ||
112 | |||
113 | struct symfile | ||
114 | { | ||
115 | char *filename; | ||
116 | struct symbols *symbollist; | ||
117 | int symbolcnt; | ||
118 | }; | ||
119 | |||
120 | struct symfile symfilelist[MAXFILES]; | ||
121 | int symfilecnt = 0; | ||
122 | |||
123 | void add_new_symbol(struct symfile *sym, char * symname) | ||
124 | { | ||
125 | sym->symbollist = | ||
126 | realloc(sym->symbollist, (sym->symbolcnt + 1) * sizeof(char *)); | ||
127 | sym->symbollist[sym->symbolcnt++].name = strdup(symname); | ||
128 | } | ||
129 | |||
130 | /* Add a filename to the list */ | ||
131 | struct symfile * add_new_file(char * filename) | ||
132 | { | ||
133 | symfilelist[symfilecnt++].filename = strdup(filename); | ||
134 | return &symfilelist[symfilecnt - 1]; | ||
135 | } | ||
136 | /* Check if file already are present in the list */ | ||
137 | struct symfile * filename_exist(char * filename) | ||
138 | { | ||
139 | int i; | ||
140 | for (i=0; i < symfilecnt; i++) | ||
141 | if (strcmp(symfilelist[i].filename, filename) == 0) | ||
142 | return &symfilelist[i]; | ||
143 | return NULL; | ||
144 | } | ||
145 | |||
146 | /* | ||
147 | * List all files referenced within the template file. | ||
148 | * Files are separated by tabs. | ||
149 | */ | ||
150 | void adddep(char * file) { printf("\t%s", file); } | ||
151 | void adddep2(char * file, char * line) { line = line; adddep(file); } | ||
152 | void noaction(char * line) { line = line; } | ||
153 | void noaction2(char * file, char * line) { file = file; line = line; } | ||
154 | |||
155 | /* Echo the line without further action */ | ||
156 | void printline(char * line) { printf("%s", line); } | ||
157 | |||
158 | /* | ||
159 | * Find all symbols exported with EXPORT_SYMBOL and EXPORT_SYMBOL_GPL | ||
160 | * in filename. | ||
161 | * All symbols located are stored in symfilelist. | ||
162 | */ | ||
163 | void find_export_symbols(char * filename) | ||
164 | { | ||
165 | FILE * fp; | ||
166 | struct symfile *sym; | ||
167 | char line[MAXLINESZ]; | ||
168 | if (filename_exist(filename) == NULL) { | ||
169 | char real_filename[PATH_MAX + 1]; | ||
170 | memset(real_filename, 0, sizeof(real_filename)); | ||
171 | strncat(real_filename, getenv("SRCTREE"), PATH_MAX); | ||
172 | strncat(real_filename, filename, | ||
173 | PATH_MAX - strlen(real_filename)); | ||
174 | sym = add_new_file(filename); | ||
175 | fp = fopen(real_filename, "r"); | ||
176 | if (fp == NULL) | ||
177 | { | ||
178 | fprintf(stderr, "docproc: "); | ||
179 | perror(real_filename); | ||
180 | } | ||
181 | while(fgets(line, MAXLINESZ, fp)) { | ||
182 | char *p; | ||
183 | char *e; | ||
184 | if (((p = strstr(line, "EXPORT_SYMBOL_GPL")) != 0) || | ||
185 | ((p = strstr(line, "EXPORT_SYMBOL")) != 0)) { | ||
186 | /* Skip EXPORT_SYMBOL{_GPL} */ | ||
187 | while (isalnum(*p) || *p == '_') | ||
188 | p++; | ||
189 | /* Remove paranteses and additional ws */ | ||
190 | while (isspace(*p)) | ||
191 | p++; | ||
192 | if (*p != '(') | ||
193 | continue; /* Syntax error? */ | ||
194 | else | ||
195 | p++; | ||
196 | while (isspace(*p)) | ||
197 | p++; | ||
198 | e = p; | ||
199 | while (isalnum(*e) || *e == '_') | ||
200 | e++; | ||
201 | *e = '\0'; | ||
202 | add_new_symbol(sym, p); | ||
203 | } | ||
204 | } | ||
205 | fclose(fp); | ||
206 | } | ||
207 | } | ||
208 | |||
209 | /* | ||
210 | * Document all external or internal functions in a file. | ||
211 | * Call kernel-doc with following parameters: | ||
212 | * kernel-doc -docbook -nofunction function_name1 filename | ||
213 | * function names are obtained from all the the src files | ||
214 | * by find_export_symbols. | ||
215 | * intfunc uses -nofunction | ||
216 | * extfunc uses -function | ||
217 | */ | ||
218 | void docfunctions(char * filename, char * type) | ||
219 | { | ||
220 | int i,j; | ||
221 | int symcnt = 0; | ||
222 | int idx = 0; | ||
223 | char **vec; | ||
224 | |||
225 | for (i=0; i <= symfilecnt; i++) | ||
226 | symcnt += symfilelist[i].symbolcnt; | ||
227 | vec = malloc((2 + 2 * symcnt + 2) * sizeof(char*)); | ||
228 | if (vec == NULL) { | ||
229 | perror("docproc: "); | ||
230 | exit(1); | ||
231 | } | ||
232 | vec[idx++] = KERNELDOC; | ||
233 | vec[idx++] = DOCBOOK; | ||
234 | for (i=0; i < symfilecnt; i++) { | ||
235 | struct symfile * sym = &symfilelist[i]; | ||
236 | for (j=0; j < sym->symbolcnt; j++) { | ||
237 | vec[idx++] = type; | ||
238 | vec[idx++] = sym->symbollist[j].name; | ||
239 | } | ||
240 | } | ||
241 | vec[idx++] = filename; | ||
242 | vec[idx] = NULL; | ||
243 | printf("<!-- %s -->\n", filename); | ||
244 | exec_kernel_doc(vec); | ||
245 | fflush(stdout); | ||
246 | free(vec); | ||
247 | } | ||
248 | void intfunc(char * filename) { docfunctions(filename, NOFUNCTION); } | ||
249 | void extfunc(char * filename) { docfunctions(filename, FUNCTION); } | ||
250 | |||
251 | /* | ||
252 | * Document spåecific function(s) in a file. | ||
253 | * Call kernel-doc with the following parameters: | ||
254 | * kernel-doc -docbook -function function1 [-function function2] | ||
255 | */ | ||
256 | void singfunc(char * filename, char * line) | ||
257 | { | ||
258 | char *vec[200]; /* Enough for specific functions */ | ||
259 | int i, idx = 0; | ||
260 | int startofsym = 1; | ||
261 | vec[idx++] = KERNELDOC; | ||
262 | vec[idx++] = DOCBOOK; | ||
263 | |||
264 | /* Split line up in individual parameters preceeded by FUNCTION */ | ||
265 | for (i=0; line[i]; i++) { | ||
266 | if (isspace(line[i])) { | ||
267 | line[i] = '\0'; | ||
268 | startofsym = 1; | ||
269 | continue; | ||
270 | } | ||
271 | if (startofsym) { | ||
272 | startofsym = 0; | ||
273 | vec[idx++] = FUNCTION; | ||
274 | vec[idx++] = &line[i]; | ||
275 | } | ||
276 | } | ||
277 | vec[idx++] = filename; | ||
278 | vec[idx] = NULL; | ||
279 | exec_kernel_doc(vec); | ||
280 | } | ||
281 | |||
282 | /* | ||
283 | * Parse file, calling action specific functions for: | ||
284 | * 1) Lines containing !E | ||
285 | * 2) Lines containing !I | ||
286 | * 3) Lines containing !D | ||
287 | * 4) Lines containing !F | ||
288 | * 5) Default lines - lines not matching the above | ||
289 | */ | ||
290 | void parse_file(FILE *infile) | ||
291 | { | ||
292 | char line[MAXLINESZ]; | ||
293 | char * s; | ||
294 | while(fgets(line, MAXLINESZ, infile)) { | ||
295 | if (line[0] == '!') { | ||
296 | s = line + 2; | ||
297 | switch (line[1]) { | ||
298 | case 'E': | ||
299 | while (*s && !isspace(*s)) s++; | ||
300 | *s = '\0'; | ||
301 | externalfunctions(line+2); | ||
302 | break; | ||
303 | case 'I': | ||
304 | while (*s && !isspace(*s)) s++; | ||
305 | *s = '\0'; | ||
306 | internalfunctions(line+2); | ||
307 | break; | ||
308 | case 'D': | ||
309 | while (*s && !isspace(*s)) s++; | ||
310 | *s = '\0'; | ||
311 | symbolsonly(line+2); | ||
312 | break; | ||
313 | case 'F': | ||
314 | /* filename */ | ||
315 | while (*s && !isspace(*s)) s++; | ||
316 | *s++ = '\0'; | ||
317 | /* function names */ | ||
318 | while (isspace(*s)) | ||
319 | s++; | ||
320 | singlefunctions(line +2, s); | ||
321 | break; | ||
322 | default: | ||
323 | defaultline(line); | ||
324 | } | ||
325 | } | ||
326 | else { | ||
327 | defaultline(line); | ||
328 | } | ||
329 | } | ||
330 | fflush(stdout); | ||
331 | } | ||
332 | |||
333 | |||
334 | int main(int argc, char *argv[]) | ||
335 | { | ||
336 | FILE * infile; | ||
337 | if (argc != 3) { | ||
338 | usage(); | ||
339 | exit(1); | ||
340 | } | ||
341 | /* Open file, exit on error */ | ||
342 | infile = fopen(argv[2], "r"); | ||
343 | if (infile == NULL) { | ||
344 | fprintf(stderr, "docproc: "); | ||
345 | perror(argv[2]); | ||
346 | exit(2); | ||
347 | } | ||
348 | |||
349 | if (strcmp("doc", argv[1]) == 0) | ||
350 | { | ||
351 | /* Need to do this in two passes. | ||
352 | * First pass is used to collect all symbols exported | ||
353 | * in the various files. | ||
354 | * Second pass generate the documentation. | ||
355 | * This is required because function are declared | ||
356 | * and exported in different files :-(( | ||
357 | */ | ||
358 | /* Collect symbols */ | ||
359 | defaultline = noaction; | ||
360 | internalfunctions = find_export_symbols; | ||
361 | externalfunctions = find_export_symbols; | ||
362 | symbolsonly = find_export_symbols; | ||
363 | singlefunctions = noaction2; | ||
364 | parse_file(infile); | ||
365 | |||
366 | /* Rewind to start from beginning of file again */ | ||
367 | fseek(infile, 0, SEEK_SET); | ||
368 | defaultline = printline; | ||
369 | internalfunctions = intfunc; | ||
370 | externalfunctions = extfunc; | ||
371 | symbolsonly = printline; | ||
372 | singlefunctions = singfunc; | ||
373 | |||
374 | parse_file(infile); | ||
375 | } | ||
376 | else if (strcmp("depend", argv[1]) == 0) | ||
377 | { | ||
378 | /* Create first part of dependency chain | ||
379 | * file.tmpl */ | ||
380 | printf("%s\t", argv[2]); | ||
381 | defaultline = noaction; | ||
382 | internalfunctions = adddep; | ||
383 | externalfunctions = adddep; | ||
384 | symbolsonly = adddep; | ||
385 | singlefunctions = adddep2; | ||
386 | parse_file(infile); | ||
387 | printf("\n"); | ||
388 | } | ||
389 | else | ||
390 | { | ||
391 | fprintf(stderr, "Unknown option: %s\n", argv[1]); | ||
392 | exit(1); | ||
393 | } | ||
394 | fclose(infile); | ||
395 | fflush(stdout); | ||
396 | return exitstatus; | ||
397 | } | ||
398 | |||
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c new file mode 100644 index 000000000..cc2c6541b --- /dev/null +++ b/scripts/basic/fixdep.c | |||
@@ -0,0 +1,393 @@ | |||
1 | /* | ||
2 | * "Optimize" a list of dependencies as spit out by gcc -MD | ||
3 | * for the kernel build | ||
4 | * =========================================================================== | ||
5 | * | ||
6 | * Author Kai Germaschewski | ||
7 | * Copyright 2002 by Kai Germaschewski <kai.germaschewski@gmx.de> | ||
8 | * | ||
9 | * This software may be used and distributed according to the terms | ||
10 | * of the GNU General Public License, incorporated herein by reference. | ||
11 | * | ||
12 | * | ||
13 | * Introduction: | ||
14 | * | ||
15 | * gcc produces a very nice and correct list of dependencies which | ||
16 | * tells make when to remake a file. | ||
17 | * | ||
18 | * To use this list as-is however has the drawback that virtually | ||
19 | * every file in the kernel includes <linux/config.h> which then again | ||
20 | * includes <linux/autoconf.h> | ||
21 | * | ||
22 | * If the user re-runs make *config, linux/autoconf.h will be | ||
23 | * regenerated. make notices that and will rebuild every file which | ||
24 | * includes autoconf.h, i.e. basically all files. This is extremely | ||
25 | * annoying if the user just changed CONFIG_HIS_DRIVER from n to m. | ||
26 | * | ||
27 | * So we play the same trick that "mkdep" played before. We replace | ||
28 | * the dependency on linux/autoconf.h by a dependency on every config | ||
29 | * option which is mentioned in any of the listed prequisites. | ||
30 | * | ||
31 | * To be exact, split-include populates a tree in include/config/, | ||
32 | * e.g. include/config/his/driver.h, which contains the #define/#undef | ||
33 | * for the CONFIG_HIS_DRIVER option. | ||
34 | * | ||
35 | * So if the user changes his CONFIG_HIS_DRIVER option, only the objects | ||
36 | * which depend on "include/linux/config/his/driver.h" will be rebuilt, | ||
37 | * so most likely only his driver ;-) | ||
38 | * | ||
39 | * The idea above dates, by the way, back to Michael E Chastain, AFAIK. | ||
40 | * | ||
41 | * So to get dependencies right, there are two issues: | ||
42 | * o if any of the files the compiler read changed, we need to rebuild | ||
43 | * o if the command line given to the compile the file changed, we | ||
44 | * better rebuild as well. | ||
45 | * | ||
46 | * The former is handled by using the -MD output, the later by saving | ||
47 | * the command line used to compile the old object and comparing it | ||
48 | * to the one we would now use. | ||
49 | * | ||
50 | * Again, also this idea is pretty old and has been discussed on | ||
51 | * kbuild-devel a long time ago. I don't have a sensibly working | ||
52 | * internet connection right now, so I rather don't mention names | ||
53 | * without double checking. | ||
54 | * | ||
55 | * This code here has been based partially based on mkdep.c, which | ||
56 | * says the following about its history: | ||
57 | * | ||
58 | * Copyright abandoned, Michael Chastain, <mailto:mec@shout.net>. | ||
59 | * This is a C version of syncdep.pl by Werner Almesberger. | ||
60 | * | ||
61 | * | ||
62 | * It is invoked as | ||
63 | * | ||
64 | * fixdep <depfile> <target> <cmdline> | ||
65 | * | ||
66 | * and will read the dependency file <depfile> | ||
67 | * | ||
68 | * The transformed dependency snipped is written to stdout. | ||
69 | * | ||
70 | * It first generates a line | ||
71 | * | ||
72 | * cmd_<target> = <cmdline> | ||
73 | * | ||
74 | * and then basically copies the .<target>.d file to stdout, in the | ||
75 | * process filtering out the dependency on linux/autoconf.h and adding | ||
76 | * dependencies on include/config/my/option.h for every | ||
77 | * CONFIG_MY_OPTION encountered in any of the prequisites. | ||
78 | * | ||
79 | * It will also filter out all the dependencies on *.ver. We need | ||
80 | * to make sure that the generated version checksum are globally up | ||
81 | * to date before even starting the recursive build, so it's too late | ||
82 | * at this point anyway. | ||
83 | * | ||
84 | * The algorithm to grep for "CONFIG_..." is bit unusual, but should | ||
85 | * be fast ;-) We don't even try to really parse the header files, but | ||
86 | * merely grep, i.e. if CONFIG_FOO is mentioned in a comment, it will | ||
87 | * be picked up as well. It's not a problem with respect to | ||
88 | * correctness, since that can only give too many dependencies, thus | ||
89 | * we cannot miss a rebuild. Since people tend to not mention totally | ||
90 | * unrelated CONFIG_ options all over the place, it's not an | ||
91 | * efficiency problem either. | ||
92 | * | ||
93 | * (Note: it'd be easy to port over the complete mkdep state machine, | ||
94 | * but I don't think the added complexity is worth it) | ||
95 | */ | ||
96 | /* | ||
97 | * Note 2: if somebody writes HELLO_CONFIG_BOOM in a file, it will depend onto | ||
98 | * CONFIG_BOOM. This could seem a bug (not too hard to fix), but please do not | ||
99 | * fix it! Some UserModeLinux files (look at arch/um/) call CONFIG_BOOM as | ||
100 | * UML_CONFIG_BOOM, to avoid conflicts with /usr/include/linux/autoconf.h, | ||
101 | * through arch/um/include/uml-config.h; this fixdep "bug" makes sure that | ||
102 | * those files will have correct dependencies. | ||
103 | */ | ||
104 | |||
105 | #include <sys/types.h> | ||
106 | #include <sys/stat.h> | ||
107 | #include <sys/mman.h> | ||
108 | #include <unistd.h> | ||
109 | #include <fcntl.h> | ||
110 | #include <string.h> | ||
111 | #include <stdlib.h> | ||
112 | #include <stdio.h> | ||
113 | #include <limits.h> | ||
114 | #include <ctype.h> | ||
115 | #include <arpa/inet.h> | ||
116 | |||
117 | #define INT_CONF ntohl(0x434f4e46) | ||
118 | #define INT_ONFI ntohl(0x4f4e4649) | ||
119 | #define INT_NFIG ntohl(0x4e464947) | ||
120 | #define INT_FIG_ ntohl(0x4649475f) | ||
121 | |||
122 | char *target; | ||
123 | char *depfile; | ||
124 | char *cmdline; | ||
125 | |||
126 | void usage(void) | ||
127 | |||
128 | { | ||
129 | fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n"); | ||
130 | exit(1); | ||
131 | } | ||
132 | |||
133 | /* | ||
134 | * Print out the commandline prefixed with cmd_<target filename> := | ||
135 | */ | ||
136 | void print_cmdline(void) | ||
137 | { | ||
138 | printf("cmd_%s := %s\n\n", target, cmdline); | ||
139 | } | ||
140 | |||
141 | char * str_config = NULL; | ||
142 | int size_config = 0; | ||
143 | int len_config = 0; | ||
144 | |||
145 | /* | ||
146 | * Grow the configuration string to a desired length. | ||
147 | * Usually the first growth is plenty. | ||
148 | */ | ||
149 | void grow_config(int len) | ||
150 | { | ||
151 | while (len_config + len > size_config) { | ||
152 | if (size_config == 0) | ||
153 | size_config = 2048; | ||
154 | str_config = realloc(str_config, size_config *= 2); | ||
155 | if (str_config == NULL) | ||
156 | { perror("fixdep:malloc"); exit(1); } | ||
157 | } | ||
158 | } | ||
159 | |||
160 | |||
161 | |||
162 | /* | ||
163 | * Lookup a value in the configuration string. | ||
164 | */ | ||
165 | int is_defined_config(const char * name, int len) | ||
166 | { | ||
167 | const char * pconfig; | ||
168 | const char * plast = str_config + len_config - len; | ||
169 | for ( pconfig = str_config + 1; pconfig < plast; pconfig++ ) { | ||
170 | if (pconfig[ -1] == '\n' | ||
171 | && pconfig[len] == '\n' | ||
172 | && !memcmp(pconfig, name, len)) | ||
173 | return 1; | ||
174 | } | ||
175 | return 0; | ||
176 | } | ||
177 | |||
178 | /* | ||
179 | * Add a new value to the configuration string. | ||
180 | */ | ||
181 | void define_config(const char * name, int len) | ||
182 | { | ||
183 | grow_config(len + 1); | ||
184 | |||
185 | memcpy(str_config+len_config, name, len); | ||
186 | len_config += len; | ||
187 | str_config[len_config++] = '\n'; | ||
188 | } | ||
189 | |||
190 | /* | ||
191 | * Clear the set of configuration strings. | ||
192 | */ | ||
193 | void clear_config(void) | ||
194 | { | ||
195 | len_config = 0; | ||
196 | define_config("", 0); | ||
197 | } | ||
198 | |||
199 | /* | ||
200 | * Record the use of a CONFIG_* word. | ||
201 | */ | ||
202 | void use_config(char *m, int slen) | ||
203 | { | ||
204 | char s[PATH_MAX]; | ||
205 | char *p; | ||
206 | |||
207 | if (is_defined_config(m, slen)) | ||
208 | return; | ||
209 | |||
210 | define_config(m, slen); | ||
211 | |||
212 | memcpy(s, m, slen); s[slen] = 0; | ||
213 | |||
214 | for (p = s; p < s + slen; p++) { | ||
215 | if (*p == '_') | ||
216 | *p = '/'; | ||
217 | else | ||
218 | *p = tolower((int)*p); | ||
219 | } | ||
220 | printf(" $(wildcard include/config/%s.h) \\\n", s); | ||
221 | } | ||
222 | |||
223 | void parse_config_file(char *map, size_t len) | ||
224 | { | ||
225 | int *end = (int *) (map + len); | ||
226 | /* start at +1, so that p can never be < map */ | ||
227 | int *m = (int *) map + 1; | ||
228 | char *p, *q; | ||
229 | |||
230 | for (; m < end; m++) { | ||
231 | if (*m == INT_CONF) { p = (char *) m ; goto conf; } | ||
232 | if (*m == INT_ONFI) { p = (char *) m-1; goto conf; } | ||
233 | if (*m == INT_NFIG) { p = (char *) m-2; goto conf; } | ||
234 | if (*m == INT_FIG_) { p = (char *) m-3; goto conf; } | ||
235 | continue; | ||
236 | conf: | ||
237 | if (p > map + len - 7) | ||
238 | continue; | ||
239 | if (memcmp(p, "CONFIG_", 7)) | ||
240 | continue; | ||
241 | for (q = p + 7; q < map + len; q++) { | ||
242 | if (!(isalnum(*q) || *q == '_')) | ||
243 | goto found; | ||
244 | } | ||
245 | continue; | ||
246 | |||
247 | found: | ||
248 | use_config(p+7, q-p-7); | ||
249 | } | ||
250 | } | ||
251 | |||
252 | /* test is s ends in sub */ | ||
253 | int strrcmp(char *s, char *sub) | ||
254 | { | ||
255 | int slen = strlen(s); | ||
256 | int sublen = strlen(sub); | ||
257 | |||
258 | if (sublen > slen) | ||
259 | return 1; | ||
260 | |||
261 | return memcmp(s + slen - sublen, sub, sublen); | ||
262 | } | ||
263 | |||
264 | void do_config_file(char *filename) | ||
265 | { | ||
266 | struct stat st; | ||
267 | int fd; | ||
268 | void *map; | ||
269 | |||
270 | fd = open(filename, O_RDONLY); | ||
271 | if (fd < 0) { | ||
272 | fprintf(stderr, "fixdep: "); | ||
273 | perror(filename); | ||
274 | exit(2); | ||
275 | } | ||
276 | fstat(fd, &st); | ||
277 | if (st.st_size == 0) { | ||
278 | close(fd); | ||
279 | return; | ||
280 | } | ||
281 | map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); | ||
282 | if ((long) map == -1) { | ||
283 | perror("fixdep: mmap"); | ||
284 | close(fd); | ||
285 | return; | ||
286 | } | ||
287 | |||
288 | parse_config_file(map, st.st_size); | ||
289 | |||
290 | munmap(map, st.st_size); | ||
291 | |||
292 | close(fd); | ||
293 | } | ||
294 | |||
295 | void parse_dep_file(void *map, size_t len) | ||
296 | { | ||
297 | char *m = map; | ||
298 | char *end = m + len; | ||
299 | char *p; | ||
300 | char s[PATH_MAX]; | ||
301 | |||
302 | p = strchr(m, ':'); | ||
303 | if (!p) { | ||
304 | fprintf(stderr, "fixdep: parse error\n"); | ||
305 | exit(1); | ||
306 | } | ||
307 | memcpy(s, m, p-m); s[p-m] = 0; | ||
308 | printf("deps_%s := \\\n", target); | ||
309 | m = p+1; | ||
310 | |||
311 | clear_config(); | ||
312 | |||
313 | while (m < end) { | ||
314 | while (m < end && (*m == ' ' || *m == '\\' || *m == '\n')) | ||
315 | m++; | ||
316 | p = m; | ||
317 | while (p < end && *p != ' ') p++; | ||
318 | if (p == end) { | ||
319 | do p--; while (!isalnum(*p)); | ||
320 | p++; | ||
321 | } | ||
322 | memcpy(s, m, p-m); s[p-m] = 0; | ||
323 | if (strrcmp(s, "include/autoconf.h") && | ||
324 | strrcmp(s, "arch/um/include/uml-config.h") && | ||
325 | strrcmp(s, ".ver")) { | ||
326 | printf(" %s \\\n", s); | ||
327 | do_config_file(s); | ||
328 | } | ||
329 | m = p + 1; | ||
330 | } | ||
331 | printf("\n%s: $(deps_%s)\n\n", target, target); | ||
332 | printf("$(deps_%s):\n", target); | ||
333 | } | ||
334 | |||
335 | void print_deps(void) | ||
336 | { | ||
337 | struct stat st; | ||
338 | int fd; | ||
339 | void *map; | ||
340 | |||
341 | fd = open(depfile, O_RDONLY); | ||
342 | if (fd < 0) { | ||
343 | fprintf(stderr, "fixdep: "); | ||
344 | perror(depfile); | ||
345 | exit(2); | ||
346 | } | ||
347 | fstat(fd, &st); | ||
348 | if (st.st_size == 0) { | ||
349 | fprintf(stderr,"fixdep: %s is empty\n",depfile); | ||
350 | close(fd); | ||
351 | return; | ||
352 | } | ||
353 | map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); | ||
354 | if ((long) map == -1) { | ||
355 | perror("fixdep: mmap"); | ||
356 | close(fd); | ||
357 | return; | ||
358 | } | ||
359 | |||
360 | parse_dep_file(map, st.st_size); | ||
361 | |||
362 | munmap(map, st.st_size); | ||
363 | |||
364 | close(fd); | ||
365 | } | ||
366 | |||
367 | void traps(void) | ||
368 | { | ||
369 | static char test[] __attribute__((aligned(sizeof(int)))) = "CONF"; | ||
370 | |||
371 | if (*(int *)test != INT_CONF) { | ||
372 | fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n", | ||
373 | *(int *)test); | ||
374 | exit(2); | ||
375 | } | ||
376 | } | ||
377 | |||
378 | int main(int argc, char *argv[]) | ||
379 | { | ||
380 | traps(); | ||
381 | |||
382 | if (argc != 4) | ||
383 | usage(); | ||
384 | |||
385 | depfile = argv[1]; | ||
386 | target = argv[2]; | ||
387 | cmdline = argv[3]; | ||
388 | |||
389 | print_cmdline(); | ||
390 | print_deps(); | ||
391 | |||
392 | return 0; | ||
393 | } | ||
diff --git a/scripts/basic/split-include.c b/scripts/basic/split-include.c new file mode 100644 index 000000000..459c45276 --- /dev/null +++ b/scripts/basic/split-include.c | |||
@@ -0,0 +1,226 @@ | |||
1 | /* | ||
2 | * split-include.c | ||
3 | * | ||
4 | * Copyright abandoned, Michael Chastain, <mailto:mec@shout.net>. | ||
5 | * This is a C version of syncdep.pl by Werner Almesberger. | ||
6 | * | ||
7 | * This program takes autoconf.h as input and outputs a directory full | ||
8 | * of one-line include files, merging onto the old values. | ||
9 | * | ||
10 | * Think of the configuration options as key-value pairs. Then there | ||
11 | * are five cases: | ||
12 | * | ||
13 | * key old value new value action | ||
14 | * | ||
15 | * KEY-1 VALUE-1 VALUE-1 leave file alone | ||
16 | * KEY-2 VALUE-2A VALUE-2B write VALUE-2B into file | ||
17 | * KEY-3 - VALUE-3 write VALUE-3 into file | ||
18 | * KEY-4 VALUE-4 - write an empty file | ||
19 | * KEY-5 (empty) - leave old empty file alone | ||
20 | */ | ||
21 | |||
22 | #include <sys/stat.h> | ||
23 | #include <sys/types.h> | ||
24 | |||
25 | #include <ctype.h> | ||
26 | #include <errno.h> | ||
27 | #include <fcntl.h> | ||
28 | #include <stdio.h> | ||
29 | #include <stdlib.h> | ||
30 | #include <string.h> | ||
31 | #include <unistd.h> | ||
32 | |||
33 | #define ERROR_EXIT(strExit) \ | ||
34 | { \ | ||
35 | const int errnoSave = errno; \ | ||
36 | fprintf(stderr, "%s: ", str_my_name); \ | ||
37 | errno = errnoSave; \ | ||
38 | perror((strExit)); \ | ||
39 | exit(1); \ | ||
40 | } | ||
41 | |||
42 | |||
43 | |||
44 | int main(int argc, const char * argv []) | ||
45 | { | ||
46 | const char * str_my_name; | ||
47 | const char * str_file_autoconf; | ||
48 | const char * str_dir_config; | ||
49 | |||
50 | FILE * fp_config; | ||
51 | FILE * fp_target; | ||
52 | FILE * fp_find; | ||
53 | |||
54 | int buffer_size; | ||
55 | |||
56 | char * line; | ||
57 | char * old_line; | ||
58 | char * list_target; | ||
59 | char * ptarget; | ||
60 | |||
61 | struct stat stat_buf; | ||
62 | |||
63 | /* Check arg count. */ | ||
64 | if (argc != 3) | ||
65 | { | ||
66 | fprintf(stderr, "%s: wrong number of arguments.\n", argv[0]); | ||
67 | exit(1); | ||
68 | } | ||
69 | |||
70 | str_my_name = argv[0]; | ||
71 | str_file_autoconf = argv[1]; | ||
72 | str_dir_config = argv[2]; | ||
73 | |||
74 | /* Find a buffer size. */ | ||
75 | if (stat(str_file_autoconf, &stat_buf) != 0) | ||
76 | ERROR_EXIT(str_file_autoconf); | ||
77 | buffer_size = 2 * stat_buf.st_size + 4096; | ||
78 | |||
79 | /* Allocate buffers. */ | ||
80 | if ( (line = malloc(buffer_size)) == NULL | ||
81 | || (old_line = malloc(buffer_size)) == NULL | ||
82 | || (list_target = malloc(buffer_size)) == NULL ) | ||
83 | ERROR_EXIT(str_file_autoconf); | ||
84 | |||
85 | /* Open autoconfig file. */ | ||
86 | if ((fp_config = fopen(str_file_autoconf, "r")) == NULL) | ||
87 | ERROR_EXIT(str_file_autoconf); | ||
88 | |||
89 | /* Make output directory if needed. */ | ||
90 | if (stat(str_dir_config, &stat_buf) != 0) | ||
91 | { | ||
92 | if (mkdir(str_dir_config, 0755) != 0) | ||
93 | ERROR_EXIT(str_dir_config); | ||
94 | } | ||
95 | |||
96 | /* Change to output directory. */ | ||
97 | if (chdir(str_dir_config) != 0) | ||
98 | ERROR_EXIT(str_dir_config); | ||
99 | |||
100 | /* Put initial separator into target list. */ | ||
101 | ptarget = list_target; | ||
102 | *ptarget++ = '\n'; | ||
103 | |||
104 | /* Read config lines. */ | ||
105 | while (fgets(line, buffer_size, fp_config)) | ||
106 | { | ||
107 | const char * str_config; | ||
108 | int is_same; | ||
109 | int itarget; | ||
110 | |||
111 | if (line[0] != '#') | ||
112 | continue; | ||
113 | if ((str_config = strstr(line, "CONFIG_")) == NULL) | ||
114 | continue; | ||
115 | |||
116 | /* Make the output file name. */ | ||
117 | str_config += sizeof("CONFIG_") - 1; | ||
118 | for (itarget = 0; !isspace(str_config[itarget]); itarget++) | ||
119 | { | ||
120 | int c = (unsigned char) str_config[itarget]; | ||
121 | if (isupper(c)) c = tolower(c); | ||
122 | if (c == '_') c = '/'; | ||
123 | ptarget[itarget] = c; | ||
124 | } | ||
125 | ptarget[itarget++] = '.'; | ||
126 | ptarget[itarget++] = 'h'; | ||
127 | ptarget[itarget++] = '\0'; | ||
128 | |||
129 | /* Check for existing file. */ | ||
130 | is_same = 0; | ||
131 | if ((fp_target = fopen(ptarget, "r")) != NULL) | ||
132 | { | ||
133 | fgets(old_line, buffer_size, fp_target); | ||
134 | if (fclose(fp_target) != 0) | ||
135 | ERROR_EXIT(ptarget); | ||
136 | if (!strcmp(line, old_line)) | ||
137 | is_same = 1; | ||
138 | } | ||
139 | |||
140 | if (!is_same) | ||
141 | { | ||
142 | /* Auto-create directories. */ | ||
143 | int islash; | ||
144 | for (islash = 0; islash < itarget; islash++) | ||
145 | { | ||
146 | if (ptarget[islash] == '/') | ||
147 | { | ||
148 | ptarget[islash] = '\0'; | ||
149 | if (stat(ptarget, &stat_buf) != 0 | ||
150 | && mkdir(ptarget, 0755) != 0) | ||
151 | ERROR_EXIT( ptarget ); | ||
152 | ptarget[islash] = '/'; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | /* Write the file. */ | ||
157 | if ((fp_target = fopen(ptarget, "w" )) == NULL) | ||
158 | ERROR_EXIT(ptarget); | ||
159 | fputs(line, fp_target); | ||
160 | if (ferror(fp_target) || fclose(fp_target) != 0) | ||
161 | ERROR_EXIT(ptarget); | ||
162 | } | ||
163 | |||
164 | /* Update target list */ | ||
165 | ptarget += itarget; | ||
166 | *(ptarget-1) = '\n'; | ||
167 | } | ||
168 | |||
169 | /* | ||
170 | * Close autoconfig file. | ||
171 | * Terminate the target list. | ||
172 | */ | ||
173 | if (fclose(fp_config) != 0) | ||
174 | ERROR_EXIT(str_file_autoconf); | ||
175 | *ptarget = '\0'; | ||
176 | |||
177 | /* | ||
178 | * Fix up existing files which have no new value. | ||
179 | * This is Case 4 and Case 5. | ||
180 | * | ||
181 | * I re-read the tree and filter it against list_target. | ||
182 | * This is crude. But it avoids data copies. Also, list_target | ||
183 | * is compact and contiguous, so it easily fits into cache. | ||
184 | * | ||
185 | * Notice that list_target contains strings separated by \n, | ||
186 | * with a \n before the first string and after the last. | ||
187 | * fgets gives the incoming names a terminating \n. | ||
188 | * So by having an initial \n, strstr will find exact matches. | ||
189 | */ | ||
190 | |||
191 | fp_find = popen("find * -type f -name \"*.h\" -print", "r"); | ||
192 | if (fp_find == 0) | ||
193 | ERROR_EXIT( "find" ); | ||
194 | |||
195 | line[0] = '\n'; | ||
196 | while (fgets(line+1, buffer_size, fp_find)) | ||
197 | { | ||
198 | if (strstr(list_target, line) == NULL) | ||
199 | { | ||
200 | /* | ||
201 | * This is an old file with no CONFIG_* flag in autoconf.h. | ||
202 | */ | ||
203 | |||
204 | /* First strip the \n. */ | ||
205 | line[strlen(line)-1] = '\0'; | ||
206 | |||
207 | /* Grab size. */ | ||
208 | if (stat(line+1, &stat_buf) != 0) | ||
209 | ERROR_EXIT(line); | ||
210 | |||
211 | /* If file is not empty, make it empty and give it a fresh date. */ | ||
212 | if (stat_buf.st_size != 0) | ||
213 | { | ||
214 | if ((fp_target = fopen(line+1, "w")) == NULL) | ||
215 | ERROR_EXIT(line); | ||
216 | if (fclose(fp_target) != 0) | ||
217 | ERROR_EXIT(line); | ||
218 | } | ||
219 | } | ||
220 | } | ||
221 | |||
222 | if (pclose(fp_find) != 0) | ||
223 | ERROR_EXIT("find"); | ||
224 | |||
225 | return 0; | ||
226 | } | ||
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 @@ | |||
1 | Introduction | ||
2 | ------------ | ||
3 | |||
4 | The configuration database is collection of configuration options | ||
5 | organized 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 | |||
20 | Every entry has its own dependencies. These dependencies are used | ||
21 | to determine the visible of an entry. Any child entry is only | ||
22 | visible if its parent entry is also visible. | ||
23 | |||
24 | Menu entries | ||
25 | ------------ | ||
26 | |||
27 | Most entries define a config option, all other entries help to organize | ||
28 | them. A single configuration option is defined like this: | ||
29 | |||
30 | config 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 | |||
37 | Every line starts with a key word and can be followed by multiple | ||
38 | arguments. "config" starts a new config entry. The following lines | ||
39 | define attributes for this config option. Attributes can be the type of | ||
40 | the config option, input prompt, dependencies, help text and default | ||
41 | values. A config option can be defined multiple times with the same | ||
42 | name, but every definition can have only a single input prompt and the | ||
43 | type must not conflict. | ||
44 | |||
45 | Menu attributes | ||
46 | --------------- | ||
47 | |||
48 | A menu entry can have a number of attributes. Not all of them are | ||
49 | applicable 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 | |||
99 | Menu dependencies | ||
100 | ----------------- | ||
101 | |||
102 | Dependencies define the visibility of a menu entry and can also reduce | ||
103 | the input range of tristate symbols. The tristate logic used in the | ||
104 | expressions uses one more state than normal boolean logic to express the | ||
105 | module 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 | |||
115 | Expressions 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 | |||
129 | An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2 | ||
130 | respectively for calculations). A menu entry becomes visible when it's | ||
131 | expression evaluates to 'm' or 'y'. | ||
132 | |||
133 | There are two type of symbols: constant and nonconstant symbols. | ||
134 | Nonconstant symbols are the most common ones and are defined with the | ||
135 | 'config' statement. Nonconstant symbols consist entirely of alphanumeric | ||
136 | characters or underscores. | ||
137 | Constant symbols are only part of expressions. Constant symbols are | ||
138 | always surrounded by single or double quotes. Within the quote any | ||
139 | other character is allowed and the quotes can be escaped using '\'. | ||
140 | |||
141 | Menu structure | ||
142 | -------------- | ||
143 | |||
144 | The position of a menu entry in the tree is determined in two ways. First | ||
145 | it can be specified explicitely: | ||
146 | |||
147 | menu "Network device support" | ||
148 | depends NET | ||
149 | |||
150 | config NETDEVICES | ||
151 | ... | ||
152 | |||
153 | endmenu | ||
154 | |||
155 | All entries within the "menu" ... "endmenu" block become a submenu of | ||
156 | "Network device support". All subentries inherit the dependencies from | ||
157 | the menu entry, e.g. this means the dependency "NET" is added to the | ||
158 | dependency list of the config option NETDEVICES. | ||
159 | |||
160 | The other way to generate the menu structure is done by analyzing the | ||
161 | dependencies. If a menu entry somehow depends on the previous entry, it | ||
162 | can be made a submenu of it. First the the previous (parent) symbol must | ||
163 | be part of the dependency list and then one of these two condititions | ||
164 | must 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 | |||
168 | config MODULES | ||
169 | bool "Enable loadable module support" | ||
170 | |||
171 | config MODVERSIONS | ||
172 | bool "Set version information on all module symbols" | ||
173 | depends MODULES | ||
174 | |||
175 | comment "module support disabled" | ||
176 | depends !MODULES | ||
177 | |||
178 | MODVERSIONS directly depends on MODULES, this means it's only visible if | ||
179 | MODULES is different from 'n'. The comment on the other hand is always | ||
180 | visible when MODULES it's visible (the (empty) dependency of MODULES is | ||
181 | also part of the comment dependencies). | ||
182 | |||
183 | |||
184 | Kconfig syntax | ||
185 | -------------- | ||
186 | |||
187 | The configuration file describes a series of menu entries, where every | ||
188 | line starts with a keyword (except help texts). The following keywords | ||
189 | end a menu entry: | ||
190 | - config | ||
191 | - choice/endchoice | ||
192 | - comment | ||
193 | - menu/endmenu | ||
194 | - if/endif | ||
195 | - source | ||
196 | The first four also start the definition of a menu entry. | ||
197 | |||
198 | config: | ||
199 | |||
200 | "config" <symbol> | ||
201 | <config options> | ||
202 | |||
203 | This defines a config symbol <symbol> and accepts any of above | ||
204 | attributes as options. | ||
205 | |||
206 | choices: | ||
207 | |||
208 | "choice" | ||
209 | <choice options> | ||
210 | <choice block> | ||
211 | "endchoice" | ||
212 | |||
213 | This defines a choice group and accepts any of above attributes as | ||
214 | options. A choice can only be of type bool or tristate, while a boolean | ||
215 | choice only allows a single config entry to be selected, a tristate | ||
216 | choice also allows any number of config entries to be set to 'm'. This | ||
217 | can be used if multiple drivers for a single hardware exists and only a | ||
218 | single driver can be compiled/loaded into the kernel, but all drivers | ||
219 | can be compiled as modules. | ||
220 | A choice accepts another option "optional", which allows to set the | ||
221 | choice to 'n' and no entry needs to be selected. | ||
222 | |||
223 | comment: | ||
224 | |||
225 | "comment" <prompt> | ||
226 | <comment options> | ||
227 | |||
228 | This defines a comment which is displayed to the user during the | ||
229 | configuration process and is also echoed to the output files. The only | ||
230 | possible options are dependencies. | ||
231 | |||
232 | menu: | ||
233 | |||
234 | "menu" <prompt> | ||
235 | <menu options> | ||
236 | <menu block> | ||
237 | "endmenu" | ||
238 | |||
239 | This defines a menu block, see "Menu structure" above for more | ||
240 | information. The only possible options are dependencies. | ||
241 | |||
242 | if: | ||
243 | |||
244 | "if" <expr> | ||
245 | <if block> | ||
246 | "endif" | ||
247 | |||
248 | This defines an if block. The dependency expression <expr> is appended | ||
249 | to all enclosed menu entries. | ||
250 | |||
251 | source: | ||
252 | |||
253 | "source" <prompt> | ||
254 | |||
255 | This 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 | |||
5 | top_srcdir=../.. | ||
6 | top_builddir=../.. | ||
7 | srcdir=$(top_srcdir)/scripts/config | ||
8 | include $(top_srcdir)/Rules.mak | ||
9 | |||
10 | all: ncurses conf mconf | ||
11 | |||
12 | ifeq ($(shell uname),SunOS) | ||
13 | LIBS = -lcurses | ||
14 | else | ||
15 | LIBS = -lncurses | ||
16 | endif | ||
17 | ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h)) | ||
18 | HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" | ||
19 | else | ||
20 | ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h)) | ||
21 | HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>" | ||
22 | else | ||
23 | ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h)) | ||
24 | HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses.h>" | ||
25 | else | ||
26 | ifeq (/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>" | ||
28 | else | ||
29 | ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h)) | ||
30 | HOSTNCURSES += -DCURSES_LOC="<ncurses.h>" | ||
31 | else | ||
32 | HOSTNCURSES += -DCURSES_LOC="<curses.h>" | ||
33 | endif | ||
34 | endif | ||
35 | endif | ||
36 | endif | ||
37 | endif | ||
38 | |||
39 | CONF_SRC = conf.c | ||
40 | MCONF_SRC = mconf.c | ||
41 | LXD_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 | |||
45 | SHARED_SRC = zconf.tab.c | ||
46 | SHARED_DEPS := $(srcdir)/lkc.h $(srcdir)/lkc_proto.h \ | ||
47 | lkc_defs.h $(srcdir)/expr.h zconf.tab.h | ||
48 | CONF_OBJS = $(patsubst %.c,%.o, $(CONF_SRC)) | ||
49 | MCONF_OBJS = $(patsubst %.c,%.o, $(MCONF_SRC) $(LXD_SRC)) | ||
50 | SHARED_OBJS = $(patsubst %.c,%.o, $(SHARED_SRC)) | ||
51 | |||
52 | conf: $(CONF_OBJS) $(SHARED_OBJS) | ||
53 | $(SECHO) " "HOSTCC $@ ; true | ||
54 | $(Q)$(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ | ||
55 | |||
56 | mconf: $(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 | |||
67 | lkc_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 | |||
76 | ifdef LKC_GENPARSER | ||
77 | |||
78 | %.tab.c %.tab.h: $(srcdir)/%.y | ||
79 | bison -t -d -v -b $* -p $(notdir $*) $< | ||
80 | |||
81 | lex.%.c: $(srcdir)/%.l | ||
82 | flex -P$(notdir $*) -o$@ $< | ||
83 | else | ||
84 | |||
85 | lex.zconf.o: lex.zconf.c $(SHARED_DEPS) | ||
86 | $(compile.h) -I$(srcdir) | ||
87 | |||
88 | lex.zconf.c: $(srcdir)/lex.zconf.c_shipped | ||
89 | $(Q)cp $< $@ | ||
90 | |||
91 | zconf.tab.c: $(srcdir)/zconf.tab.c_shipped | ||
92 | $(Q)cp $< $@ | ||
93 | |||
94 | zconf.tab.h: $(srcdir)/zconf.tab.h_shipped | ||
95 | $(Q)cp $< $@ | ||
96 | endif | ||
97 | |||
98 | zconf.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 | |||
104 | ncurses: | ||
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 | |||
119 | clean: | ||
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/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> | ||
35 | typedef int8_t flex_int8_t; | ||
36 | typedef uint8_t flex_uint8_t; | ||
37 | typedef int16_t flex_int16_t; | ||
38 | typedef uint16_t flex_uint16_t; | ||
39 | typedef int32_t flex_int32_t; | ||
40 | typedef uint32_t flex_uint32_t; | ||
41 | #else | ||
42 | typedef signed char flex_int8_t; | ||
43 | typedef short int flex_int16_t; | ||
44 | typedef int flex_int32_t; | ||
45 | typedef unsigned char flex_uint8_t; | ||
46 | typedef unsigned short int flex_uint16_t; | ||
47 | typedef 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 | ||
139 | typedef struct yy_buffer_state *YY_BUFFER_STATE; | ||
140 | #endif | ||
141 | |||
142 | extern int zconfleng; | ||
143 | |||
144 | extern 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 | ||
175 | typedef unsigned int yy_size_t; | ||
176 | #endif | ||
177 | |||
178 | #ifndef YY_STRUCT_YY_BUFFER_STATE | ||
179 | #define YY_STRUCT_YY_BUFFER_STATE | ||
180 | struct 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. */ | ||
244 | static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ | ||
245 | static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ | ||
246 | static 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. */ | ||
264 | static char yy_hold_char; | ||
265 | static int yy_n_chars; /* number of characters read into yy_ch_buf */ | ||
266 | int zconfleng; | ||
267 | |||
268 | /* Points to current character in buffer. */ | ||
269 | static char *yy_c_buf_p = (char *) 0; | ||
270 | static int yy_init = 1; /* whether we need to initialize */ | ||
271 | static 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 | */ | ||
276 | static int yy_did_buffer_switch_on_eof; | ||
277 | |||
278 | void zconfrestart (FILE *input_file ); | ||
279 | void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ); | ||
280 | YY_BUFFER_STATE zconf_create_buffer (FILE *file,int size ); | ||
281 | void zconf_delete_buffer (YY_BUFFER_STATE b ); | ||
282 | void zconf_flush_buffer (YY_BUFFER_STATE b ); | ||
283 | void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ); | ||
284 | void zconfpop_buffer_state (void ); | ||
285 | |||
286 | static void zconfensure_buffer_stack (void ); | ||
287 | static void zconf_load_buffer_state (void ); | ||
288 | static void zconf_init_buffer (YY_BUFFER_STATE b,FILE *file ); | ||
289 | |||
290 | #define YY_FLUSH_BUFFER zconf_flush_buffer(YY_CURRENT_BUFFER ) | ||
291 | |||
292 | YY_BUFFER_STATE zconf_scan_buffer (char *base,yy_size_t size ); | ||
293 | YY_BUFFER_STATE zconf_scan_string (yyconst char *yy_str ); | ||
294 | YY_BUFFER_STATE zconf_scan_bytes (yyconst char *bytes,int len ); | ||
295 | |||
296 | void *zconfalloc (yy_size_t ); | ||
297 | void *zconfrealloc (void *,yy_size_t ); | ||
298 | void 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 | |||
329 | typedef unsigned char YY_CHAR; | ||
330 | |||
331 | FILE *zconfin = (FILE *) 0, *zconfout = (FILE *) 0; | ||
332 | |||
333 | typedef int yy_state_type; | ||
334 | |||
335 | extern int zconflineno; | ||
336 | |||
337 | int zconflineno = 1; | ||
338 | |||
339 | extern char *zconftext; | ||
340 | #define yytext_ptr zconftext | ||
341 | static 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 | |||
1906 | static yy_state_type yy_get_previous_state (void ); | ||
1907 | static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); | ||
1908 | static int yy_get_next_buffer (void ); | ||
1909 | static 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. */ | ||
1925 | struct yy_trans_info | ||
1926 | { | ||
1927 | flex_int32_t yy_verify; | ||
1928 | flex_int32_t yy_nxt; | ||
1929 | }; | ||
1930 | static 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 | |||
1957 | static 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 | |||
1989 | extern int zconf_flex_debug; | ||
1990 | int 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 | ||
1999 | char *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 | |||
2017 | char *text; | ||
2018 | static char *text_ptr; | ||
2019 | static int text_size, text_asize; | ||
2020 | |||
2021 | struct buffer { | ||
2022 | struct buffer *parent; | ||
2023 | YY_BUFFER_STATE state; | ||
2024 | }; | ||
2025 | |||
2026 | struct buffer *current_buf; | ||
2027 | |||
2028 | static int last_ts, first_ts; | ||
2029 | |||
2030 | static void zconf_endhelp(void); | ||
2031 | static struct buffer *zconf_endfile(void); | ||
2032 | |||
2033 | void 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 | |||
2042 | void 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 | |||
2056 | void 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 | ||
2085 | extern "C" int zconfwrap (void ); | ||
2086 | #else | ||
2087 | extern int zconfwrap (void ); | ||
2088 | #endif | ||
2089 | #endif | ||
2090 | |||
2091 | static void yyunput (int c,char *buf_ptr ); | ||
2092 | |||
2093 | #ifndef yytext_ptr | ||
2094 | static void yy_flex_strncpy (char *,yyconst char *,int ); | ||
2095 | #endif | ||
2096 | |||
2097 | #ifdef YY_NEED_STRLEN | ||
2098 | static int yy_flex_strlen (yyconst char * ); | ||
2099 | #endif | ||
2100 | |||
2101 | #ifndef YY_NO_INPUT | ||
2102 | |||
2103 | #ifdef __cplusplus | ||
2104 | static int yyinput (void ); | ||
2105 | #else | ||
2106 | static 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 | |||
2170 | extern 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 | */ | ||
2192 | YY_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); | ||
2240 | yy_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 | |||
2246 | yy_find_action: | ||
2247 | yy_act = yy_accept[yy_current_state]; | ||
2248 | |||
2249 | YY_DO_BEFORE_ACTION; | ||
2250 | |||
2251 | do_action: /* This label is used only to access EOF actions. */ | ||
2252 | |||
2253 | switch ( yy_act ) | ||
2254 | { /* beginning of action switch */ | ||
2255 | case 1: | ||
2256 | /* rule 1 can match eol */ | ||
2257 | YY_RULE_SETUP | ||
2258 | current_file->lineno++; | ||
2259 | YY_BREAK | ||
2260 | case 2: | ||
2261 | YY_RULE_SETUP | ||
2262 | |||
2263 | YY_BREAK | ||
2264 | case 3: | ||
2265 | /* rule 3 can match eol */ | ||
2266 | YY_RULE_SETUP | ||
2267 | current_file->lineno++; return T_EOL; | ||
2268 | YY_BREAK | ||
2269 | case 4: | ||
2270 | YY_RULE_SETUP | ||
2271 | { | ||
2272 | BEGIN(COMMAND); | ||
2273 | } | ||
2274 | YY_BREAK | ||
2275 | case 5: | ||
2276 | YY_RULE_SETUP | ||
2277 | { | ||
2278 | unput(zconftext[0]); | ||
2279 | BEGIN(COMMAND); | ||
2280 | } | ||
2281 | YY_BREAK | ||
2282 | |||
2283 | case 6: | ||
2284 | YY_RULE_SETUP | ||
2285 | BEGIN(PARAM); return T_MAINMENU; | ||
2286 | YY_BREAK | ||
2287 | case 7: | ||
2288 | YY_RULE_SETUP | ||
2289 | BEGIN(PARAM); return T_MENU; | ||
2290 | YY_BREAK | ||
2291 | case 8: | ||
2292 | YY_RULE_SETUP | ||
2293 | BEGIN(PARAM); return T_ENDMENU; | ||
2294 | YY_BREAK | ||
2295 | case 9: | ||
2296 | YY_RULE_SETUP | ||
2297 | BEGIN(PARAM); return T_SOURCE; | ||
2298 | YY_BREAK | ||
2299 | case 10: | ||
2300 | YY_RULE_SETUP | ||
2301 | BEGIN(PARAM); return T_CHOICE; | ||
2302 | YY_BREAK | ||
2303 | case 11: | ||
2304 | YY_RULE_SETUP | ||
2305 | BEGIN(PARAM); return T_ENDCHOICE; | ||
2306 | YY_BREAK | ||
2307 | case 12: | ||
2308 | YY_RULE_SETUP | ||
2309 | BEGIN(PARAM); return T_COMMENT; | ||
2310 | YY_BREAK | ||
2311 | case 13: | ||
2312 | YY_RULE_SETUP | ||
2313 | BEGIN(PARAM); return T_CONFIG; | ||
2314 | YY_BREAK | ||
2315 | case 14: | ||
2316 | YY_RULE_SETUP | ||
2317 | BEGIN(PARAM); return T_MENUCONFIG; | ||
2318 | YY_BREAK | ||
2319 | case 15: | ||
2320 | YY_RULE_SETUP | ||
2321 | BEGIN(PARAM); return T_HELP; | ||
2322 | YY_BREAK | ||
2323 | case 16: | ||
2324 | YY_RULE_SETUP | ||
2325 | BEGIN(PARAM); return T_IF; | ||
2326 | YY_BREAK | ||
2327 | case 17: | ||
2328 | YY_RULE_SETUP | ||
2329 | BEGIN(PARAM); return T_ENDIF; | ||
2330 | YY_BREAK | ||
2331 | case 18: | ||
2332 | YY_RULE_SETUP | ||
2333 | BEGIN(PARAM); return T_DEPENDS; | ||
2334 | YY_BREAK | ||
2335 | case 19: | ||
2336 | YY_RULE_SETUP | ||
2337 | BEGIN(PARAM); return T_REQUIRES; | ||
2338 | YY_BREAK | ||
2339 | case 20: | ||
2340 | YY_RULE_SETUP | ||
2341 | BEGIN(PARAM); return T_OPTIONAL; | ||
2342 | YY_BREAK | ||
2343 | case 21: | ||
2344 | YY_RULE_SETUP | ||
2345 | BEGIN(PARAM); return T_DEFAULT; | ||
2346 | YY_BREAK | ||
2347 | case 22: | ||
2348 | YY_RULE_SETUP | ||
2349 | BEGIN(PARAM); return T_PROMPT; | ||
2350 | YY_BREAK | ||
2351 | case 23: | ||
2352 | YY_RULE_SETUP | ||
2353 | BEGIN(PARAM); return T_TRISTATE; | ||
2354 | YY_BREAK | ||
2355 | case 24: | ||
2356 | YY_RULE_SETUP | ||
2357 | BEGIN(PARAM); return T_DEF_TRISTATE; | ||
2358 | YY_BREAK | ||
2359 | case 25: | ||
2360 | YY_RULE_SETUP | ||
2361 | BEGIN(PARAM); return T_BOOLEAN; | ||
2362 | YY_BREAK | ||
2363 | case 26: | ||
2364 | YY_RULE_SETUP | ||
2365 | BEGIN(PARAM); return T_BOOLEAN; | ||
2366 | YY_BREAK | ||
2367 | case 27: | ||
2368 | YY_RULE_SETUP | ||
2369 | BEGIN(PARAM); return T_DEF_BOOLEAN; | ||
2370 | YY_BREAK | ||
2371 | case 28: | ||
2372 | YY_RULE_SETUP | ||
2373 | BEGIN(PARAM); return T_DEF_BOOLEAN; | ||
2374 | YY_BREAK | ||
2375 | case 29: | ||
2376 | YY_RULE_SETUP | ||
2377 | BEGIN(PARAM); return T_INT; | ||
2378 | YY_BREAK | ||
2379 | case 30: | ||
2380 | YY_RULE_SETUP | ||
2381 | BEGIN(PARAM); return T_HEX; | ||
2382 | YY_BREAK | ||
2383 | case 31: | ||
2384 | YY_RULE_SETUP | ||
2385 | BEGIN(PARAM); return T_STRING; | ||
2386 | YY_BREAK | ||
2387 | case 32: | ||
2388 | YY_RULE_SETUP | ||
2389 | BEGIN(PARAM); return T_SELECT; | ||
2390 | YY_BREAK | ||
2391 | case 33: | ||
2392 | YY_RULE_SETUP | ||
2393 | BEGIN(PARAM); return T_SELECT; | ||
2394 | YY_BREAK | ||
2395 | case 34: | ||
2396 | YY_RULE_SETUP | ||
2397 | BEGIN(PARAM); return T_RANGE; | ||
2398 | YY_BREAK | ||
2399 | case 35: | ||
2400 | YY_RULE_SETUP | ||
2401 | { | ||
2402 | alloc_string(zconftext, zconfleng); | ||
2403 | zconflval.string = text; | ||
2404 | return T_WORD; | ||
2405 | } | ||
2406 | YY_BREAK | ||
2407 | case 36: | ||
2408 | YY_RULE_SETUP | ||
2409 | |||
2410 | YY_BREAK | ||
2411 | case 37: | ||
2412 | /* rule 37 can match eol */ | ||
2413 | YY_RULE_SETUP | ||
2414 | current_file->lineno++; BEGIN(INITIAL); | ||
2415 | YY_BREAK | ||
2416 | |||
2417 | case 38: | ||
2418 | YY_RULE_SETUP | ||
2419 | return T_AND; | ||
2420 | YY_BREAK | ||
2421 | case 39: | ||
2422 | YY_RULE_SETUP | ||
2423 | return T_OR; | ||
2424 | YY_BREAK | ||
2425 | case 40: | ||
2426 | YY_RULE_SETUP | ||
2427 | return T_OPEN_PAREN; | ||
2428 | YY_BREAK | ||
2429 | case 41: | ||
2430 | YY_RULE_SETUP | ||
2431 | return T_CLOSE_PAREN; | ||
2432 | YY_BREAK | ||
2433 | case 42: | ||
2434 | YY_RULE_SETUP | ||
2435 | return T_NOT; | ||
2436 | YY_BREAK | ||
2437 | case 43: | ||
2438 | YY_RULE_SETUP | ||
2439 | return T_EQUAL; | ||
2440 | YY_BREAK | ||
2441 | case 44: | ||
2442 | YY_RULE_SETUP | ||
2443 | return T_UNEQUAL; | ||
2444 | YY_BREAK | ||
2445 | case 45: | ||
2446 | YY_RULE_SETUP | ||
2447 | return T_IF; | ||
2448 | YY_BREAK | ||
2449 | case 46: | ||
2450 | YY_RULE_SETUP | ||
2451 | return T_ON; | ||
2452 | YY_BREAK | ||
2453 | case 47: | ||
2454 | YY_RULE_SETUP | ||
2455 | { | ||
2456 | str = zconftext[0]; | ||
2457 | new_string(); | ||
2458 | BEGIN(STRING); | ||
2459 | } | ||
2460 | YY_BREAK | ||
2461 | case 48: | ||
2462 | /* rule 48 can match eol */ | ||
2463 | YY_RULE_SETUP | ||
2464 | BEGIN(INITIAL); current_file->lineno++; return T_EOL; | ||
2465 | YY_BREAK | ||
2466 | case 49: | ||
2467 | YY_RULE_SETUP | ||
2468 | /* ignore */ | ||
2469 | YY_BREAK | ||
2470 | case 50: | ||
2471 | YY_RULE_SETUP | ||
2472 | { | ||
2473 | alloc_string(zconftext, zconfleng); | ||
2474 | zconflval.string = text; | ||
2475 | return T_WORD; | ||
2476 | } | ||
2477 | YY_BREAK | ||
2478 | case 51: | ||
2479 | YY_RULE_SETUP | ||
2480 | /* comment */ | ||
2481 | YY_BREAK | ||
2482 | case 52: | ||
2483 | /* rule 52 can match eol */ | ||
2484 | YY_RULE_SETUP | ||
2485 | current_file->lineno++; | ||
2486 | YY_BREAK | ||
2487 | case 53: | ||
2488 | YY_RULE_SETUP | ||
2489 | |||
2490 | YY_BREAK | ||
2491 | case YY_STATE_EOF(PARAM): | ||
2492 | { | ||
2493 | BEGIN(INITIAL); | ||
2494 | } | ||
2495 | YY_BREAK | ||
2496 | |||
2497 | case 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; | ||
2501 | YY_DO_BEFORE_ACTION; /* set up zconftext again */ | ||
2502 | YY_RULE_SETUP | ||
2503 | { | ||
2504 | append_string(zconftext, zconfleng); | ||
2505 | zconflval.string = text; | ||
2506 | return T_WORD_QUOTE; | ||
2507 | } | ||
2508 | YY_BREAK | ||
2509 | case 55: | ||
2510 | YY_RULE_SETUP | ||
2511 | { | ||
2512 | append_string(zconftext, zconfleng); | ||
2513 | } | ||
2514 | YY_BREAK | ||
2515 | case 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; | ||
2519 | YY_DO_BEFORE_ACTION; /* set up zconftext again */ | ||
2520 | YY_RULE_SETUP | ||
2521 | { | ||
2522 | append_string(zconftext + 1, zconfleng - 1); | ||
2523 | zconflval.string = text; | ||
2524 | return T_WORD_QUOTE; | ||
2525 | } | ||
2526 | YY_BREAK | ||
2527 | case 57: | ||
2528 | YY_RULE_SETUP | ||
2529 | { | ||
2530 | append_string(zconftext + 1, zconfleng - 1); | ||
2531 | } | ||
2532 | YY_BREAK | ||
2533 | case 58: | ||
2534 | YY_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 | ||
2544 | case 59: | ||
2545 | /* rule 59 can match eol */ | ||
2546 | YY_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 | ||
2554 | case YY_STATE_EOF(STRING): | ||
2555 | { | ||
2556 | BEGIN(INITIAL); | ||
2557 | } | ||
2558 | YY_BREAK | ||
2559 | |||
2560 | case 60: | ||
2561 | YY_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 | ||
2585 | case 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; | ||
2589 | YY_DO_BEFORE_ACTION; /* set up zconftext again */ | ||
2590 | YY_RULE_SETUP | ||
2591 | { | ||
2592 | current_file->lineno++; | ||
2593 | zconf_endhelp(); | ||
2594 | return T_HELPTEXT; | ||
2595 | } | ||
2596 | YY_BREAK | ||
2597 | case 62: | ||
2598 | /* rule 62 can match eol */ | ||
2599 | YY_RULE_SETUP | ||
2600 | { | ||
2601 | current_file->lineno++; | ||
2602 | append_string("\n", 1); | ||
2603 | } | ||
2604 | YY_BREAK | ||
2605 | case 63: | ||
2606 | YY_RULE_SETUP | ||
2607 | { | ||
2608 | append_string(zconftext, zconfleng); | ||
2609 | if (!first_ts) | ||
2610 | first_ts = last_ts; | ||
2611 | } | ||
2612 | YY_BREAK | ||
2613 | case YY_STATE_EOF(HELP): | ||
2614 | { | ||
2615 | zconf_endhelp(); | ||
2616 | return T_HELPTEXT; | ||
2617 | } | ||
2618 | YY_BREAK | ||
2619 | |||
2620 | case YY_STATE_EOF(INITIAL): | ||
2621 | case 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 | ||
2631 | case 64: | ||
2632 | YY_RULE_SETUP | ||
2633 | YY_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 | */ | ||
2772 | static 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 | |||
3092 | static 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 | */ | ||
3210 | void 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 | */ | ||
3240 | void 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 | */ | ||
3259 | static 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 | */ | ||
3304 | YY_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 | */ | ||
3341 | YY_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 | */ | ||
3354 | YY_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 | |||
3388 | static 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 | */ | ||
3416 | int zconfget_lineno (void) | ||
3417 | { | ||
3418 | |||
3419 | return zconflineno; | ||
3420 | } | ||
3421 | |||
3422 | /** Get the input stream. | ||
3423 | * | ||
3424 | */ | ||
3425 | FILE *zconfget_in (void) | ||
3426 | { | ||
3427 | return zconfin; | ||
3428 | } | ||
3429 | |||
3430 | /** Get the output stream. | ||
3431 | * | ||
3432 | */ | ||
3433 | FILE *zconfget_out (void) | ||
3434 | { | ||
3435 | return zconfout; | ||
3436 | } | ||
3437 | |||
3438 | /** Get the length of the current token. | ||
3439 | * | ||
3440 | */ | ||
3441 | int zconfget_leng (void) | ||
3442 | { | ||
3443 | return zconfleng; | ||
3444 | } | ||
3445 | |||
3446 | /** Get the current token. | ||
3447 | * | ||
3448 | */ | ||
3449 | |||
3450 | char *zconfget_text (void) | ||
3451 | { | ||
3452 | return zconftext; | ||
3453 | } | ||
3454 | |||
3455 | /** Set the current line number. | ||
3456 | * @param line_number | ||
3457 | * | ||
3458 | */ | ||
3459 | void 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 | */ | ||
3471 | void zconfset_in (FILE * in_str ) | ||
3472 | { | ||
3473 | zconfin = in_str ; | ||
3474 | } | ||
3475 | |||
3476 | void zconfset_out (FILE * out_str ) | ||
3477 | { | ||
3478 | zconfout = out_str ; | ||
3479 | } | ||
3480 | |||
3481 | int zconfget_debug (void) | ||
3482 | { | ||
3483 | return zconf_flex_debug; | ||
3484 | } | ||
3485 | |||
3486 | void zconfset_debug (int bdebug ) | ||
3487 | { | ||
3488 | zconf_flex_debug = bdebug ; | ||
3489 | } | ||
3490 | |||
3491 | /* zconflex_destroy is for both reentrant and non-reentrant scanners. */ | ||
3492 | int 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 | ||
3514 | static 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 | ||
3523 | static 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 | |||
3533 | void *zconfalloc (yy_size_t size ) | ||
3534 | { | ||
3535 | return (void *) malloc( size ); | ||
3536 | } | ||
3537 | |||
3538 | void *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 | |||
3550 | void 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 | |||
3570 | void zconf_starthelp(void) | ||
3571 | { | ||
3572 | new_string(); | ||
3573 | last_ts = first_ts = 0; | ||
3574 | BEGIN(HELP); | ||
3575 | } | ||
3576 | |||
3577 | static 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 | */ | ||
3591 | FILE *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 | |||
3607 | void 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 | |||
3623 | void 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 | |||
3653 | static 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 | |||
3673 | int zconf_lineno(void) | ||
3674 | { | ||
3675 | if (current_buf) | ||
3676 | return current_file->lineno - 1; | ||
3677 | else | ||
3678 | return 0; | ||
3679 | } | ||
3680 | |||
3681 | char *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/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 | |||
27 | static int list_width, check_x, item_x, checkflag; | ||
28 | |||
29 | /* | ||
30 | * Print list item | ||
31 | */ | ||
32 | static void | ||
33 | print_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 | */ | ||
64 | static void | ||
65 | print_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 | */ | ||
103 | static void | ||
104 | print_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 | */ | ||
120 | int | ||
121 | dialog_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/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 | |||
25 | char dialog_input_result[MAX_LEN + 1]; | ||
26 | |||
27 | /* | ||
28 | * Print the termination buttons | ||
29 | */ | ||
30 | static void | ||
31 | print_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 | */ | ||
46 | int | ||
47 | dialog_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 | |||
62 | static int menu_width, item_x; | ||
63 | |||
64 | /* | ||
65 | * Print menu item | ||
66 | */ | ||
67 | static void | ||
68 | print_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 | */ | ||
104 | static void | ||
105 | print_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 | */ | ||
149 | static void | ||
150 | print_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 | */ | ||
166 | int | ||
167 | dialog_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 | */ | ||
29 | int | ||
30 | dialog_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 | |||
25 | static void back_lines (int n); | ||
26 | static void print_page (WINDOW * win, int height, int width); | ||
27 | static void print_line (WINDOW * win, int row, int width); | ||
28 | static char *get_line (void); | ||
29 | static void print_position (WINDOW * win, int height, int width); | ||
30 | |||
31 | static int hscroll, fd, file_size, bytes_read; | ||
32 | static int begin_reached = 1, end_reached, page_length; | ||
33 | static char *buf, *page; | ||
34 | |||
35 | /* | ||
36 | * Display text from a file in a dialog box. | ||
37 | */ | ||
38 | int | ||
39 | dialog_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 | */ | ||
328 | static void | ||
329 | back_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 | */ | ||
441 | static void | ||
442 | print_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 | */ | ||
460 | static void | ||
461 | print_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 | */ | ||
490 | static char * | ||
491 | get_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 | */ | ||
541 | static void | ||
542 | print_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? */ | ||
27 | bool use_colors = 1; | ||
28 | |||
29 | const char *backtitle = NULL; | ||
30 | |||
31 | const char *dialog_result; | ||
32 | |||
33 | /* | ||
34 | * Attribute values, default is for mono display | ||
35 | */ | ||
36 | chtype 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 | */ | ||
75 | int 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 | */ | ||
112 | void | ||
113 | attr_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 | |||
126 | void 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 | */ | ||
145 | void | ||
146 | init_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 | */ | ||
164 | void | ||
165 | color_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 | */ | ||
185 | void | ||
186 | end_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 | */ | ||
198 | void | ||
199 | print_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 | */ | ||
258 | void | ||
259 | print_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 | */ | ||
286 | void | ||
287 | draw_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 | */ | ||
321 | void | ||
322 | draw_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 | */ | ||
343 | int | ||
344 | first_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 | */ | ||
365 | struct dialog_list_item * | ||
366 | first_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 | */ | ||
28 | static void | ||
29 | print_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 | */ | ||
44 | int | ||
45 | dialog_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/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" | ||
109 | typedef 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 | |||
121 | extern YYSTYPE zconflval; | ||
122 | |||
123 | |||
124 | #endif /* not BISON_ZCONF_TAB_H */ | ||
125 | |||
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile new file mode 100644 index 000000000..a28414de8 --- /dev/null +++ b/scripts/kconfig/Makefile | |||
@@ -0,0 +1,254 @@ | |||
1 | # =========================================================================== | ||
2 | # Kernel configuration targets | ||
3 | # These targets are used from top-level makefile | ||
4 | |||
5 | PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config | ||
6 | |||
7 | xconfig: $(obj)/qconf | ||
8 | $< Config.in | ||
9 | |||
10 | gconfig: $(obj)/gconf | ||
11 | $< Config.in | ||
12 | |||
13 | menuconfig: $(obj)/mconf | ||
14 | $(Q)$(MAKE) $(build)=scripts/kconfig/lxdialog | ||
15 | $< Config.in | ||
16 | |||
17 | config: $(obj)/conf | ||
18 | $< Config.in | ||
19 | |||
20 | oldconfig: $(obj)/conf | ||
21 | $< -o Config.in | ||
22 | |||
23 | silentoldconfig: $(obj)/conf | ||
24 | $< -s Config.in | ||
25 | |||
26 | update-po-config: $(obj)/kxgettext | ||
27 | xgettext --default-domain=linux \ | ||
28 | --add-comments --keyword=_ --keyword=N_ \ | ||
29 | --files-from=scripts/kconfig/POTFILES.in \ | ||
30 | --output scripts/kconfig/config.pot | ||
31 | $(Q)ln -fs Kconfig_i386 arch/um/Kconfig_arch | ||
32 | $(Q)for i in `ls arch/`; \ | ||
33 | do \ | ||
34 | scripts/kconfig/kxgettext arch/$$i/Kconfig \ | ||
35 | | msguniq -o scripts/kconfig/linux_$${i}.pot; \ | ||
36 | done | ||
37 | $(Q)msgcat scripts/kconfig/config.pot \ | ||
38 | `find scripts/kconfig/ -type f -name linux_*.pot` \ | ||
39 | --output scripts/kconfig/linux_raw.pot | ||
40 | $(Q)msguniq --sort-by-file scripts/kconfig/linux_raw.pot \ | ||
41 | --output scripts/kconfig/linux.pot | ||
42 | $(Q)rm -f arch/um/Kconfig_arch | ||
43 | $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot | ||
44 | |||
45 | PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig | ||
46 | |||
47 | randconfig: $(obj)/conf | ||
48 | $< -r Config.in | ||
49 | |||
50 | allyesconfig: $(obj)/conf | ||
51 | $< -y Config.in | ||
52 | |||
53 | allnoconfig: $(obj)/conf | ||
54 | $< -n Config.in | ||
55 | |||
56 | allmodconfig: $(obj)/conf | ||
57 | $< -m Config.in | ||
58 | |||
59 | defconfig: $(obj)/conf | ||
60 | ifeq ($(KBUILD_DEFCONFIG),) | ||
61 | $< -d Config.in | ||
62 | else | ||
63 | @echo *** Default configuration is based on '$(KBUILD_DEFCONFIG)' | ||
64 | $(Q)$< -D $(KBUILD_DEFCONFIG) Config.in | ||
65 | endif | ||
66 | |||
67 | %_defconfig: $(obj)/conf | ||
68 | $(Q)$< -D $@ Config.in | ||
69 | |||
70 | # Help text used by make help | ||
71 | help: | ||
72 | @echo ' config - Update current config utilising a line-oriented program' | ||
73 | @echo ' menuconfig - Update current config utilising a menu based program' | ||
74 | @echo ' xconfig - Update current config utilising a QT based front-end' | ||
75 | @echo ' gconfig - Update current config utilising a GTK based front-end' | ||
76 | @echo ' oldconfig - Update current config utilising a provided .config as base' | ||
77 | @echo ' randconfig - New config with random answer to all options' | ||
78 | @echo ' defconfig - New config with default answer to all options' | ||
79 | @echo ' allmodconfig - New config selecting modules when possible' | ||
80 | @echo ' allyesconfig - New config where all options are accepted with yes' | ||
81 | @echo ' allnoconfig - New config where all options are answered with no' | ||
82 | |||
83 | # =========================================================================== | ||
84 | # Shared Makefile for the various kconfig executables: | ||
85 | # conf: Used for defconfig, oldconfig and related targets | ||
86 | # mconf: Used for the mconfig target. | ||
87 | # Utilizes the lxdialog package | ||
88 | # qconf: Used for the xconfig target | ||
89 | # Based on QT which needs to be installed to compile it | ||
90 | # gconf: Used for the gconfig target | ||
91 | # Based on GTK which needs to be installed to compile it | ||
92 | # object files used by all kconfig flavours | ||
93 | |||
94 | hostprogs-y := conf mconf qconf gconf kxgettext | ||
95 | conf-objs := conf.o zconf.tab.o | ||
96 | mconf-objs := mconf.o zconf.tab.o | ||
97 | kxgettext-objs := kxgettext.o zconf.tab.o | ||
98 | |||
99 | ifeq ($(MAKECMDGOALS),xconfig) | ||
100 | qconf-target := 1 | ||
101 | endif | ||
102 | ifeq ($(MAKECMDGOALS),gconfig) | ||
103 | gconf-target := 1 | ||
104 | endif | ||
105 | |||
106 | |||
107 | ifeq ($(qconf-target),1) | ||
108 | qconf-cxxobjs := qconf.o | ||
109 | qconf-objs := kconfig_load.o zconf.tab.o | ||
110 | endif | ||
111 | |||
112 | ifeq ($(gconf-target),1) | ||
113 | gconf-objs := gconf.o kconfig_load.o zconf.tab.o | ||
114 | endif | ||
115 | |||
116 | clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \ | ||
117 | .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c | ||
118 | subdir- += lxdialog | ||
119 | |||
120 | # Needed for systems without gettext | ||
121 | KBUILD_HAVE_NLS := $(shell \ | ||
122 | if echo "\#include <libintl.h>" | $(HOSTCC) $(HOSTCFLAGS) -E - > /dev/null 2>&1 ; \ | ||
123 | then echo yes ; \ | ||
124 | else echo no ; fi) | ||
125 | ifeq ($(KBUILD_HAVE_NLS),no) | ||
126 | HOSTCFLAGS += -DKBUILD_NO_NLS | ||
127 | endif | ||
128 | |||
129 | # generated files seem to need this to find local include files | ||
130 | HOSTCFLAGS_lex.zconf.o := -I$(src) | ||
131 | HOSTCFLAGS_zconf.tab.o := -I$(src) | ||
132 | |||
133 | HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl | ||
134 | HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK | ||
135 | |||
136 | HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` | ||
137 | HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ | ||
138 | -D LKC_DIRECT_LINK | ||
139 | |||
140 | $(obj)/qconf.o: $(obj)/.tmp_qtcheck | ||
141 | |||
142 | ifeq ($(qconf-target),1) | ||
143 | $(obj)/.tmp_qtcheck: $(src)/Makefile | ||
144 | -include $(obj)/.tmp_qtcheck | ||
145 | |||
146 | # QT needs some extra effort... | ||
147 | $(obj)/.tmp_qtcheck: | ||
148 | @set -e; echo " CHECK qt"; dir=""; pkg=""; \ | ||
149 | pkg-config --exists qt 2> /dev/null && pkg=qt; \ | ||
150 | pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \ | ||
151 | if [ -n "$$pkg" ]; then \ | ||
152 | cflags="\$$(shell pkg-config $$pkg --cflags)"; \ | ||
153 | libs="\$$(shell pkg-config $$pkg --libs)"; \ | ||
154 | moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \ | ||
155 | dir="$$(pkg-config $$pkg --variable=prefix)"; \ | ||
156 | else \ | ||
157 | for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \ | ||
158 | if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \ | ||
159 | done; \ | ||
160 | if [ -z "$$dir" ]; then \ | ||
161 | echo "*"; \ | ||
162 | echo "* Unable to find the QT installation. Please make sure that"; \ | ||
163 | echo "* the QT development package is correctly installed and"; \ | ||
164 | echo "* either install pkg-config or set the QTDIR environment"; \ | ||
165 | echo "* variable to the correct location."; \ | ||
166 | echo "*"; \ | ||
167 | false; \ | ||
168 | fi; \ | ||
169 | libpath=$$dir/lib; lib=qt; osdir=""; \ | ||
170 | $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \ | ||
171 | osdir=x$$($(HOSTCXX) -print-multi-os-directory); \ | ||
172 | test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \ | ||
173 | test -f $$libpath/libqt-mt.so && lib=qt-mt; \ | ||
174 | cflags="-I$$dir/include"; \ | ||
175 | libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \ | ||
176 | moc="$$dir/bin/moc"; \ | ||
177 | fi; \ | ||
178 | if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \ | ||
179 | echo "*"; \ | ||
180 | echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \ | ||
181 | echo "*"; \ | ||
182 | moc="/usr/bin/moc"; \ | ||
183 | fi; \ | ||
184 | echo "KC_QT_CFLAGS=$$cflags" > $@; \ | ||
185 | echo "KC_QT_LIBS=$$libs" >> $@; \ | ||
186 | echo "KC_QT_MOC=$$moc" >> $@ | ||
187 | endif | ||
188 | |||
189 | $(obj)/gconf.o: $(obj)/.tmp_gtkcheck | ||
190 | |||
191 | ifeq ($(gconf-target),1) | ||
192 | -include $(obj)/.tmp_gtkcheck | ||
193 | |||
194 | # GTK needs some extra effort, too... | ||
195 | $(obj)/.tmp_gtkcheck: | ||
196 | @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \ | ||
197 | if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \ | ||
198 | touch $@; \ | ||
199 | else \ | ||
200 | echo "*"; \ | ||
201 | echo "* GTK+ is present but version >= 2.0.0 is required."; \ | ||
202 | echo "*"; \ | ||
203 | false; \ | ||
204 | fi \ | ||
205 | else \ | ||
206 | echo "*"; \ | ||
207 | echo "* Unable to find the GTK+ installation. Please make sure that"; \ | ||
208 | echo "* the GTK+ 2.0 development package is correctly installed..."; \ | ||
209 | echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \ | ||
210 | echo "*"; \ | ||
211 | false; \ | ||
212 | fi | ||
213 | endif | ||
214 | |||
215 | $(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c | ||
216 | |||
217 | $(obj)/kconfig_load.o: $(obj)/lkc_defs.h | ||
218 | |||
219 | $(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h | ||
220 | |||
221 | $(obj)/gconf.o: $(obj)/lkc_defs.h | ||
222 | |||
223 | $(obj)/%.moc: $(src)/%.h | ||
224 | $(KC_QT_MOC) -i $< -o $@ | ||
225 | |||
226 | $(obj)/lkc_defs.h: $(src)/lkc_proto.h | ||
227 | sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/' | ||
228 | |||
229 | |||
230 | ### | ||
231 | # The following requires flex/bison/gperf | ||
232 | # By default we use the _shipped versions, uncomment the following line if | ||
233 | # you are modifying the flex/bison src. | ||
234 | # LKC_GENPARSER := 1 | ||
235 | |||
236 | ifdef LKC_GENPARSER | ||
237 | |||
238 | $(obj)/zconf.tab.c: $(src)/zconf.y | ||
239 | $(obj)/lex.zconf.c: $(src)/zconf.l | ||
240 | $(obj)/zconf.hash.c: $(src)/zconf.gperf | ||
241 | |||
242 | %.tab.c: %.y | ||
243 | bison -l -b $* -p $(notdir $*) $< | ||
244 | cp $@ $@_shipped | ||
245 | |||
246 | lex.%.c: %.l | ||
247 | flex -L -P$(notdir $*) -o$@ $< | ||
248 | cp $@ $@_shipped | ||
249 | |||
250 | %.hash.c: %.gperf | ||
251 | gperf < $< > $@ | ||
252 | cp $@ $@_shipped | ||
253 | |||
254 | endif | ||
diff --git a/scripts/kconfig/POTFILES.in b/scripts/kconfig/POTFILES.in new file mode 100644 index 000000000..cc94e46a7 --- /dev/null +++ b/scripts/kconfig/POTFILES.in | |||
@@ -0,0 +1,5 @@ | |||
1 | scripts/kconfig/mconf.c | ||
2 | scripts/kconfig/conf.c | ||
3 | scripts/kconfig/confdata.c | ||
4 | scripts/kconfig/gconf.c | ||
5 | scripts/kconfig/qconf.cc | ||
diff --git a/scripts/config/conf.c b/scripts/kconfig/conf.c index 2da5ff7a7..8012d1076 100644 --- a/scripts/config/conf.c +++ b/scripts/kconfig/conf.c | |||
@@ -1,4 +1,3 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | 1 | /* |
3 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
4 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
@@ -6,6 +5,7 @@ | |||
6 | 5 | ||
7 | #include <ctype.h> | 6 | #include <ctype.h> |
8 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <stdio.h> | ||
9 | #include <string.h> | 9 | #include <string.h> |
10 | #include <unistd.h> | 10 | #include <unistd.h> |
11 | #include <time.h> | 11 | #include <time.h> |
@@ -35,7 +35,7 @@ static int conf_cnt; | |||
35 | static char line[128]; | 35 | static char line[128]; |
36 | static struct menu *rootEntry; | 36 | static struct menu *rootEntry; |
37 | 37 | ||
38 | static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; | 38 | static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n"); |
39 | 39 | ||
40 | static void strip(char *str) | 40 | static void strip(char *str) |
41 | { | 41 | { |
@@ -57,9 +57,9 @@ static void strip(char *str) | |||
57 | static void check_stdin(void) | 57 | static void check_stdin(void) |
58 | { | 58 | { |
59 | if (!valid_stdin && input_mode == ask_silent) { | 59 | if (!valid_stdin && input_mode == ask_silent) { |
60 | printf("aborted!\n\n"); | 60 | printf(_("aborted!\n\n")); |
61 | printf("Console input/output is redirected. "); | 61 | printf(_("Console input/output is redirected. ")); |
62 | printf("Run 'make oldconfig' to update configuration.\n\n"); | 62 | printf(_("Run 'make oldconfig' to update configuration.\n\n")); |
63 | exit(1); | 63 | exit(1); |
64 | } | 64 | } |
65 | } | 65 | } |
@@ -83,6 +83,15 @@ static void conf_askvalue(struct symbol *sym, const char *def) | |||
83 | } | 83 | } |
84 | 84 | ||
85 | switch (input_mode) { | 85 | switch (input_mode) { |
86 | case set_no: | ||
87 | case set_mod: | ||
88 | case set_yes: | ||
89 | case set_random: | ||
90 | if (sym_has_value(sym)) { | ||
91 | printf("%s\n", def); | ||
92 | return; | ||
93 | } | ||
94 | break; | ||
86 | case ask_new: | 95 | case ask_new: |
87 | case ask_silent: | 96 | case ask_silent: |
88 | if (sym_has_value(sym)) { | 97 | if (sym_has_value(sym)) { |
@@ -306,8 +315,7 @@ static int conf_choice(struct menu *menu) | |||
306 | printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); | 315 | printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); |
307 | def_sym = sym_get_choice_value(sym); | 316 | def_sym = sym_get_choice_value(sym); |
308 | cnt = def = 0; | 317 | cnt = def = 0; |
309 | line[0] = '0'; | 318 | line[0] = 0; |
310 | line[1] = 0; | ||
311 | for (child = menu->list; child; child = child->next) { | 319 | for (child = menu->list; child; child = child->next) { |
312 | if (!menu_is_visible(child)) | 320 | if (!menu_is_visible(child)) |
313 | continue; | 321 | continue; |
@@ -468,15 +476,14 @@ static void check_conf(struct menu *menu) | |||
468 | return; | 476 | return; |
469 | 477 | ||
470 | sym = menu->sym; | 478 | sym = menu->sym; |
471 | if (sym) { | 479 | if (sym && !sym_has_value(sym)) { |
472 | if (sym_is_changable(sym) && !sym_has_value(sym)) { | 480 | if (sym_is_changable(sym) || |
481 | (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { | ||
473 | if (!conf_cnt++) | 482 | if (!conf_cnt++) |
474 | printf("*\n* Restart config...\n*\n"); | 483 | printf(_("*\n* Restart config...\n*\n")); |
475 | rootEntry = menu_get_parent_menu(menu); | 484 | rootEntry = menu_get_parent_menu(menu); |
476 | conf(rootEntry); | 485 | conf(rootEntry); |
477 | } | 486 | } |
478 | if (sym_is_choice(sym) && sym_get_tristate_value(sym) != mod) | ||
479 | return; | ||
480 | } | 487 | } |
481 | 488 | ||
482 | for (child = menu->list; child; child = child->next) | 489 | for (child = menu->list; child; child = child->next) |
@@ -505,7 +512,7 @@ int main(int ac, char **av) | |||
505 | input_mode = set_default; | 512 | input_mode = set_default; |
506 | defconfig_file = av[i++]; | 513 | defconfig_file = av[i++]; |
507 | if (!defconfig_file) { | 514 | if (!defconfig_file) { |
508 | printf("%s: No default config file specified\n", | 515 | printf(_("%s: No default config file specified\n"), |
509 | av[0]); | 516 | av[0]); |
510 | exit(1); | 517 | exit(1); |
511 | } | 518 | } |
@@ -525,13 +532,13 @@ int main(int ac, char **av) | |||
525 | break; | 532 | break; |
526 | case 'h': | 533 | case 'h': |
527 | case '?': | 534 | case '?': |
528 | printf("%s [-o|-s] config\n", av[0]); | 535 | fprintf(stderr, "See README for usage info\n"); |
529 | exit(0); | 536 | exit(0); |
530 | } | 537 | } |
531 | } | 538 | } |
532 | name = av[i]; | 539 | name = av[i]; |
533 | if (!name) { | 540 | if (!name) { |
534 | printf("%s: configuration file missing\n", av[0]); | 541 | printf(_("%s: Kconfig file missing\n"), av[0]); |
535 | } | 542 | } |
536 | conf_parse(name); | 543 | conf_parse(name); |
537 | //zconfdump(stdout); | 544 | //zconfdump(stdout); |
@@ -548,18 +555,39 @@ int main(int ac, char **av) | |||
548 | break; | 555 | break; |
549 | case ask_silent: | 556 | case ask_silent: |
550 | if (stat(".config", &tmpstat)) { | 557 | if (stat(".config", &tmpstat)) { |
551 | printf("***\n" | 558 | printf(_("***\n" |
552 | "*** You have not yet configured BusyBox!\n" | 559 | "*** You have not yet configured your kernel!\n" |
553 | "***\n" | 560 | "***\n" |
554 | "*** Please run some configurator (e.g. \"make oldconfig\" or\n" | 561 | "*** Please run some configurator (e.g. \"make oldconfig\" or\n" |
555 | "*** \"make menuconfig\" or \"make config\").\n" | 562 | "*** \"make menuconfig\" or \"make xconfig\").\n" |
556 | "***\n"); | 563 | "***\n")); |
557 | exit(1); | 564 | exit(1); |
558 | } | 565 | } |
559 | case ask_all: | 566 | case ask_all: |
560 | case ask_new: | 567 | case ask_new: |
561 | conf_read(NULL); | 568 | conf_read(NULL); |
562 | break; | 569 | break; |
570 | case set_no: | ||
571 | case set_mod: | ||
572 | case set_yes: | ||
573 | case set_random: | ||
574 | name = getenv("KCONFIG_ALLCONFIG"); | ||
575 | if (name && !stat(name, &tmpstat)) { | ||
576 | conf_read_simple(name); | ||
577 | break; | ||
578 | } | ||
579 | switch (input_mode) { | ||
580 | case set_no: name = "allno.config"; break; | ||
581 | case set_mod: name = "allmod.config"; break; | ||
582 | case set_yes: name = "allyes.config"; break; | ||
583 | case set_random: name = "allrandom.config"; break; | ||
584 | default: break; | ||
585 | } | ||
586 | if (!stat(name, &tmpstat)) | ||
587 | conf_read_simple(name); | ||
588 | else if (!stat("all.config", &tmpstat)) | ||
589 | conf_read_simple("all.config"); | ||
590 | break; | ||
563 | default: | 591 | default: |
564 | break; | 592 | break; |
565 | } | 593 | } |
@@ -577,7 +605,7 @@ int main(int ac, char **av) | |||
577 | check_conf(&rootmenu); | 605 | check_conf(&rootmenu); |
578 | } while (conf_cnt); | 606 | } while (conf_cnt); |
579 | if (conf_write(NULL)) { | 607 | if (conf_write(NULL)) { |
580 | fprintf(stderr, "\n*** Error during writing of the BusyBox configuration.\n\n"); | 608 | fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); |
581 | return 1; | 609 | return 1; |
582 | } | 610 | } |
583 | return 0; | 611 | return 0; |
diff --git a/scripts/config/confdata.c b/scripts/kconfig/confdata.c index db3fdcd56..301774f0c 100644 --- a/scripts/config/confdata.c +++ b/scripts/kconfig/confdata.c | |||
@@ -1,4 +1,3 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | 1 | /* |
3 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
4 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
@@ -9,21 +8,42 @@ | |||
9 | #include <stdio.h> | 8 | #include <stdio.h> |
10 | #include <stdlib.h> | 9 | #include <stdlib.h> |
11 | #include <string.h> | 10 | #include <string.h> |
11 | #include <time.h> | ||
12 | #include <unistd.h> | 12 | #include <unistd.h> |
13 | 13 | ||
14 | #define LKC_DIRECT_LINK | 14 | #define LKC_DIRECT_LINK |
15 | #include "lkc.h" | 15 | #include "lkc.h" |
16 | 16 | ||
17 | static void conf_warning(const char *fmt, ...) | ||
18 | __attribute__ ((format (printf, 1, 2))); | ||
19 | |||
20 | static const char *conf_filename; | ||
21 | static int conf_lineno, conf_warnings, conf_unsaved; | ||
22 | |||
17 | const char conf_def_filename[] = ".config"; | 23 | const char conf_def_filename[] = ".config"; |
18 | 24 | ||
19 | const char conf_defname[] = "defconfig"; | 25 | const char conf_defname[] = "arch/$ARCH/defconfig"; |
20 | 26 | ||
21 | const char *conf_confnames[] = { | 27 | const char *conf_confnames[] = { |
22 | ".config", | 28 | ".config", |
29 | "/lib/modules/$UNAME_RELEASE/.config", | ||
30 | "/etc/kernel-config", | ||
31 | "/boot/config-$UNAME_RELEASE", | ||
23 | conf_defname, | 32 | conf_defname, |
24 | NULL, | 33 | NULL, |
25 | }; | 34 | }; |
26 | 35 | ||
36 | static void conf_warning(const char *fmt, ...) | ||
37 | { | ||
38 | va_list ap; | ||
39 | va_start(ap, fmt); | ||
40 | fprintf(stderr, "%s:%d:warning: ", conf_filename, conf_lineno); | ||
41 | vfprintf(stderr, fmt, ap); | ||
42 | fprintf(stderr, "\n"); | ||
43 | va_end(ap); | ||
44 | conf_warnings++; | ||
45 | } | ||
46 | |||
27 | static char *conf_expand_value(const char *in) | 47 | static char *conf_expand_value(const char *in) |
28 | { | 48 | { |
29 | struct symbol *sym; | 49 | struct symbol *sym; |
@@ -66,15 +86,12 @@ char *conf_get_default_confname(void) | |||
66 | return name; | 86 | return name; |
67 | } | 87 | } |
68 | 88 | ||
69 | int conf_read(const char *name) | 89 | int conf_read_simple(const char *name) |
70 | { | 90 | { |
71 | FILE *in = NULL; | 91 | FILE *in = NULL; |
72 | char line[1024]; | 92 | char line[1024]; |
73 | char *p, *p2; | 93 | char *p, *p2; |
74 | int lineno = 0; | ||
75 | struct symbol *sym; | 94 | struct symbol *sym; |
76 | struct property *prop; | ||
77 | struct expr *e; | ||
78 | int i; | 95 | int i; |
79 | 96 | ||
80 | if (name) { | 97 | if (name) { |
@@ -85,25 +102,32 @@ int conf_read(const char *name) | |||
85 | name = conf_expand_value(name); | 102 | name = conf_expand_value(name); |
86 | in = zconf_fopen(name); | 103 | in = zconf_fopen(name); |
87 | if (in) { | 104 | if (in) { |
88 | printf("#\n" | 105 | printf(_("#\n" |
89 | "# using defaults found in %s\n" | 106 | "# using defaults found in %s\n" |
90 | "#\n", name); | 107 | "#\n"), name); |
91 | break; | 108 | break; |
92 | } | 109 | } |
93 | } | 110 | } |
94 | } | 111 | } |
95 | |||
96 | if (!in) | 112 | if (!in) |
97 | return 1; | 113 | return 1; |
98 | 114 | ||
115 | conf_filename = name; | ||
116 | conf_lineno = 0; | ||
117 | conf_warnings = 0; | ||
118 | conf_unsaved = 0; | ||
119 | |||
99 | for_all_symbols(i, sym) { | 120 | for_all_symbols(i, sym) { |
100 | sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED; | 121 | sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED; |
122 | if (sym_is_choice(sym)) | ||
123 | sym->flags &= ~SYMBOL_NEW; | ||
101 | sym->flags &= ~SYMBOL_VALID; | 124 | sym->flags &= ~SYMBOL_VALID; |
102 | switch (sym->type) { | 125 | switch (sym->type) { |
103 | case S_INT: | 126 | case S_INT: |
104 | case S_HEX: | 127 | case S_HEX: |
105 | case S_STRING: | 128 | case S_STRING: |
106 | free(sym->user.val); | 129 | if (sym->user.val) |
130 | free(sym->user.val); | ||
107 | default: | 131 | default: |
108 | sym->user.val = NULL; | 132 | sym->user.val = NULL; |
109 | sym->user.tri = no; | 133 | sym->user.tri = no; |
@@ -111,21 +135,24 @@ int conf_read(const char *name) | |||
111 | } | 135 | } |
112 | 136 | ||
113 | while (fgets(line, sizeof(line), in)) { | 137 | while (fgets(line, sizeof(line), in)) { |
114 | lineno++; | 138 | conf_lineno++; |
115 | sym = NULL; | 139 | sym = NULL; |
116 | switch (line[0]) { | 140 | switch (line[0]) { |
117 | case '#': | 141 | case '#': |
118 | if (line[1]!=' ') | 142 | if (memcmp(line + 2, "CONFIG_", 7)) |
119 | continue; | 143 | continue; |
120 | p = strchr(line + 2, ' '); | 144 | p = strchr(line + 9, ' '); |
121 | if (!p) | 145 | if (!p) |
122 | continue; | 146 | continue; |
123 | *p++ = 0; | 147 | *p++ = 0; |
124 | if (strncmp(p, "is not set", 10)) | 148 | if (strncmp(p, "is not set", 10)) |
125 | continue; | 149 | continue; |
126 | sym = sym_find(line + 2); | 150 | sym = sym_find(line + 9); |
127 | if (!sym) { | 151 | if (!sym) { |
128 | fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 2); | 152 | conf_warning("trying to assign nonexistent symbol %s", line + 9); |
153 | break; | ||
154 | } else if (!(sym->flags & SYMBOL_NEW)) { | ||
155 | conf_warning("trying to reassign symbol %s", sym->name); | ||
129 | break; | 156 | break; |
130 | } | 157 | } |
131 | switch (sym->type) { | 158 | switch (sym->type) { |
@@ -138,18 +165,24 @@ int conf_read(const char *name) | |||
138 | ; | 165 | ; |
139 | } | 166 | } |
140 | break; | 167 | break; |
141 | 168 | case 'C': | |
142 | case 'A' ... 'Z': | 169 | if (memcmp(line, "CONFIG_", 7)) { |
143 | p = strchr(line, '='); | 170 | conf_warning("unexpected data"); |
171 | continue; | ||
172 | } | ||
173 | p = strchr(line + 7, '='); | ||
144 | if (!p) | 174 | if (!p) |
145 | continue; | 175 | continue; |
146 | *p++ = 0; | 176 | *p++ = 0; |
147 | p2 = strchr(p, '\n'); | 177 | p2 = strchr(p, '\n'); |
148 | if (p2) | 178 | if (p2) |
149 | *p2 = 0; | 179 | *p2 = 0; |
150 | sym = sym_find(line); | 180 | sym = sym_find(line + 7); |
151 | if (!sym) { | 181 | if (!sym) { |
152 | fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line); | 182 | conf_warning("trying to assign nonexistent symbol %s", line + 7); |
183 | break; | ||
184 | } else if (!(sym->flags & SYMBOL_NEW)) { | ||
185 | conf_warning("trying to reassign symbol %s", sym->name); | ||
153 | break; | 186 | break; |
154 | } | 187 | } |
155 | switch (sym->type) { | 188 | switch (sym->type) { |
@@ -170,6 +203,7 @@ int conf_read(const char *name) | |||
170 | sym->flags &= ~SYMBOL_NEW; | 203 | sym->flags &= ~SYMBOL_NEW; |
171 | break; | 204 | break; |
172 | } | 205 | } |
206 | conf_warning("symbol value '%s' invalid for %s", p, sym->name); | ||
173 | break; | 207 | break; |
174 | case S_STRING: | 208 | case S_STRING: |
175 | if (*p++ != '"') | 209 | if (*p++ != '"') |
@@ -182,8 +216,8 @@ int conf_read(const char *name) | |||
182 | memmove(p2, p2 + 1, strlen(p2)); | 216 | memmove(p2, p2 + 1, strlen(p2)); |
183 | } | 217 | } |
184 | if (!p2) { | 218 | if (!p2) { |
185 | fprintf(stderr, "%s:%d: invalid string found\n", name, lineno); | 219 | conf_warning("invalid string found"); |
186 | exit(1); | 220 | continue; |
187 | } | 221 | } |
188 | case S_INT: | 222 | case S_INT: |
189 | case S_HEX: | 223 | case S_HEX: |
@@ -191,8 +225,8 @@ int conf_read(const char *name) | |||
191 | sym->user.val = strdup(p); | 225 | sym->user.val = strdup(p); |
192 | sym->flags &= ~SYMBOL_NEW; | 226 | sym->flags &= ~SYMBOL_NEW; |
193 | } else { | 227 | } else { |
194 | fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); | 228 | conf_warning("symbol value '%s' invalid for %s", p, sym->name); |
195 | exit(1); | 229 | continue; |
196 | } | 230 | } |
197 | break; | 231 | break; |
198 | default: | 232 | default: |
@@ -202,6 +236,7 @@ int conf_read(const char *name) | |||
202 | case '\n': | 236 | case '\n': |
203 | break; | 237 | break; |
204 | default: | 238 | default: |
239 | conf_warning("unexpected data"); | ||
205 | continue; | 240 | continue; |
206 | } | 241 | } |
207 | if (sym && sym_is_choice_value(sym)) { | 242 | if (sym && sym_is_choice_value(sym)) { |
@@ -210,25 +245,63 @@ int conf_read(const char *name) | |||
210 | case no: | 245 | case no: |
211 | break; | 246 | break; |
212 | case mod: | 247 | case mod: |
213 | if (cs->user.tri == yes) | 248 | if (cs->user.tri == yes) { |
214 | /* warn? */; | 249 | conf_warning("%s creates inconsistent choice state", sym->name); |
250 | cs->flags |= SYMBOL_NEW; | ||
251 | } | ||
215 | break; | 252 | break; |
216 | case yes: | 253 | case yes: |
217 | if (cs->user.tri != no) | 254 | if (cs->user.tri != no) { |
218 | /* warn? */; | 255 | conf_warning("%s creates inconsistent choice state", sym->name); |
219 | cs->user.val = sym; | 256 | cs->flags |= SYMBOL_NEW; |
257 | } else | ||
258 | cs->user.val = sym; | ||
220 | break; | 259 | break; |
221 | } | 260 | } |
222 | cs->user.tri = E_OR(cs->user.tri, sym->user.tri); | 261 | cs->user.tri = E_OR(cs->user.tri, sym->user.tri); |
223 | cs->flags &= ~SYMBOL_NEW; | ||
224 | } | 262 | } |
225 | } | 263 | } |
226 | fclose(in); | 264 | fclose(in); |
227 | 265 | ||
228 | if (modules_sym) | 266 | if (modules_sym) |
229 | sym_calc_value(modules_sym); | 267 | sym_calc_value(modules_sym); |
268 | return 0; | ||
269 | } | ||
270 | |||
271 | int conf_read(const char *name) | ||
272 | { | ||
273 | struct symbol *sym; | ||
274 | struct property *prop; | ||
275 | struct expr *e; | ||
276 | int i; | ||
277 | |||
278 | if (conf_read_simple(name)) | ||
279 | return 1; | ||
280 | |||
230 | for_all_symbols(i, sym) { | 281 | for_all_symbols(i, sym) { |
231 | sym_calc_value(sym); | 282 | sym_calc_value(sym); |
283 | if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO)) | ||
284 | goto sym_ok; | ||
285 | if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) { | ||
286 | /* check that calculated value agrees with saved value */ | ||
287 | switch (sym->type) { | ||
288 | case S_BOOLEAN: | ||
289 | case S_TRISTATE: | ||
290 | if (sym->user.tri != sym_get_tristate_value(sym)) | ||
291 | break; | ||
292 | if (!sym_is_choice(sym)) | ||
293 | goto sym_ok; | ||
294 | default: | ||
295 | if (!strcmp(sym->curr.val, sym->user.val)) | ||
296 | goto sym_ok; | ||
297 | break; | ||
298 | } | ||
299 | } else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE)) | ||
300 | /* no previous value and not saved */ | ||
301 | goto sym_ok; | ||
302 | conf_unsaved++; | ||
303 | /* maybe print value in verbose mode... */ | ||
304 | sym_ok: | ||
232 | if (sym_has_value(sym) && !sym_is_choice_value(sym)) { | 305 | if (sym_has_value(sym) && !sym_is_choice_value(sym)) { |
233 | if (sym->visible == no) | 306 | if (sym->visible == no) |
234 | sym->flags |= SYMBOL_NEW; | 307 | sym->flags |= SYMBOL_NEW; |
@@ -236,8 +309,10 @@ int conf_read(const char *name) | |||
236 | case S_STRING: | 309 | case S_STRING: |
237 | case S_INT: | 310 | case S_INT: |
238 | case S_HEX: | 311 | case S_HEX: |
239 | if (!sym_string_within_range(sym, sym->user.val)) | 312 | if (!sym_string_within_range(sym, sym->user.val)) { |
240 | sym->flags |= SYMBOL_NEW; | 313 | sym->flags |= SYMBOL_NEW; |
314 | sym->flags &= ~SYMBOL_VALID; | ||
315 | } | ||
241 | default: | 316 | default: |
242 | break; | 317 | break; |
243 | } | 318 | } |
@@ -250,26 +325,11 @@ int conf_read(const char *name) | |||
250 | sym->flags |= e->right.sym->flags & SYMBOL_NEW; | 325 | sym->flags |= e->right.sym->flags & SYMBOL_NEW; |
251 | } | 326 | } |
252 | 327 | ||
253 | sym_change_count = 1; | 328 | sym_change_count = conf_warnings || conf_unsaved; |
254 | 329 | ||
255 | return 0; | 330 | return 0; |
256 | } | 331 | } |
257 | 332 | ||
258 | struct 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 | |||
273 | int conf_write(const char *name) | 333 | int conf_write(const char *name) |
274 | { | 334 | { |
275 | FILE *out, *out_h; | 335 | FILE *out, *out_h; |
@@ -279,10 +339,9 @@ int conf_write(const char *name) | |||
279 | char dirname[128], tmpname[128], newname[128]; | 339 | char dirname[128], tmpname[128], newname[128]; |
280 | int type, l; | 340 | int type, l; |
281 | const char *str; | 341 | const char *str; |
282 | 342 | time_t now; | |
283 | /* busybox`s code */ | 343 | int use_timestamp = 1; |
284 | const char *opt_name; | 344 | char *env; |
285 | int use_flg; | ||
286 | 345 | ||
287 | dirname[0] = 0; | 346 | dirname[0] = 0; |
288 | if (name && name[0]) { | 347 | if (name && name[0]) { |
@@ -315,38 +374,42 @@ int conf_write(const char *name) | |||
315 | out_h = fopen(".tmpconfig.h", "w"); | 374 | out_h = fopen(".tmpconfig.h", "w"); |
316 | if (!out_h) | 375 | if (!out_h) |
317 | return 1; | 376 | return 1; |
377 | file_write_dep(NULL); | ||
318 | } | 378 | } |
319 | fprintf(out, "#\n" | 379 | sym = sym_lookup("KERNELVERSION", 0); |
320 | "# Automatically generated make config: don't edit\n" | 380 | sym_calc_value(sym); |
321 | "#\n"); | 381 | time(&now); |
322 | 382 | env = getenv("KCONFIG_NOTIMESTAMP"); | |
323 | /* busybox`s code */ | 383 | if (env && *env) |
384 | use_timestamp = 0; | ||
385 | |||
386 | fprintf(out, _("#\n" | ||
387 | "# Automatically generated make config: don't edit\n" | ||
388 | "# Linux kernel version: %s\n" | ||
389 | "%s%s" | ||
390 | "#\n"), | ||
391 | sym_get_string_value(sym), | ||
392 | use_timestamp ? "# " : "", | ||
393 | use_timestamp ? ctime(&now) : ""); | ||
324 | if (out_h) { | 394 | if (out_h) { |
325 | fprintf(out_h, "#ifndef BB_CONFIG_H\n#define BB_CONFIG_H\n"); | 395 | char buf[sizeof("#define AUTOCONF_TIMESTAMP " |
396 | "\"YYYY-MM-DD HH:MM:SS some_timezone\"\n")]; | ||
397 | buf[0] = '\0'; | ||
398 | if (use_timestamp) | ||
399 | strftime(buf, sizeof(buf), "#define AUTOCONF_TIMESTAMP " | ||
400 | "\"%Y-%m-%d %H:%M:%S %Z\"\n", localtime(&now)); | ||
326 | fprintf(out_h, "/*\n" | 401 | fprintf(out_h, "/*\n" |
327 | " * Automatically generated header file: don't edit\n" | 402 | " * Automatically generated C config: don't edit\n" |
328 | " */\n\n" | 403 | " * Linux kernel version: %s\n" |
329 | "/* Version Number */\n" | 404 | " */\n" |
330 | "#define BB_VER \"%s\"\n" | 405 | "%s" |
331 | "#define BB_BT \"%s\"\n", | 406 | "#define AUTOCONF_INCLUDED\n", |
332 | getenv("VERSION"), | 407 | sym_get_string_value(sym), |
333 | getenv("BUILDTIME")); | 408 | buf); |
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 | } | 409 | } |
339 | /* end busybox`s code */ | ||
340 | |||
341 | if (!sym_change_count) | 410 | if (!sym_change_count) |
342 | sym_clear_all_valid(); | 411 | sym_clear_all_valid(); |
343 | 412 | ||
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; | 413 | menu = rootmenu.list; |
351 | while (menu) { | 414 | while (menu) { |
352 | sym = menu->sym; | 415 | sym = menu->sym; |
@@ -365,56 +428,52 @@ int conf_write(const char *name) | |||
365 | " */\n", str); | 428 | " */\n", str); |
366 | } else if (!(sym->flags & SYMBOL_CHOICE)) { | 429 | } else if (!(sym->flags & SYMBOL_CHOICE)) { |
367 | sym_calc_value(sym); | 430 | sym_calc_value(sym); |
368 | if (!(sym->flags & SYMBOL_FORCEWRITE)) | 431 | if (!(sym->flags & SYMBOL_WRITE)) |
369 | goto next; | 432 | goto next; |
370 | 433 | sym->flags &= ~SYMBOL_WRITE; | |
371 | sym->flags &= ~SYMBOL_FORCEWRITE; | ||
372 | type = sym->type; | 434 | type = sym->type; |
373 | if (type == S_TRISTATE) { | 435 | if (type == S_TRISTATE) { |
374 | sym_calc_value(modules_sym); | 436 | sym_calc_value(modules_sym); |
375 | if (modules_sym->curr.tri == no) | 437 | if (modules_sym->curr.tri == no) |
376 | type = S_BOOLEAN; | 438 | type = S_BOOLEAN; |
377 | } | 439 | } |
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) { | 440 | switch (type) { |
389 | case S_BOOLEAN: | 441 | case S_BOOLEAN: |
390 | case S_TRISTATE: | 442 | case S_TRISTATE: |
391 | switch (sym_get_tristate_value(sym)) { | 443 | switch (sym_get_tristate_value(sym)) { |
392 | case no: | 444 | case no: |
393 | fprintf(out, "# %s is not set\n", sym->name); | 445 | fprintf(out, "# CONFIG_%s is not set\n", sym->name); |
394 | if (out_h) | 446 | if (out_h) { |
395 | fprintf(out_h, "#undef %s\n", sym->name); | 447 | fprintf(out_h, "#undef CONFIG_%s\n", sym->name); |
396 | use_flg = 0; /* busybox`s code */ | 448 | /* bbox */ |
449 | fprintf(out_h, "#define ENABLE_%s 0\n", sym->name); | ||
450 | fprintf(out_h, "#define USE_%s(...)\n", sym->name); | ||
451 | fprintf(out_h, "#define SKIP_%s(...) __VA_ARGS__\n", sym->name); | ||
452 | } | ||
397 | break; | 453 | break; |
398 | case mod: | 454 | case mod: |
399 | #if 0 /* busybox`s code */ | 455 | fprintf(out, "CONFIG_%s=m\n", sym->name); |
400 | fprintf(out, "%s=m\n", sym->name); | ||
401 | if (out_h) | 456 | if (out_h) |
402 | fprintf(out_h, "#define %s_MODULE 1\n", sym->name); | 457 | fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); |
403 | #endif /* busybox`s code */ | ||
404 | break; | 458 | break; |
405 | case yes: | 459 | case yes: |
406 | fprintf(out, "%s=y\n", sym->name); | 460 | fprintf(out, "CONFIG_%s=y\n", sym->name); |
407 | if (out_h) | 461 | if (out_h) { |
408 | fprintf(out_h, "#define %s 1\n", sym->name); | 462 | fprintf(out_h, "#define CONFIG_%s 1\n", sym->name); |
463 | /* bbox */ | ||
464 | fprintf(out_h, "#define ENABLE_%s 1\n", sym->name); | ||
465 | fprintf(out_h, "#define USE_%s(...) __VA_ARGS__\n", sym->name); | ||
466 | fprintf(out_h, "#define SKIP_%s(...)\n", sym->name); | ||
467 | } | ||
409 | break; | 468 | break; |
410 | } | 469 | } |
411 | break; | 470 | break; |
412 | case S_STRING: | 471 | case S_STRING: |
413 | // fix me | 472 | // fix me |
414 | str = sym_get_string_value(sym); | 473 | str = sym_get_string_value(sym); |
415 | fprintf(out, "%s=\"", sym->name); | 474 | fprintf(out, "CONFIG_%s=\"", sym->name); |
416 | if (out_h) | 475 | if (out_h) |
417 | fprintf(out_h, "#define %s \"", sym->name); | 476 | fprintf(out_h, "#define CONFIG_%s \"", sym->name); |
418 | do { | 477 | do { |
419 | l = strcspn(str, "\"\\"); | 478 | l = strcspn(str, "\"\\"); |
420 | if (l) { | 479 | if (l) { |
@@ -431,43 +490,59 @@ int conf_write(const char *name) | |||
431 | } | 490 | } |
432 | } while (*str); | 491 | } while (*str); |
433 | fputs("\"\n", out); | 492 | fputs("\"\n", out); |
434 | if (out_h) | 493 | if (out_h) { |
435 | fputs("\"\n", out_h); | 494 | fputs("\"\n", out_h); |
495 | /* bbox */ | ||
496 | fprintf(out_h, "#define ENABLE_%s 1\n", sym->name); | ||
497 | fprintf(out_h, "#define USE_%s(...) __VA_ARGS__\n", sym->name); | ||
498 | fprintf(out_h, "#define SKIP_%s(...)\n", sym->name); | ||
499 | } | ||
436 | break; | 500 | break; |
437 | case S_HEX: | 501 | case S_HEX: |
438 | str = sym_get_string_value(sym); | 502 | str = sym_get_string_value(sym); |
439 | if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { | 503 | if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { |
440 | fprintf(out, "%s=%s\n", sym->name, *str ? str : "0"); | 504 | fprintf(out, "CONFIG_%s=%s\n", sym->name, str); |
441 | if (out_h) | 505 | if (out_h) { |
442 | fprintf(out_h, "#define %s 0x%s\n", sym->name, str); | 506 | fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str); |
507 | /* bbox */ | ||
508 | fprintf(out_h, "#define ENABLE_%s 1\n", sym->name); | ||
509 | fprintf(out_h, "#define USE_%s(...) __VA_ARGS__\n", sym->name); | ||
510 | fprintf(out_h, "#define SKIP_%s(...)\n", sym->name); | ||
511 | } | ||
443 | break; | 512 | break; |
444 | } | 513 | } |
445 | case S_INT: | 514 | case S_INT: |
446 | str = sym_get_string_value(sym); | 515 | str = sym_get_string_value(sym); |
447 | fprintf(out, "%s=%s\n", sym->name, *str ? str : "0"); | 516 | fprintf(out, "CONFIG_%s=%s\n", sym->name, str); |
448 | if (out_h) | 517 | if (out_h) { |
449 | fprintf(out_h, "#define %s %s\n", sym->name, str); | 518 | fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str); |
519 | /* bbox */ | ||
520 | fprintf(out_h, "#define ENABLE_%s 1\n", sym->name); | ||
521 | fprintf(out_h, "#define USE_%s(...) __VA_ARGS__\n", sym->name); | ||
522 | fprintf(out_h, "#define SKIP_%s(...)\n", sym->name); | ||
523 | } | ||
450 | break; | 524 | break; |
451 | } | 525 | } |
452 | /* busybox`s code */ | 526 | } |
453 | if (out_h) { | 527 | |
454 | fprintf(out_h, "#define ENABLE_%s %d\n", opt_name, use_flg); | 528 | next: |
455 | fprintf(out_h, "#define USE_%s(...)%s\n", opt_name, | 529 | if (menu->list) { |
456 | (use_flg ? " __VA_ARGS__" : "")); | 530 | menu = menu->list; |
457 | fprintf(out_h, "#define SKIP_%s(...)%s\n\n", opt_name, | 531 | continue; |
458 | (use_flg ? "" : " __VA_ARGS__")); | 532 | } |
533 | if (menu->next) | ||
534 | menu = menu->next; | ||
535 | else while ((menu = menu->parent)) { | ||
536 | if (menu->next) { | ||
537 | menu = menu->next; | ||
538 | break; | ||
459 | } | 539 | } |
460 | /* end busybox`s code */ | ||
461 | } | 540 | } |
462 | next: | ||
463 | menu = next_menu(menu); | ||
464 | } | 541 | } |
465 | fclose(out); | 542 | fclose(out); |
466 | if (out_h) { | 543 | if (out_h) { |
467 | fprintf(out_h, "#endif /* BB_CONFIG_H */\n"); /* busybox`s code */ | ||
468 | fclose(out_h); | 544 | fclose(out_h); |
469 | rename(".tmpconfig.h", "include/bb_config.h"); /* busybox`s config name */ | 545 | rename(".tmpconfig.h", "include/autoconf.h"); |
470 | file_write_dep(NULL); | ||
471 | } | 546 | } |
472 | if (!name || basename != conf_def_filename) { | 547 | if (!name || basename != conf_def_filename) { |
473 | if (!name) | 548 | if (!name) |
diff --git a/scripts/config/expr.c b/scripts/kconfig/expr.c index 125573e77..30e4f9d69 100644 --- a/scripts/config/expr.c +++ b/scripts/kconfig/expr.c | |||
@@ -1,4 +1,3 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | 1 | /* |
3 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
4 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
@@ -825,7 +824,7 @@ bool expr_depends_symbol(struct expr *dep, struct symbol *sym) | |||
825 | default: | 824 | default: |
826 | ; | 825 | ; |
827 | } | 826 | } |
828 | return false; | 827 | return false; |
829 | } | 828 | } |
830 | 829 | ||
831 | struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2) | 830 | struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2) |
diff --git a/scripts/config/expr.h b/scripts/kconfig/expr.h index de7332f64..1b36ef18c 100644 --- a/scripts/config/expr.h +++ b/scripts/kconfig/expr.h | |||
@@ -1,4 +1,3 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | 1 | /* |
3 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
4 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
@@ -94,7 +93,6 @@ struct symbol { | |||
94 | #define SYMBOL_NEW 0x0800 | 93 | #define SYMBOL_NEW 0x0800 |
95 | #define SYMBOL_AUTO 0x1000 | 94 | #define SYMBOL_AUTO 0x1000 |
96 | #define SYMBOL_CHECKED 0x2000 | 95 | #define SYMBOL_CHECKED 0x2000 |
97 | #define SYMBOL_CHECK_DONE 0x4000 | ||
98 | #define SYMBOL_WARNED 0x8000 | 96 | #define SYMBOL_WARNED 0x8000 |
99 | 97 | ||
100 | #define SYMBOL_MAXLENGTH 256 | 98 | #define SYMBOL_MAXLENGTH 256 |
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c new file mode 100644 index 000000000..665bd5300 --- /dev/null +++ b/scripts/kconfig/gconf.c | |||
@@ -0,0 +1,1645 @@ | |||
1 | /* Hey EMACS -*- linux-c -*- */ | ||
2 | /* | ||
3 | * | ||
4 | * Copyright (C) 2002-2003 Romain Lievin <roms@tilp.info> | ||
5 | * Released under the terms of the GNU GPL v2.0. | ||
6 | * | ||
7 | */ | ||
8 | |||
9 | #ifdef HAVE_CONFIG_H | ||
10 | # include <config.h> | ||
11 | #endif | ||
12 | |||
13 | #include "lkc.h" | ||
14 | #include "images.c" | ||
15 | |||
16 | #include <glade/glade.h> | ||
17 | #include <gtk/gtk.h> | ||
18 | #include <glib.h> | ||
19 | #include <gdk/gdkkeysyms.h> | ||
20 | |||
21 | #include <stdio.h> | ||
22 | #include <string.h> | ||
23 | #include <unistd.h> | ||
24 | #include <time.h> | ||
25 | #include <stdlib.h> | ||
26 | |||
27 | //#define DEBUG | ||
28 | |||
29 | enum { | ||
30 | SINGLE_VIEW, SPLIT_VIEW, FULL_VIEW | ||
31 | }; | ||
32 | |||
33 | static gint view_mode = FULL_VIEW; | ||
34 | static gboolean show_name = TRUE; | ||
35 | static gboolean show_range = TRUE; | ||
36 | static gboolean show_value = TRUE; | ||
37 | static gboolean show_all = FALSE; | ||
38 | static gboolean show_debug = FALSE; | ||
39 | static gboolean resizeable = FALSE; | ||
40 | |||
41 | static gboolean config_changed = FALSE; | ||
42 | |||
43 | static char nohelp_text[] = | ||
44 | N_("Sorry, no help available for this option yet.\n"); | ||
45 | |||
46 | GtkWidget *main_wnd = NULL; | ||
47 | GtkWidget *tree1_w = NULL; // left frame | ||
48 | GtkWidget *tree2_w = NULL; // right frame | ||
49 | GtkWidget *text_w = NULL; | ||
50 | GtkWidget *hpaned = NULL; | ||
51 | GtkWidget *vpaned = NULL; | ||
52 | GtkWidget *back_btn = NULL; | ||
53 | |||
54 | GtkTextTag *tag1, *tag2; | ||
55 | GdkColor color; | ||
56 | |||
57 | GtkTreeStore *tree1, *tree2, *tree; | ||
58 | GtkTreeModel *model1, *model2; | ||
59 | static GtkTreeIter *parents[256]; | ||
60 | static gint indent; | ||
61 | |||
62 | static struct menu *current; // current node for SINGLE view | ||
63 | static struct menu *browsed; // browsed node for SPLIT view | ||
64 | |||
65 | enum { | ||
66 | COL_OPTION, COL_NAME, COL_NO, COL_MOD, COL_YES, COL_VALUE, | ||
67 | COL_MENU, COL_COLOR, COL_EDIT, COL_PIXBUF, | ||
68 | COL_PIXVIS, COL_BTNVIS, COL_BTNACT, COL_BTNINC, COL_BTNRAD, | ||
69 | COL_NUMBER | ||
70 | }; | ||
71 | |||
72 | static void display_list(void); | ||
73 | static void display_tree(struct menu *menu); | ||
74 | static void display_tree_part(void); | ||
75 | static void update_tree(struct menu *src, GtkTreeIter * dst); | ||
76 | static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row); | ||
77 | static gchar **fill_row(struct menu *menu); | ||
78 | |||
79 | |||
80 | /* Helping/Debugging Functions */ | ||
81 | |||
82 | |||
83 | const char *dbg_print_stype(int val) | ||
84 | { | ||
85 | static char buf[256]; | ||
86 | |||
87 | bzero(buf, 256); | ||
88 | |||
89 | if (val == S_UNKNOWN) | ||
90 | strcpy(buf, "unknown"); | ||
91 | if (val == S_BOOLEAN) | ||
92 | strcpy(buf, "boolean"); | ||
93 | if (val == S_TRISTATE) | ||
94 | strcpy(buf, "tristate"); | ||
95 | if (val == S_INT) | ||
96 | strcpy(buf, "int"); | ||
97 | if (val == S_HEX) | ||
98 | strcpy(buf, "hex"); | ||
99 | if (val == S_STRING) | ||
100 | strcpy(buf, "string"); | ||
101 | if (val == S_OTHER) | ||
102 | strcpy(buf, "other"); | ||
103 | |||
104 | #ifdef DEBUG | ||
105 | printf("%s", buf); | ||
106 | #endif | ||
107 | |||
108 | return buf; | ||
109 | } | ||
110 | |||
111 | const char *dbg_print_flags(int val) | ||
112 | { | ||
113 | static char buf[256]; | ||
114 | |||
115 | bzero(buf, 256); | ||
116 | |||
117 | if (val & SYMBOL_YES) | ||
118 | strcat(buf, "yes/"); | ||
119 | if (val & SYMBOL_MOD) | ||
120 | strcat(buf, "mod/"); | ||
121 | if (val & SYMBOL_NO) | ||
122 | strcat(buf, "no/"); | ||
123 | if (val & SYMBOL_CONST) | ||
124 | strcat(buf, "const/"); | ||
125 | if (val & SYMBOL_CHECK) | ||
126 | strcat(buf, "check/"); | ||
127 | if (val & SYMBOL_CHOICE) | ||
128 | strcat(buf, "choice/"); | ||
129 | if (val & SYMBOL_CHOICEVAL) | ||
130 | strcat(buf, "choiceval/"); | ||
131 | if (val & SYMBOL_PRINTED) | ||
132 | strcat(buf, "printed/"); | ||
133 | if (val & SYMBOL_VALID) | ||
134 | strcat(buf, "valid/"); | ||
135 | if (val & SYMBOL_OPTIONAL) | ||
136 | strcat(buf, "optional/"); | ||
137 | if (val & SYMBOL_WRITE) | ||
138 | strcat(buf, "write/"); | ||
139 | if (val & SYMBOL_CHANGED) | ||
140 | strcat(buf, "changed/"); | ||
141 | if (val & SYMBOL_NEW) | ||
142 | strcat(buf, "new/"); | ||
143 | if (val & SYMBOL_AUTO) | ||
144 | strcat(buf, "auto/"); | ||
145 | |||
146 | buf[strlen(buf) - 1] = '\0'; | ||
147 | #ifdef DEBUG | ||
148 | printf("%s", buf); | ||
149 | #endif | ||
150 | |||
151 | return buf; | ||
152 | } | ||
153 | |||
154 | const char *dbg_print_ptype(int val) | ||
155 | { | ||
156 | static char buf[256]; | ||
157 | |||
158 | bzero(buf, 256); | ||
159 | |||
160 | if (val == P_UNKNOWN) | ||
161 | strcpy(buf, "unknown"); | ||
162 | if (val == P_PROMPT) | ||
163 | strcpy(buf, "prompt"); | ||
164 | if (val == P_COMMENT) | ||
165 | strcpy(buf, "comment"); | ||
166 | if (val == P_MENU) | ||
167 | strcpy(buf, "menu"); | ||
168 | if (val == P_DEFAULT) | ||
169 | strcpy(buf, "default"); | ||
170 | if (val == P_CHOICE) | ||
171 | strcpy(buf, "choice"); | ||
172 | |||
173 | #ifdef DEBUG | ||
174 | printf("%s", buf); | ||
175 | #endif | ||
176 | |||
177 | return buf; | ||
178 | } | ||
179 | |||
180 | |||
181 | void replace_button_icon(GladeXML * xml, GdkDrawable * window, | ||
182 | GtkStyle * style, gchar * btn_name, gchar ** xpm) | ||
183 | { | ||
184 | GdkPixmap *pixmap; | ||
185 | GdkBitmap *mask; | ||
186 | GtkToolButton *button; | ||
187 | GtkWidget *image; | ||
188 | |||
189 | pixmap = gdk_pixmap_create_from_xpm_d(window, &mask, | ||
190 | &style->bg[GTK_STATE_NORMAL], | ||
191 | xpm); | ||
192 | |||
193 | button = GTK_TOOL_BUTTON(glade_xml_get_widget(xml, btn_name)); | ||
194 | image = gtk_image_new_from_pixmap(pixmap, mask); | ||
195 | gtk_widget_show(image); | ||
196 | gtk_tool_button_set_icon_widget(button, image); | ||
197 | } | ||
198 | |||
199 | /* Main Window Initialization */ | ||
200 | void init_main_window(const gchar * glade_file) | ||
201 | { | ||
202 | GladeXML *xml; | ||
203 | GtkWidget *widget; | ||
204 | GtkTextBuffer *txtbuf; | ||
205 | char title[256]; | ||
206 | GtkStyle *style; | ||
207 | |||
208 | xml = glade_xml_new(glade_file, "window1", NULL); | ||
209 | if (!xml) | ||
210 | g_error(_("GUI loading failed !\n")); | ||
211 | glade_xml_signal_autoconnect(xml); | ||
212 | |||
213 | main_wnd = glade_xml_get_widget(xml, "window1"); | ||
214 | hpaned = glade_xml_get_widget(xml, "hpaned1"); | ||
215 | vpaned = glade_xml_get_widget(xml, "vpaned1"); | ||
216 | tree1_w = glade_xml_get_widget(xml, "treeview1"); | ||
217 | tree2_w = glade_xml_get_widget(xml, "treeview2"); | ||
218 | text_w = glade_xml_get_widget(xml, "textview3"); | ||
219 | |||
220 | back_btn = glade_xml_get_widget(xml, "button1"); | ||
221 | gtk_widget_set_sensitive(back_btn, FALSE); | ||
222 | |||
223 | widget = glade_xml_get_widget(xml, "show_name1"); | ||
224 | gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget, | ||
225 | show_name); | ||
226 | |||
227 | widget = glade_xml_get_widget(xml, "show_range1"); | ||
228 | gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget, | ||
229 | show_range); | ||
230 | |||
231 | widget = glade_xml_get_widget(xml, "show_data1"); | ||
232 | gtk_check_menu_item_set_active((GtkCheckMenuItem *) widget, | ||
233 | show_value); | ||
234 | |||
235 | style = gtk_widget_get_style(main_wnd); | ||
236 | widget = glade_xml_get_widget(xml, "toolbar1"); | ||
237 | |||
238 | #if 0 /* Use stock Gtk icons instead */ | ||
239 | replace_button_icon(xml, main_wnd->window, style, | ||
240 | "button1", (gchar **) xpm_back); | ||
241 | replace_button_icon(xml, main_wnd->window, style, | ||
242 | "button2", (gchar **) xpm_load); | ||
243 | replace_button_icon(xml, main_wnd->window, style, | ||
244 | "button3", (gchar **) xpm_save); | ||
245 | #endif | ||
246 | replace_button_icon(xml, main_wnd->window, style, | ||
247 | "button4", (gchar **) xpm_single_view); | ||
248 | replace_button_icon(xml, main_wnd->window, style, | ||
249 | "button5", (gchar **) xpm_split_view); | ||
250 | replace_button_icon(xml, main_wnd->window, style, | ||
251 | "button6", (gchar **) xpm_tree_view); | ||
252 | |||
253 | #if 0 | ||
254 | switch (view_mode) { | ||
255 | case SINGLE_VIEW: | ||
256 | widget = glade_xml_get_widget(xml, "button4"); | ||
257 | g_signal_emit_by_name(widget, "clicked"); | ||
258 | break; | ||
259 | case SPLIT_VIEW: | ||
260 | widget = glade_xml_get_widget(xml, "button5"); | ||
261 | g_signal_emit_by_name(widget, "clicked"); | ||
262 | break; | ||
263 | case FULL_VIEW: | ||
264 | widget = glade_xml_get_widget(xml, "button6"); | ||
265 | g_signal_emit_by_name(widget, "clicked"); | ||
266 | break; | ||
267 | } | ||
268 | #endif | ||
269 | txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w)); | ||
270 | tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1", | ||
271 | "foreground", "red", | ||
272 | "weight", PANGO_WEIGHT_BOLD, | ||
273 | NULL); | ||
274 | tag2 = gtk_text_buffer_create_tag(txtbuf, "mytag2", | ||
275 | /*"style", PANGO_STYLE_OBLIQUE, */ | ||
276 | NULL); | ||
277 | |||
278 | sprintf(title, _("Linux Kernel v%s Configuration"), | ||
279 | getenv("KERNELVERSION")); | ||
280 | gtk_window_set_title(GTK_WINDOW(main_wnd), title); | ||
281 | |||
282 | gtk_widget_show(main_wnd); | ||
283 | } | ||
284 | |||
285 | void init_tree_model(void) | ||
286 | { | ||
287 | gint i; | ||
288 | |||
289 | tree = tree2 = gtk_tree_store_new(COL_NUMBER, | ||
290 | G_TYPE_STRING, G_TYPE_STRING, | ||
291 | G_TYPE_STRING, G_TYPE_STRING, | ||
292 | G_TYPE_STRING, G_TYPE_STRING, | ||
293 | G_TYPE_POINTER, GDK_TYPE_COLOR, | ||
294 | G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, | ||
295 | G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, | ||
296 | G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, | ||
297 | G_TYPE_BOOLEAN); | ||
298 | model2 = GTK_TREE_MODEL(tree2); | ||
299 | |||
300 | for (parents[0] = NULL, i = 1; i < 256; i++) | ||
301 | parents[i] = (GtkTreeIter *) g_malloc(sizeof(GtkTreeIter)); | ||
302 | |||
303 | tree1 = gtk_tree_store_new(COL_NUMBER, | ||
304 | G_TYPE_STRING, G_TYPE_STRING, | ||
305 | G_TYPE_STRING, G_TYPE_STRING, | ||
306 | G_TYPE_STRING, G_TYPE_STRING, | ||
307 | G_TYPE_POINTER, GDK_TYPE_COLOR, | ||
308 | G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, | ||
309 | G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, | ||
310 | G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, | ||
311 | G_TYPE_BOOLEAN); | ||
312 | model1 = GTK_TREE_MODEL(tree1); | ||
313 | } | ||
314 | |||
315 | void init_left_tree(void) | ||
316 | { | ||
317 | GtkTreeView *view = GTK_TREE_VIEW(tree1_w); | ||
318 | GtkCellRenderer *renderer; | ||
319 | GtkTreeSelection *sel; | ||
320 | GtkTreeViewColumn *column; | ||
321 | |||
322 | gtk_tree_view_set_model(view, model1); | ||
323 | gtk_tree_view_set_headers_visible(view, TRUE); | ||
324 | gtk_tree_view_set_rules_hint(view, FALSE); | ||
325 | |||
326 | column = gtk_tree_view_column_new(); | ||
327 | gtk_tree_view_append_column(view, column); | ||
328 | gtk_tree_view_column_set_title(column, _("Options")); | ||
329 | |||
330 | renderer = gtk_cell_renderer_toggle_new(); | ||
331 | gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column), | ||
332 | renderer, FALSE); | ||
333 | gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column), | ||
334 | renderer, | ||
335 | "active", COL_BTNACT, | ||
336 | "inconsistent", COL_BTNINC, | ||
337 | "visible", COL_BTNVIS, | ||
338 | "radio", COL_BTNRAD, NULL); | ||
339 | renderer = gtk_cell_renderer_text_new(); | ||
340 | gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column), | ||
341 | renderer, FALSE); | ||
342 | gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column), | ||
343 | renderer, | ||
344 | "text", COL_OPTION, | ||
345 | "foreground-gdk", | ||
346 | COL_COLOR, NULL); | ||
347 | |||
348 | sel = gtk_tree_view_get_selection(view); | ||
349 | gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); | ||
350 | gtk_widget_realize(tree1_w); | ||
351 | } | ||
352 | |||
353 | static void renderer_edited(GtkCellRendererText * cell, | ||
354 | const gchar * path_string, | ||
355 | const gchar * new_text, gpointer user_data); | ||
356 | static void renderer_toggled(GtkCellRendererToggle * cellrenderertoggle, | ||
357 | gchar * arg1, gpointer user_data); | ||
358 | |||
359 | void init_right_tree(void) | ||
360 | { | ||
361 | GtkTreeView *view = GTK_TREE_VIEW(tree2_w); | ||
362 | GtkCellRenderer *renderer; | ||
363 | GtkTreeSelection *sel; | ||
364 | GtkTreeViewColumn *column; | ||
365 | gint i; | ||
366 | |||
367 | gtk_tree_view_set_model(view, model2); | ||
368 | gtk_tree_view_set_headers_visible(view, TRUE); | ||
369 | gtk_tree_view_set_rules_hint(view, FALSE); | ||
370 | |||
371 | column = gtk_tree_view_column_new(); | ||
372 | gtk_tree_view_append_column(view, column); | ||
373 | gtk_tree_view_column_set_title(column, _("Options")); | ||
374 | |||
375 | renderer = gtk_cell_renderer_pixbuf_new(); | ||
376 | gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column), | ||
377 | renderer, FALSE); | ||
378 | gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column), | ||
379 | renderer, | ||
380 | "pixbuf", COL_PIXBUF, | ||
381 | "visible", COL_PIXVIS, NULL); | ||
382 | renderer = gtk_cell_renderer_toggle_new(); | ||
383 | gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column), | ||
384 | renderer, FALSE); | ||
385 | gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column), | ||
386 | renderer, | ||
387 | "active", COL_BTNACT, | ||
388 | "inconsistent", COL_BTNINC, | ||
389 | "visible", COL_BTNVIS, | ||
390 | "radio", COL_BTNRAD, NULL); | ||
391 | /*g_signal_connect(G_OBJECT(renderer), "toggled", | ||
392 | G_CALLBACK(renderer_toggled), NULL); */ | ||
393 | renderer = gtk_cell_renderer_text_new(); | ||
394 | gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column), | ||
395 | renderer, FALSE); | ||
396 | gtk_tree_view_column_set_attributes(GTK_TREE_VIEW_COLUMN(column), | ||
397 | renderer, | ||
398 | "text", COL_OPTION, | ||
399 | "foreground-gdk", | ||
400 | COL_COLOR, NULL); | ||
401 | |||
402 | renderer = gtk_cell_renderer_text_new(); | ||
403 | gtk_tree_view_insert_column_with_attributes(view, -1, | ||
404 | _("Name"), renderer, | ||
405 | "text", COL_NAME, | ||
406 | "foreground-gdk", | ||
407 | COL_COLOR, NULL); | ||
408 | renderer = gtk_cell_renderer_text_new(); | ||
409 | gtk_tree_view_insert_column_with_attributes(view, -1, | ||
410 | "N", renderer, | ||
411 | "text", COL_NO, | ||
412 | "foreground-gdk", | ||
413 | COL_COLOR, NULL); | ||
414 | renderer = gtk_cell_renderer_text_new(); | ||
415 | gtk_tree_view_insert_column_with_attributes(view, -1, | ||
416 | "M", renderer, | ||
417 | "text", COL_MOD, | ||
418 | "foreground-gdk", | ||
419 | COL_COLOR, NULL); | ||
420 | renderer = gtk_cell_renderer_text_new(); | ||
421 | gtk_tree_view_insert_column_with_attributes(view, -1, | ||
422 | "Y", renderer, | ||
423 | "text", COL_YES, | ||
424 | "foreground-gdk", | ||
425 | COL_COLOR, NULL); | ||
426 | renderer = gtk_cell_renderer_text_new(); | ||
427 | gtk_tree_view_insert_column_with_attributes(view, -1, | ||
428 | _("Value"), renderer, | ||
429 | "text", COL_VALUE, | ||
430 | "editable", | ||
431 | COL_EDIT, | ||
432 | "foreground-gdk", | ||
433 | COL_COLOR, NULL); | ||
434 | g_signal_connect(G_OBJECT(renderer), "edited", | ||
435 | G_CALLBACK(renderer_edited), NULL); | ||
436 | |||
437 | column = gtk_tree_view_get_column(view, COL_NAME); | ||
438 | gtk_tree_view_column_set_visible(column, show_name); | ||
439 | column = gtk_tree_view_get_column(view, COL_NO); | ||
440 | gtk_tree_view_column_set_visible(column, show_range); | ||
441 | column = gtk_tree_view_get_column(view, COL_MOD); | ||
442 | gtk_tree_view_column_set_visible(column, show_range); | ||
443 | column = gtk_tree_view_get_column(view, COL_YES); | ||
444 | gtk_tree_view_column_set_visible(column, show_range); | ||
445 | column = gtk_tree_view_get_column(view, COL_VALUE); | ||
446 | gtk_tree_view_column_set_visible(column, show_value); | ||
447 | |||
448 | if (resizeable) { | ||
449 | for (i = 0; i < COL_VALUE; i++) { | ||
450 | column = gtk_tree_view_get_column(view, i); | ||
451 | gtk_tree_view_column_set_resizable(column, TRUE); | ||
452 | } | ||
453 | } | ||
454 | |||
455 | sel = gtk_tree_view_get_selection(view); | ||
456 | gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); | ||
457 | } | ||
458 | |||
459 | |||
460 | /* Utility Functions */ | ||
461 | |||
462 | |||
463 | static void text_insert_help(struct menu *menu) | ||
464 | { | ||
465 | GtkTextBuffer *buffer; | ||
466 | GtkTextIter start, end; | ||
467 | const char *prompt = menu_get_prompt(menu); | ||
468 | gchar *name; | ||
469 | const char *help = _(nohelp_text); | ||
470 | |||
471 | if (!menu->sym) | ||
472 | help = ""; | ||
473 | else if (menu->sym->help) | ||
474 | help = _(menu->sym->help); | ||
475 | |||
476 | if (menu->sym && menu->sym->name) | ||
477 | name = g_strdup_printf(_(menu->sym->name)); | ||
478 | else | ||
479 | name = g_strdup(""); | ||
480 | |||
481 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w)); | ||
482 | gtk_text_buffer_get_bounds(buffer, &start, &end); | ||
483 | gtk_text_buffer_delete(buffer, &start, &end); | ||
484 | gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_w), 15); | ||
485 | |||
486 | gtk_text_buffer_get_end_iter(buffer, &end); | ||
487 | gtk_text_buffer_insert_with_tags(buffer, &end, prompt, -1, tag1, | ||
488 | NULL); | ||
489 | gtk_text_buffer_insert_at_cursor(buffer, " ", 1); | ||
490 | gtk_text_buffer_get_end_iter(buffer, &end); | ||
491 | gtk_text_buffer_insert_with_tags(buffer, &end, name, -1, tag1, | ||
492 | NULL); | ||
493 | gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2); | ||
494 | gtk_text_buffer_get_end_iter(buffer, &end); | ||
495 | gtk_text_buffer_insert_with_tags(buffer, &end, help, -1, tag2, | ||
496 | NULL); | ||
497 | } | ||
498 | |||
499 | |||
500 | static void text_insert_msg(const char *title, const char *message) | ||
501 | { | ||
502 | GtkTextBuffer *buffer; | ||
503 | GtkTextIter start, end; | ||
504 | const char *msg = message; | ||
505 | |||
506 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w)); | ||
507 | gtk_text_buffer_get_bounds(buffer, &start, &end); | ||
508 | gtk_text_buffer_delete(buffer, &start, &end); | ||
509 | gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text_w), 15); | ||
510 | |||
511 | gtk_text_buffer_get_end_iter(buffer, &end); | ||
512 | gtk_text_buffer_insert_with_tags(buffer, &end, title, -1, tag1, | ||
513 | NULL); | ||
514 | gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2); | ||
515 | gtk_text_buffer_get_end_iter(buffer, &end); | ||
516 | gtk_text_buffer_insert_with_tags(buffer, &end, msg, -1, tag2, | ||
517 | NULL); | ||
518 | } | ||
519 | |||
520 | |||
521 | /* Main Windows Callbacks */ | ||
522 | |||
523 | void on_save1_activate(GtkMenuItem * menuitem, gpointer user_data); | ||
524 | gboolean on_window1_delete_event(GtkWidget * widget, GdkEvent * event, | ||
525 | gpointer user_data) | ||
526 | { | ||
527 | GtkWidget *dialog, *label; | ||
528 | gint result; | ||
529 | |||
530 | if (config_changed == FALSE) | ||
531 | return FALSE; | ||
532 | |||
533 | dialog = gtk_dialog_new_with_buttons(_("Warning !"), | ||
534 | GTK_WINDOW(main_wnd), | ||
535 | (GtkDialogFlags) | ||
536 | (GTK_DIALOG_MODAL | | ||
537 | GTK_DIALOG_DESTROY_WITH_PARENT), | ||
538 | GTK_STOCK_OK, | ||
539 | GTK_RESPONSE_YES, | ||
540 | GTK_STOCK_NO, | ||
541 | GTK_RESPONSE_NO, | ||
542 | GTK_STOCK_CANCEL, | ||
543 | GTK_RESPONSE_CANCEL, NULL); | ||
544 | gtk_dialog_set_default_response(GTK_DIALOG(dialog), | ||
545 | GTK_RESPONSE_CANCEL); | ||
546 | |||
547 | label = gtk_label_new(_("\nSave configuration ?\n")); | ||
548 | gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); | ||
549 | gtk_widget_show(label); | ||
550 | |||
551 | result = gtk_dialog_run(GTK_DIALOG(dialog)); | ||
552 | switch (result) { | ||
553 | case GTK_RESPONSE_YES: | ||
554 | on_save1_activate(NULL, NULL); | ||
555 | return FALSE; | ||
556 | case GTK_RESPONSE_NO: | ||
557 | return FALSE; | ||
558 | case GTK_RESPONSE_CANCEL: | ||
559 | case GTK_RESPONSE_DELETE_EVENT: | ||
560 | default: | ||
561 | gtk_widget_destroy(dialog); | ||
562 | return TRUE; | ||
563 | } | ||
564 | |||
565 | return FALSE; | ||
566 | } | ||
567 | |||
568 | |||
569 | void on_window1_destroy(GtkObject * object, gpointer user_data) | ||
570 | { | ||
571 | gtk_main_quit(); | ||
572 | } | ||
573 | |||
574 | |||
575 | void | ||
576 | on_window1_size_request(GtkWidget * widget, | ||
577 | GtkRequisition * requisition, gpointer user_data) | ||
578 | { | ||
579 | static gint old_h; | ||
580 | gint w, h; | ||
581 | |||
582 | if (widget->window == NULL) | ||
583 | gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h); | ||
584 | else | ||
585 | gdk_window_get_size(widget->window, &w, &h); | ||
586 | |||
587 | if (h == old_h) | ||
588 | return; | ||
589 | old_h = h; | ||
590 | |||
591 | gtk_paned_set_position(GTK_PANED(vpaned), 2 * h / 3); | ||
592 | } | ||
593 | |||
594 | |||
595 | /* Menu & Toolbar Callbacks */ | ||
596 | |||
597 | |||
598 | static void | ||
599 | load_filename(GtkFileSelection * file_selector, gpointer user_data) | ||
600 | { | ||
601 | const gchar *fn; | ||
602 | |||
603 | fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION | ||
604 | (user_data)); | ||
605 | |||
606 | if (conf_read(fn)) | ||
607 | text_insert_msg(_("Error"), _("Unable to load configuration !")); | ||
608 | else | ||
609 | display_tree(&rootmenu); | ||
610 | } | ||
611 | |||
612 | void on_load1_activate(GtkMenuItem * menuitem, gpointer user_data) | ||
613 | { | ||
614 | GtkWidget *fs; | ||
615 | |||
616 | fs = gtk_file_selection_new(_("Load file...")); | ||
617 | g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button), | ||
618 | "clicked", | ||
619 | G_CALLBACK(load_filename), (gpointer) fs); | ||
620 | g_signal_connect_swapped(GTK_OBJECT | ||
621 | (GTK_FILE_SELECTION(fs)->ok_button), | ||
622 | "clicked", G_CALLBACK(gtk_widget_destroy), | ||
623 | (gpointer) fs); | ||
624 | g_signal_connect_swapped(GTK_OBJECT | ||
625 | (GTK_FILE_SELECTION(fs)->cancel_button), | ||
626 | "clicked", G_CALLBACK(gtk_widget_destroy), | ||
627 | (gpointer) fs); | ||
628 | gtk_widget_show(fs); | ||
629 | } | ||
630 | |||
631 | |||
632 | void on_save1_activate(GtkMenuItem * menuitem, gpointer user_data) | ||
633 | { | ||
634 | if (conf_write(NULL)) | ||
635 | text_insert_msg(_("Error"), _("Unable to save configuration !")); | ||
636 | |||
637 | config_changed = FALSE; | ||
638 | } | ||
639 | |||
640 | |||
641 | static void | ||
642 | store_filename(GtkFileSelection * file_selector, gpointer user_data) | ||
643 | { | ||
644 | const gchar *fn; | ||
645 | |||
646 | fn = gtk_file_selection_get_filename(GTK_FILE_SELECTION | ||
647 | (user_data)); | ||
648 | |||
649 | if (conf_write(fn)) | ||
650 | text_insert_msg(_("Error"), _("Unable to save configuration !")); | ||
651 | |||
652 | gtk_widget_destroy(GTK_WIDGET(user_data)); | ||
653 | } | ||
654 | |||
655 | void on_save_as1_activate(GtkMenuItem * menuitem, gpointer user_data) | ||
656 | { | ||
657 | GtkWidget *fs; | ||
658 | |||
659 | fs = gtk_file_selection_new(_("Save file as...")); | ||
660 | g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button), | ||
661 | "clicked", | ||
662 | G_CALLBACK(store_filename), (gpointer) fs); | ||
663 | g_signal_connect_swapped(GTK_OBJECT | ||
664 | (GTK_FILE_SELECTION(fs)->ok_button), | ||
665 | "clicked", G_CALLBACK(gtk_widget_destroy), | ||
666 | (gpointer) fs); | ||
667 | g_signal_connect_swapped(GTK_OBJECT | ||
668 | (GTK_FILE_SELECTION(fs)->cancel_button), | ||
669 | "clicked", G_CALLBACK(gtk_widget_destroy), | ||
670 | (gpointer) fs); | ||
671 | gtk_widget_show(fs); | ||
672 | } | ||
673 | |||
674 | |||
675 | void on_quit1_activate(GtkMenuItem * menuitem, gpointer user_data) | ||
676 | { | ||
677 | if (!on_window1_delete_event(NULL, NULL, NULL)) | ||
678 | gtk_widget_destroy(GTK_WIDGET(main_wnd)); | ||
679 | } | ||
680 | |||
681 | |||
682 | void on_show_name1_activate(GtkMenuItem * menuitem, gpointer user_data) | ||
683 | { | ||
684 | GtkTreeViewColumn *col; | ||
685 | |||
686 | show_name = GTK_CHECK_MENU_ITEM(menuitem)->active; | ||
687 | col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_NAME); | ||
688 | if (col) | ||
689 | gtk_tree_view_column_set_visible(col, show_name); | ||
690 | } | ||
691 | |||
692 | |||
693 | void on_show_range1_activate(GtkMenuItem * menuitem, gpointer user_data) | ||
694 | { | ||
695 | GtkTreeViewColumn *col; | ||
696 | |||
697 | show_range = GTK_CHECK_MENU_ITEM(menuitem)->active; | ||
698 | col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_NO); | ||
699 | if (col) | ||
700 | gtk_tree_view_column_set_visible(col, show_range); | ||
701 | col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_MOD); | ||
702 | if (col) | ||
703 | gtk_tree_view_column_set_visible(col, show_range); | ||
704 | col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_YES); | ||
705 | if (col) | ||
706 | gtk_tree_view_column_set_visible(col, show_range); | ||
707 | |||
708 | } | ||
709 | |||
710 | |||
711 | void on_show_data1_activate(GtkMenuItem * menuitem, gpointer user_data) | ||
712 | { | ||
713 | GtkTreeViewColumn *col; | ||
714 | |||
715 | show_value = GTK_CHECK_MENU_ITEM(menuitem)->active; | ||
716 | col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), COL_VALUE); | ||
717 | if (col) | ||
718 | gtk_tree_view_column_set_visible(col, show_value); | ||
719 | } | ||
720 | |||
721 | |||
722 | void | ||
723 | on_show_all_options1_activate(GtkMenuItem * menuitem, gpointer user_data) | ||
724 | { | ||
725 | show_all = GTK_CHECK_MENU_ITEM(menuitem)->active; | ||
726 | |||
727 | gtk_tree_store_clear(tree2); | ||
728 | display_tree(&rootmenu); // instead of update_tree to speed-up | ||
729 | } | ||
730 | |||
731 | |||
732 | void | ||
733 | on_show_debug_info1_activate(GtkMenuItem * menuitem, gpointer user_data) | ||
734 | { | ||
735 | show_debug = GTK_CHECK_MENU_ITEM(menuitem)->active; | ||
736 | update_tree(&rootmenu, NULL); | ||
737 | } | ||
738 | |||
739 | |||
740 | void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data) | ||
741 | { | ||
742 | GtkWidget *dialog; | ||
743 | const gchar *intro_text = _( | ||
744 | "Welcome to gkc, the GTK+ graphical kernel configuration tool\n" | ||
745 | "for Linux.\n" | ||
746 | "For each option, a blank box indicates the feature is disabled, a\n" | ||
747 | "check indicates it is enabled, and a dot indicates that it is to\n" | ||
748 | "be compiled as a module. Clicking on the box will cycle through the three states.\n" | ||
749 | "\n" | ||
750 | "If you do not see an option (e.g., a device driver) that you\n" | ||
751 | "believe should be present, try turning on Show All Options\n" | ||
752 | "under the Options menu.\n" | ||
753 | "Although there is no cross reference yet to help you figure out\n" | ||
754 | "what other options must be enabled to support the option you\n" | ||
755 | "are interested in, you can still view the help of a grayed-out\n" | ||
756 | "option.\n" | ||
757 | "\n" | ||
758 | "Toggling Show Debug Info under the Options menu will show \n" | ||
759 | "the dependencies, which you can then match by examining other options."); | ||
760 | |||
761 | dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd), | ||
762 | GTK_DIALOG_DESTROY_WITH_PARENT, | ||
763 | GTK_MESSAGE_INFO, | ||
764 | GTK_BUTTONS_CLOSE, intro_text); | ||
765 | g_signal_connect_swapped(GTK_OBJECT(dialog), "response", | ||
766 | G_CALLBACK(gtk_widget_destroy), | ||
767 | GTK_OBJECT(dialog)); | ||
768 | gtk_widget_show_all(dialog); | ||
769 | } | ||
770 | |||
771 | |||
772 | void on_about1_activate(GtkMenuItem * menuitem, gpointer user_data) | ||
773 | { | ||
774 | GtkWidget *dialog; | ||
775 | const gchar *about_text = | ||
776 | _("gkc is copyright (c) 2002 Romain Lievin <roms@lpg.ticalc.org>.\n" | ||
777 | "Based on the source code from Roman Zippel.\n"); | ||
778 | |||
779 | dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd), | ||
780 | GTK_DIALOG_DESTROY_WITH_PARENT, | ||
781 | GTK_MESSAGE_INFO, | ||
782 | GTK_BUTTONS_CLOSE, about_text); | ||
783 | g_signal_connect_swapped(GTK_OBJECT(dialog), "response", | ||
784 | G_CALLBACK(gtk_widget_destroy), | ||
785 | GTK_OBJECT(dialog)); | ||
786 | gtk_widget_show_all(dialog); | ||
787 | } | ||
788 | |||
789 | |||
790 | void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data) | ||
791 | { | ||
792 | GtkWidget *dialog; | ||
793 | const gchar *license_text = | ||
794 | _("gkc is released under the terms of the GNU GPL v2.\n" | ||
795 | "For more information, please see the source code or\n" | ||
796 | "visit http://www.fsf.org/licenses/licenses.html\n"); | ||
797 | |||
798 | dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd), | ||
799 | GTK_DIALOG_DESTROY_WITH_PARENT, | ||
800 | GTK_MESSAGE_INFO, | ||
801 | GTK_BUTTONS_CLOSE, license_text); | ||
802 | g_signal_connect_swapped(GTK_OBJECT(dialog), "response", | ||
803 | G_CALLBACK(gtk_widget_destroy), | ||
804 | GTK_OBJECT(dialog)); | ||
805 | gtk_widget_show_all(dialog); | ||
806 | } | ||
807 | |||
808 | |||
809 | void on_back_clicked(GtkButton * button, gpointer user_data) | ||
810 | { | ||
811 | enum prop_type ptype; | ||
812 | |||
813 | current = current->parent; | ||
814 | ptype = current->prompt ? current->prompt->type : P_UNKNOWN; | ||
815 | if (ptype != P_MENU) | ||
816 | current = current->parent; | ||
817 | display_tree_part(); | ||
818 | |||
819 | if (current == &rootmenu) | ||
820 | gtk_widget_set_sensitive(back_btn, FALSE); | ||
821 | } | ||
822 | |||
823 | |||
824 | void on_load_clicked(GtkButton * button, gpointer user_data) | ||
825 | { | ||
826 | on_load1_activate(NULL, user_data); | ||
827 | } | ||
828 | |||
829 | |||
830 | void on_save_clicked(GtkButton * button, gpointer user_data) | ||
831 | { | ||
832 | on_save1_activate(NULL, user_data); | ||
833 | } | ||
834 | |||
835 | |||
836 | void on_single_clicked(GtkButton * button, gpointer user_data) | ||
837 | { | ||
838 | view_mode = SINGLE_VIEW; | ||
839 | gtk_paned_set_position(GTK_PANED(hpaned), 0); | ||
840 | gtk_widget_hide(tree1_w); | ||
841 | current = &rootmenu; | ||
842 | display_tree_part(); | ||
843 | } | ||
844 | |||
845 | |||
846 | void on_split_clicked(GtkButton * button, gpointer user_data) | ||
847 | { | ||
848 | gint w, h; | ||
849 | view_mode = SPLIT_VIEW; | ||
850 | gtk_widget_show(tree1_w); | ||
851 | gtk_window_get_default_size(GTK_WINDOW(main_wnd), &w, &h); | ||
852 | gtk_paned_set_position(GTK_PANED(hpaned), w / 2); | ||
853 | if (tree2) | ||
854 | gtk_tree_store_clear(tree2); | ||
855 | display_list(); | ||
856 | |||
857 | /* Disable back btn, like in full mode. */ | ||
858 | gtk_widget_set_sensitive(back_btn, FALSE); | ||
859 | } | ||
860 | |||
861 | |||
862 | void on_full_clicked(GtkButton * button, gpointer user_data) | ||
863 | { | ||
864 | view_mode = FULL_VIEW; | ||
865 | gtk_paned_set_position(GTK_PANED(hpaned), 0); | ||
866 | gtk_widget_hide(tree1_w); | ||
867 | if (tree2) | ||
868 | gtk_tree_store_clear(tree2); | ||
869 | display_tree(&rootmenu); | ||
870 | gtk_widget_set_sensitive(back_btn, FALSE); | ||
871 | } | ||
872 | |||
873 | |||
874 | void on_collapse_clicked(GtkButton * button, gpointer user_data) | ||
875 | { | ||
876 | gtk_tree_view_collapse_all(GTK_TREE_VIEW(tree2_w)); | ||
877 | } | ||
878 | |||
879 | |||
880 | void on_expand_clicked(GtkButton * button, gpointer user_data) | ||
881 | { | ||
882 | gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w)); | ||
883 | } | ||
884 | |||
885 | |||
886 | /* CTree Callbacks */ | ||
887 | |||
888 | /* Change hex/int/string value in the cell */ | ||
889 | static void renderer_edited(GtkCellRendererText * cell, | ||
890 | const gchar * path_string, | ||
891 | const gchar * new_text, gpointer user_data) | ||
892 | { | ||
893 | GtkTreePath *path = gtk_tree_path_new_from_string(path_string); | ||
894 | GtkTreeIter iter; | ||
895 | const char *old_def, *new_def; | ||
896 | struct menu *menu; | ||
897 | struct symbol *sym; | ||
898 | |||
899 | if (!gtk_tree_model_get_iter(model2, &iter, path)) | ||
900 | return; | ||
901 | |||
902 | gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1); | ||
903 | sym = menu->sym; | ||
904 | |||
905 | gtk_tree_model_get(model2, &iter, COL_VALUE, &old_def, -1); | ||
906 | new_def = new_text; | ||
907 | |||
908 | sym_set_string_value(sym, new_def); | ||
909 | |||
910 | config_changed = TRUE; | ||
911 | update_tree(&rootmenu, NULL); | ||
912 | |||
913 | gtk_tree_path_free(path); | ||
914 | } | ||
915 | |||
916 | /* Change the value of a symbol and update the tree */ | ||
917 | static void change_sym_value(struct menu *menu, gint col) | ||
918 | { | ||
919 | struct symbol *sym = menu->sym; | ||
920 | tristate oldval, newval; | ||
921 | |||
922 | if (!sym) | ||
923 | return; | ||
924 | |||
925 | if (col == COL_NO) | ||
926 | newval = no; | ||
927 | else if (col == COL_MOD) | ||
928 | newval = mod; | ||
929 | else if (col == COL_YES) | ||
930 | newval = yes; | ||
931 | else | ||
932 | return; | ||
933 | |||
934 | switch (sym_get_type(sym)) { | ||
935 | case S_BOOLEAN: | ||
936 | case S_TRISTATE: | ||
937 | oldval = sym_get_tristate_value(sym); | ||
938 | if (!sym_tristate_within_range(sym, newval)) | ||
939 | newval = yes; | ||
940 | sym_set_tristate_value(sym, newval); | ||
941 | config_changed = TRUE; | ||
942 | if (view_mode == FULL_VIEW) | ||
943 | update_tree(&rootmenu, NULL); | ||
944 | else if (view_mode == SPLIT_VIEW) { | ||
945 | update_tree(browsed, NULL); | ||
946 | display_list(); | ||
947 | } | ||
948 | else if (view_mode == SINGLE_VIEW) | ||
949 | display_tree_part(); //fixme: keep exp/coll | ||
950 | break; | ||
951 | case S_INT: | ||
952 | case S_HEX: | ||
953 | case S_STRING: | ||
954 | default: | ||
955 | break; | ||
956 | } | ||
957 | } | ||
958 | |||
959 | static void toggle_sym_value(struct menu *menu) | ||
960 | { | ||
961 | if (!menu->sym) | ||
962 | return; | ||
963 | |||
964 | sym_toggle_tristate_value(menu->sym); | ||
965 | if (view_mode == FULL_VIEW) | ||
966 | update_tree(&rootmenu, NULL); | ||
967 | else if (view_mode == SPLIT_VIEW) { | ||
968 | update_tree(browsed, NULL); | ||
969 | display_list(); | ||
970 | } | ||
971 | else if (view_mode == SINGLE_VIEW) | ||
972 | display_tree_part(); //fixme: keep exp/coll | ||
973 | } | ||
974 | |||
975 | static void renderer_toggled(GtkCellRendererToggle * cell, | ||
976 | gchar * path_string, gpointer user_data) | ||
977 | { | ||
978 | GtkTreePath *path, *sel_path = NULL; | ||
979 | GtkTreeIter iter, sel_iter; | ||
980 | GtkTreeSelection *sel; | ||
981 | struct menu *menu; | ||
982 | |||
983 | path = gtk_tree_path_new_from_string(path_string); | ||
984 | if (!gtk_tree_model_get_iter(model2, &iter, path)) | ||
985 | return; | ||
986 | |||
987 | sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree2_w)); | ||
988 | if (gtk_tree_selection_get_selected(sel, NULL, &sel_iter)) | ||
989 | sel_path = gtk_tree_model_get_path(model2, &sel_iter); | ||
990 | if (!sel_path) | ||
991 | goto out1; | ||
992 | if (gtk_tree_path_compare(path, sel_path)) | ||
993 | goto out2; | ||
994 | |||
995 | gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1); | ||
996 | toggle_sym_value(menu); | ||
997 | |||
998 | out2: | ||
999 | gtk_tree_path_free(sel_path); | ||
1000 | out1: | ||
1001 | gtk_tree_path_free(path); | ||
1002 | } | ||
1003 | |||
1004 | static gint column2index(GtkTreeViewColumn * column) | ||
1005 | { | ||
1006 | gint i; | ||
1007 | |||
1008 | for (i = 0; i < COL_NUMBER; i++) { | ||
1009 | GtkTreeViewColumn *col; | ||
1010 | |||
1011 | col = gtk_tree_view_get_column(GTK_TREE_VIEW(tree2_w), i); | ||
1012 | if (col == column) | ||
1013 | return i; | ||
1014 | } | ||
1015 | |||
1016 | return -1; | ||
1017 | } | ||
1018 | |||
1019 | |||
1020 | /* User click: update choice (full) or goes down (single) */ | ||
1021 | gboolean | ||
1022 | on_treeview2_button_press_event(GtkWidget * widget, | ||
1023 | GdkEventButton * event, gpointer user_data) | ||
1024 | { | ||
1025 | GtkTreeView *view = GTK_TREE_VIEW(widget); | ||
1026 | GtkTreePath *path; | ||
1027 | GtkTreeViewColumn *column; | ||
1028 | GtkTreeIter iter; | ||
1029 | struct menu *menu; | ||
1030 | gint col; | ||
1031 | |||
1032 | #if GTK_CHECK_VERSION(2,1,4) // bug in ctree with earlier version of GTK | ||
1033 | gint tx = (gint) event->x; | ||
1034 | gint ty = (gint) event->y; | ||
1035 | gint cx, cy; | ||
1036 | |||
1037 | gtk_tree_view_get_path_at_pos(view, tx, ty, &path, &column, &cx, | ||
1038 | &cy); | ||
1039 | #else | ||
1040 | gtk_tree_view_get_cursor(view, &path, &column); | ||
1041 | #endif | ||
1042 | if (path == NULL) | ||
1043 | return FALSE; | ||
1044 | |||
1045 | if (!gtk_tree_model_get_iter(model2, &iter, path)) | ||
1046 | return FALSE; | ||
1047 | gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1); | ||
1048 | |||
1049 | col = column2index(column); | ||
1050 | if (event->type == GDK_2BUTTON_PRESS) { | ||
1051 | enum prop_type ptype; | ||
1052 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | ||
1053 | |||
1054 | if (ptype == P_MENU && view_mode != FULL_VIEW && col == COL_OPTION) { | ||
1055 | // goes down into menu | ||
1056 | current = menu; | ||
1057 | display_tree_part(); | ||
1058 | gtk_widget_set_sensitive(back_btn, TRUE); | ||
1059 | } else if ((col == COL_OPTION)) { | ||
1060 | toggle_sym_value(menu); | ||
1061 | gtk_tree_view_expand_row(view, path, TRUE); | ||
1062 | } | ||
1063 | } else { | ||
1064 | if (col == COL_VALUE) { | ||
1065 | toggle_sym_value(menu); | ||
1066 | gtk_tree_view_expand_row(view, path, TRUE); | ||
1067 | } else if (col == COL_NO || col == COL_MOD | ||
1068 | || col == COL_YES) { | ||
1069 | change_sym_value(menu, col); | ||
1070 | gtk_tree_view_expand_row(view, path, TRUE); | ||
1071 | } | ||
1072 | } | ||
1073 | |||
1074 | return FALSE; | ||
1075 | } | ||
1076 | |||
1077 | /* Key pressed: update choice */ | ||
1078 | gboolean | ||
1079 | on_treeview2_key_press_event(GtkWidget * widget, | ||
1080 | GdkEventKey * event, gpointer user_data) | ||
1081 | { | ||
1082 | GtkTreeView *view = GTK_TREE_VIEW(widget); | ||
1083 | GtkTreePath *path; | ||
1084 | GtkTreeViewColumn *column; | ||
1085 | GtkTreeIter iter; | ||
1086 | struct menu *menu; | ||
1087 | gint col; | ||
1088 | |||
1089 | gtk_tree_view_get_cursor(view, &path, &column); | ||
1090 | if (path == NULL) | ||
1091 | return FALSE; | ||
1092 | |||
1093 | if (event->keyval == GDK_space) { | ||
1094 | if (gtk_tree_view_row_expanded(view, path)) | ||
1095 | gtk_tree_view_collapse_row(view, path); | ||
1096 | else | ||
1097 | gtk_tree_view_expand_row(view, path, FALSE); | ||
1098 | return TRUE; | ||
1099 | } | ||
1100 | if (event->keyval == GDK_KP_Enter) { | ||
1101 | } | ||
1102 | if (widget == tree1_w) | ||
1103 | return FALSE; | ||
1104 | |||
1105 | gtk_tree_model_get_iter(model2, &iter, path); | ||
1106 | gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1); | ||
1107 | |||
1108 | if (!strcasecmp(event->string, "n")) | ||
1109 | col = COL_NO; | ||
1110 | else if (!strcasecmp(event->string, "m")) | ||
1111 | col = COL_MOD; | ||
1112 | else if (!strcasecmp(event->string, "y")) | ||
1113 | col = COL_YES; | ||
1114 | else | ||
1115 | col = -1; | ||
1116 | change_sym_value(menu, col); | ||
1117 | |||
1118 | return FALSE; | ||
1119 | } | ||
1120 | |||
1121 | |||
1122 | /* Row selection changed: update help */ | ||
1123 | void | ||
1124 | on_treeview2_cursor_changed(GtkTreeView * treeview, gpointer user_data) | ||
1125 | { | ||
1126 | GtkTreeSelection *selection; | ||
1127 | GtkTreeIter iter; | ||
1128 | struct menu *menu; | ||
1129 | |||
1130 | selection = gtk_tree_view_get_selection(treeview); | ||
1131 | if (gtk_tree_selection_get_selected(selection, &model2, &iter)) { | ||
1132 | gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1); | ||
1133 | text_insert_help(menu); | ||
1134 | } | ||
1135 | } | ||
1136 | |||
1137 | |||
1138 | /* User click: display sub-tree in the right frame. */ | ||
1139 | gboolean | ||
1140 | on_treeview1_button_press_event(GtkWidget * widget, | ||
1141 | GdkEventButton * event, gpointer user_data) | ||
1142 | { | ||
1143 | GtkTreeView *view = GTK_TREE_VIEW(widget); | ||
1144 | GtkTreePath *path; | ||
1145 | GtkTreeViewColumn *column; | ||
1146 | GtkTreeIter iter; | ||
1147 | struct menu *menu; | ||
1148 | |||
1149 | gint tx = (gint) event->x; | ||
1150 | gint ty = (gint) event->y; | ||
1151 | gint cx, cy; | ||
1152 | |||
1153 | gtk_tree_view_get_path_at_pos(view, tx, ty, &path, &column, &cx, | ||
1154 | &cy); | ||
1155 | if (path == NULL) | ||
1156 | return FALSE; | ||
1157 | |||
1158 | gtk_tree_model_get_iter(model1, &iter, path); | ||
1159 | gtk_tree_model_get(model1, &iter, COL_MENU, &menu, -1); | ||
1160 | |||
1161 | if (event->type == GDK_2BUTTON_PRESS) { | ||
1162 | toggle_sym_value(menu); | ||
1163 | current = menu; | ||
1164 | display_tree_part(); | ||
1165 | } else { | ||
1166 | browsed = menu; | ||
1167 | display_tree_part(); | ||
1168 | } | ||
1169 | |||
1170 | gtk_widget_realize(tree2_w); | ||
1171 | gtk_tree_view_set_cursor(view, path, NULL, FALSE); | ||
1172 | gtk_widget_grab_focus(tree2_w); | ||
1173 | |||
1174 | return FALSE; | ||
1175 | } | ||
1176 | |||
1177 | |||
1178 | /* Fill a row of strings */ | ||
1179 | static gchar **fill_row(struct menu *menu) | ||
1180 | { | ||
1181 | static gchar *row[COL_NUMBER]; | ||
1182 | struct symbol *sym = menu->sym; | ||
1183 | const char *def; | ||
1184 | int stype; | ||
1185 | tristate val; | ||
1186 | enum prop_type ptype; | ||
1187 | int i; | ||
1188 | |||
1189 | for (i = COL_OPTION; i <= COL_COLOR; i++) | ||
1190 | g_free(row[i]); | ||
1191 | bzero(row, sizeof(row)); | ||
1192 | |||
1193 | row[COL_OPTION] = | ||
1194 | g_strdup_printf("%s %s", menu_get_prompt(menu), | ||
1195 | sym ? (sym-> | ||
1196 | flags & SYMBOL_NEW ? "(NEW)" : "") : | ||
1197 | ""); | ||
1198 | |||
1199 | if (show_all && !menu_is_visible(menu)) | ||
1200 | row[COL_COLOR] = g_strdup("DarkGray"); | ||
1201 | else | ||
1202 | row[COL_COLOR] = g_strdup("Black"); | ||
1203 | |||
1204 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | ||
1205 | switch (ptype) { | ||
1206 | case P_MENU: | ||
1207 | row[COL_PIXBUF] = (gchar *) xpm_menu; | ||
1208 | if (view_mode == SINGLE_VIEW) | ||
1209 | row[COL_PIXVIS] = GINT_TO_POINTER(TRUE); | ||
1210 | row[COL_BTNVIS] = GINT_TO_POINTER(FALSE); | ||
1211 | break; | ||
1212 | case P_COMMENT: | ||
1213 | row[COL_PIXBUF] = (gchar *) xpm_void; | ||
1214 | row[COL_PIXVIS] = GINT_TO_POINTER(FALSE); | ||
1215 | row[COL_BTNVIS] = GINT_TO_POINTER(FALSE); | ||
1216 | break; | ||
1217 | default: | ||
1218 | row[COL_PIXBUF] = (gchar *) xpm_void; | ||
1219 | row[COL_PIXVIS] = GINT_TO_POINTER(FALSE); | ||
1220 | row[COL_BTNVIS] = GINT_TO_POINTER(TRUE); | ||
1221 | break; | ||
1222 | } | ||
1223 | |||
1224 | if (!sym) | ||
1225 | return row; | ||
1226 | row[COL_NAME] = g_strdup(sym->name); | ||
1227 | |||
1228 | sym_calc_value(sym); | ||
1229 | sym->flags &= ~SYMBOL_CHANGED; | ||
1230 | |||
1231 | if (sym_is_choice(sym)) { // parse childs for getting final value | ||
1232 | struct menu *child; | ||
1233 | struct symbol *def_sym = sym_get_choice_value(sym); | ||
1234 | struct menu *def_menu = NULL; | ||
1235 | |||
1236 | row[COL_BTNVIS] = GINT_TO_POINTER(FALSE); | ||
1237 | |||
1238 | for (child = menu->list; child; child = child->next) { | ||
1239 | if (menu_is_visible(child) | ||
1240 | && child->sym == def_sym) | ||
1241 | def_menu = child; | ||
1242 | } | ||
1243 | |||
1244 | if (def_menu) | ||
1245 | row[COL_VALUE] = | ||
1246 | g_strdup(menu_get_prompt(def_menu)); | ||
1247 | } | ||
1248 | if (sym->flags & SYMBOL_CHOICEVAL) | ||
1249 | row[COL_BTNRAD] = GINT_TO_POINTER(TRUE); | ||
1250 | |||
1251 | stype = sym_get_type(sym); | ||
1252 | switch (stype) { | ||
1253 | case S_BOOLEAN: | ||
1254 | if (GPOINTER_TO_INT(row[COL_PIXVIS]) == FALSE) | ||
1255 | row[COL_BTNVIS] = GINT_TO_POINTER(TRUE); | ||
1256 | if (sym_is_choice(sym)) | ||
1257 | break; | ||
1258 | case S_TRISTATE: | ||
1259 | val = sym_get_tristate_value(sym); | ||
1260 | switch (val) { | ||
1261 | case no: | ||
1262 | row[COL_NO] = g_strdup("N"); | ||
1263 | row[COL_VALUE] = g_strdup("N"); | ||
1264 | row[COL_BTNACT] = GINT_TO_POINTER(FALSE); | ||
1265 | row[COL_BTNINC] = GINT_TO_POINTER(FALSE); | ||
1266 | break; | ||
1267 | case mod: | ||
1268 | row[COL_MOD] = g_strdup("M"); | ||
1269 | row[COL_VALUE] = g_strdup("M"); | ||
1270 | row[COL_BTNINC] = GINT_TO_POINTER(TRUE); | ||
1271 | break; | ||
1272 | case yes: | ||
1273 | row[COL_YES] = g_strdup("Y"); | ||
1274 | row[COL_VALUE] = g_strdup("Y"); | ||
1275 | row[COL_BTNACT] = GINT_TO_POINTER(TRUE); | ||
1276 | row[COL_BTNINC] = GINT_TO_POINTER(FALSE); | ||
1277 | break; | ||
1278 | } | ||
1279 | |||
1280 | if (val != no && sym_tristate_within_range(sym, no)) | ||
1281 | row[COL_NO] = g_strdup("_"); | ||
1282 | if (val != mod && sym_tristate_within_range(sym, mod)) | ||
1283 | row[COL_MOD] = g_strdup("_"); | ||
1284 | if (val != yes && sym_tristate_within_range(sym, yes)) | ||
1285 | row[COL_YES] = g_strdup("_"); | ||
1286 | break; | ||
1287 | case S_INT: | ||
1288 | case S_HEX: | ||
1289 | case S_STRING: | ||
1290 | def = sym_get_string_value(sym); | ||
1291 | row[COL_VALUE] = g_strdup(def); | ||
1292 | row[COL_EDIT] = GINT_TO_POINTER(TRUE); | ||
1293 | row[COL_BTNVIS] = GINT_TO_POINTER(FALSE); | ||
1294 | break; | ||
1295 | } | ||
1296 | |||
1297 | return row; | ||
1298 | } | ||
1299 | |||
1300 | |||
1301 | /* Set the node content with a row of strings */ | ||
1302 | static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row) | ||
1303 | { | ||
1304 | GdkColor color; | ||
1305 | gboolean success; | ||
1306 | GdkPixbuf *pix; | ||
1307 | |||
1308 | pix = gdk_pixbuf_new_from_xpm_data((const char **) | ||
1309 | row[COL_PIXBUF]); | ||
1310 | |||
1311 | gdk_color_parse(row[COL_COLOR], &color); | ||
1312 | gdk_colormap_alloc_colors(gdk_colormap_get_system(), &color, 1, | ||
1313 | FALSE, FALSE, &success); | ||
1314 | |||
1315 | gtk_tree_store_set(tree, node, | ||
1316 | COL_OPTION, row[COL_OPTION], | ||
1317 | COL_NAME, row[COL_NAME], | ||
1318 | COL_NO, row[COL_NO], | ||
1319 | COL_MOD, row[COL_MOD], | ||
1320 | COL_YES, row[COL_YES], | ||
1321 | COL_VALUE, row[COL_VALUE], | ||
1322 | COL_MENU, (gpointer) menu, | ||
1323 | COL_COLOR, &color, | ||
1324 | COL_EDIT, GPOINTER_TO_INT(row[COL_EDIT]), | ||
1325 | COL_PIXBUF, pix, | ||
1326 | COL_PIXVIS, GPOINTER_TO_INT(row[COL_PIXVIS]), | ||
1327 | COL_BTNVIS, GPOINTER_TO_INT(row[COL_BTNVIS]), | ||
1328 | COL_BTNACT, GPOINTER_TO_INT(row[COL_BTNACT]), | ||
1329 | COL_BTNINC, GPOINTER_TO_INT(row[COL_BTNINC]), | ||
1330 | COL_BTNRAD, GPOINTER_TO_INT(row[COL_BTNRAD]), | ||
1331 | -1); | ||
1332 | |||
1333 | g_object_unref(pix); | ||
1334 | } | ||
1335 | |||
1336 | |||
1337 | /* Add a node to the tree */ | ||
1338 | static void place_node(struct menu *menu, char **row) | ||
1339 | { | ||
1340 | GtkTreeIter *parent = parents[indent - 1]; | ||
1341 | GtkTreeIter *node = parents[indent]; | ||
1342 | |||
1343 | gtk_tree_store_append(tree, node, parent); | ||
1344 | set_node(node, menu, row); | ||
1345 | } | ||
1346 | |||
1347 | |||
1348 | /* Find a node in the GTK+ tree */ | ||
1349 | static GtkTreeIter found; | ||
1350 | |||
1351 | /* | ||
1352 | * Find a menu in the GtkTree starting at parent. | ||
1353 | */ | ||
1354 | GtkTreeIter *gtktree_iter_find_node(GtkTreeIter * parent, | ||
1355 | struct menu *tofind) | ||
1356 | { | ||
1357 | GtkTreeIter iter; | ||
1358 | GtkTreeIter *child = &iter; | ||
1359 | gboolean valid; | ||
1360 | GtkTreeIter *ret; | ||
1361 | |||
1362 | valid = gtk_tree_model_iter_children(model2, child, parent); | ||
1363 | while (valid) { | ||
1364 | struct menu *menu; | ||
1365 | |||
1366 | gtk_tree_model_get(model2, child, 6, &menu, -1); | ||
1367 | |||
1368 | if (menu == tofind) { | ||
1369 | memcpy(&found, child, sizeof(GtkTreeIter)); | ||
1370 | return &found; | ||
1371 | } | ||
1372 | |||
1373 | ret = gtktree_iter_find_node(child, tofind); | ||
1374 | if (ret) | ||
1375 | return ret; | ||
1376 | |||
1377 | valid = gtk_tree_model_iter_next(model2, child); | ||
1378 | } | ||
1379 | |||
1380 | return NULL; | ||
1381 | } | ||
1382 | |||
1383 | |||
1384 | /* | ||
1385 | * Update the tree by adding/removing entries | ||
1386 | * Does not change other nodes | ||
1387 | */ | ||
1388 | static void update_tree(struct menu *src, GtkTreeIter * dst) | ||
1389 | { | ||
1390 | struct menu *child1; | ||
1391 | GtkTreeIter iter, tmp; | ||
1392 | GtkTreeIter *child2 = &iter; | ||
1393 | gboolean valid; | ||
1394 | GtkTreeIter *sibling; | ||
1395 | struct symbol *sym; | ||
1396 | struct property *prop; | ||
1397 | struct menu *menu1, *menu2; | ||
1398 | |||
1399 | if (src == &rootmenu) | ||
1400 | indent = 1; | ||
1401 | |||
1402 | valid = gtk_tree_model_iter_children(model2, child2, dst); | ||
1403 | for (child1 = src->list; child1; child1 = child1->next) { | ||
1404 | |||
1405 | prop = child1->prompt; | ||
1406 | sym = child1->sym; | ||
1407 | |||
1408 | reparse: | ||
1409 | menu1 = child1; | ||
1410 | if (valid) | ||
1411 | gtk_tree_model_get(model2, child2, COL_MENU, | ||
1412 | &menu2, -1); | ||
1413 | else | ||
1414 | menu2 = NULL; // force adding of a first child | ||
1415 | |||
1416 | #ifdef DEBUG | ||
1417 | printf("%*c%s | %s\n", indent, ' ', | ||
1418 | menu1 ? menu_get_prompt(menu1) : "nil", | ||
1419 | menu2 ? menu_get_prompt(menu2) : "nil"); | ||
1420 | #endif | ||
1421 | |||
1422 | if (!menu_is_visible(child1) && !show_all) { // remove node | ||
1423 | if (gtktree_iter_find_node(dst, menu1) != NULL) { | ||
1424 | memcpy(&tmp, child2, sizeof(GtkTreeIter)); | ||
1425 | valid = gtk_tree_model_iter_next(model2, | ||
1426 | child2); | ||
1427 | gtk_tree_store_remove(tree2, &tmp); | ||
1428 | if (!valid) | ||
1429 | return; // next parent | ||
1430 | else | ||
1431 | goto reparse; // next child | ||
1432 | } else | ||
1433 | continue; | ||
1434 | } | ||
1435 | |||
1436 | if (menu1 != menu2) { | ||
1437 | if (gtktree_iter_find_node(dst, menu1) == NULL) { // add node | ||
1438 | if (!valid && !menu2) | ||
1439 | sibling = NULL; | ||
1440 | else | ||
1441 | sibling = child2; | ||
1442 | gtk_tree_store_insert_before(tree2, | ||
1443 | child2, | ||
1444 | dst, sibling); | ||
1445 | set_node(child2, menu1, fill_row(menu1)); | ||
1446 | if (menu2 == NULL) | ||
1447 | valid = TRUE; | ||
1448 | } else { // remove node | ||
1449 | memcpy(&tmp, child2, sizeof(GtkTreeIter)); | ||
1450 | valid = gtk_tree_model_iter_next(model2, | ||
1451 | child2); | ||
1452 | gtk_tree_store_remove(tree2, &tmp); | ||
1453 | if (!valid) | ||
1454 | return; // next parent | ||
1455 | else | ||
1456 | goto reparse; // next child | ||
1457 | } | ||
1458 | } else if (sym && (sym->flags & SYMBOL_CHANGED)) { | ||
1459 | set_node(child2, menu1, fill_row(menu1)); | ||
1460 | } | ||
1461 | |||
1462 | indent++; | ||
1463 | update_tree(child1, child2); | ||
1464 | indent--; | ||
1465 | |||
1466 | valid = gtk_tree_model_iter_next(model2, child2); | ||
1467 | } | ||
1468 | } | ||
1469 | |||
1470 | |||
1471 | /* Display the whole tree (single/split/full view) */ | ||
1472 | static void display_tree(struct menu *menu) | ||
1473 | { | ||
1474 | struct symbol *sym; | ||
1475 | struct property *prop; | ||
1476 | struct menu *child; | ||
1477 | enum prop_type ptype; | ||
1478 | |||
1479 | if (menu == &rootmenu) { | ||
1480 | indent = 1; | ||
1481 | current = &rootmenu; | ||
1482 | } | ||
1483 | |||
1484 | for (child = menu->list; child; child = child->next) { | ||
1485 | prop = child->prompt; | ||
1486 | sym = child->sym; | ||
1487 | ptype = prop ? prop->type : P_UNKNOWN; | ||
1488 | |||
1489 | if (sym) | ||
1490 | sym->flags &= ~SYMBOL_CHANGED; | ||
1491 | |||
1492 | if ((view_mode == SPLIT_VIEW) | ||
1493 | && !(child->flags & MENU_ROOT) && (tree == tree1)) | ||
1494 | continue; | ||
1495 | |||
1496 | if ((view_mode == SPLIT_VIEW) && (child->flags & MENU_ROOT) | ||
1497 | && (tree == tree2)) | ||
1498 | continue; | ||
1499 | |||
1500 | if (menu_is_visible(child) || show_all) | ||
1501 | place_node(child, fill_row(child)); | ||
1502 | #ifdef DEBUG | ||
1503 | printf("%*c%s: ", indent, ' ', menu_get_prompt(child)); | ||
1504 | printf("%s", child->flags & MENU_ROOT ? "rootmenu | " : ""); | ||
1505 | dbg_print_ptype(ptype); | ||
1506 | printf(" | "); | ||
1507 | if (sym) { | ||
1508 | dbg_print_stype(sym->type); | ||
1509 | printf(" | "); | ||
1510 | dbg_print_flags(sym->flags); | ||
1511 | printf("\n"); | ||
1512 | } else | ||
1513 | printf("\n"); | ||
1514 | #endif | ||
1515 | if ((view_mode != FULL_VIEW) && (ptype == P_MENU) | ||
1516 | && (tree == tree2)) | ||
1517 | continue; | ||
1518 | /* | ||
1519 | if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT)) | ||
1520 | || (view_mode == FULL_VIEW) | ||
1521 | || (view_mode == SPLIT_VIEW))*/ | ||
1522 | if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT)) | ||
1523 | || (view_mode == FULL_VIEW) | ||
1524 | || (view_mode == SPLIT_VIEW)) { | ||
1525 | indent++; | ||
1526 | display_tree(child); | ||
1527 | indent--; | ||
1528 | } | ||
1529 | } | ||
1530 | } | ||
1531 | |||
1532 | /* Display a part of the tree starting at current node (single/split view) */ | ||
1533 | static void display_tree_part(void) | ||
1534 | { | ||
1535 | if (tree2) | ||
1536 | gtk_tree_store_clear(tree2); | ||
1537 | if (view_mode == SINGLE_VIEW) | ||
1538 | display_tree(current); | ||
1539 | else if (view_mode == SPLIT_VIEW) | ||
1540 | display_tree(browsed); | ||
1541 | gtk_tree_view_expand_all(GTK_TREE_VIEW(tree2_w)); | ||
1542 | } | ||
1543 | |||
1544 | /* Display the list in the left frame (split view) */ | ||
1545 | static void display_list(void) | ||
1546 | { | ||
1547 | if (tree1) | ||
1548 | gtk_tree_store_clear(tree1); | ||
1549 | |||
1550 | tree = tree1; | ||
1551 | display_tree(&rootmenu); | ||
1552 | gtk_tree_view_expand_all(GTK_TREE_VIEW(tree1_w)); | ||
1553 | tree = tree2; | ||
1554 | } | ||
1555 | |||
1556 | void fixup_rootmenu(struct menu *menu) | ||
1557 | { | ||
1558 | struct menu *child; | ||
1559 | static int menu_cnt = 0; | ||
1560 | |||
1561 | menu->flags |= MENU_ROOT; | ||
1562 | for (child = menu->list; child; child = child->next) { | ||
1563 | if (child->prompt && child->prompt->type == P_MENU) { | ||
1564 | menu_cnt++; | ||
1565 | fixup_rootmenu(child); | ||
1566 | menu_cnt--; | ||
1567 | } else if (!menu_cnt) | ||
1568 | fixup_rootmenu(child); | ||
1569 | } | ||
1570 | } | ||
1571 | |||
1572 | |||
1573 | /* Main */ | ||
1574 | int main(int ac, char *av[]) | ||
1575 | { | ||
1576 | const char *name; | ||
1577 | char *env; | ||
1578 | gchar *glade_file; | ||
1579 | |||
1580 | #ifndef LKC_DIRECT_LINK | ||
1581 | kconfig_load(); | ||
1582 | #endif | ||
1583 | |||
1584 | bindtextdomain(PACKAGE, LOCALEDIR); | ||
1585 | bind_textdomain_codeset(PACKAGE, "UTF-8"); | ||
1586 | textdomain(PACKAGE); | ||
1587 | |||
1588 | /* GTK stuffs */ | ||
1589 | gtk_set_locale(); | ||
1590 | gtk_init(&ac, &av); | ||
1591 | glade_init(); | ||
1592 | |||
1593 | //add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps"); | ||
1594 | //add_pixmap_directory (PACKAGE_SOURCE_DIR "/pixmaps"); | ||
1595 | |||
1596 | /* Determine GUI path */ | ||
1597 | env = getenv(SRCTREE); | ||
1598 | if (env) | ||
1599 | glade_file = g_strconcat(env, "/scripts/kconfig/gconf.glade", NULL); | ||
1600 | else if (av[0][0] == '/') | ||
1601 | glade_file = g_strconcat(av[0], ".glade", NULL); | ||
1602 | else | ||
1603 | glade_file = g_strconcat(g_get_current_dir(), "/", av[0], ".glade", NULL); | ||
1604 | |||
1605 | /* Load the interface and connect signals */ | ||
1606 | init_main_window(glade_file); | ||
1607 | init_tree_model(); | ||
1608 | init_left_tree(); | ||
1609 | init_right_tree(); | ||
1610 | |||
1611 | /* Conf stuffs */ | ||
1612 | if (ac > 1 && av[1][0] == '-') { | ||
1613 | switch (av[1][1]) { | ||
1614 | case 'a': | ||
1615 | //showAll = 1; | ||
1616 | break; | ||
1617 | case 'h': | ||
1618 | case '?': | ||
1619 | printf("%s <config>\n", av[0]); | ||
1620 | exit(0); | ||
1621 | } | ||
1622 | name = av[2]; | ||
1623 | } else | ||
1624 | name = av[1]; | ||
1625 | |||
1626 | conf_parse(name); | ||
1627 | fixup_rootmenu(&rootmenu); | ||
1628 | conf_read(NULL); | ||
1629 | |||
1630 | switch (view_mode) { | ||
1631 | case SINGLE_VIEW: | ||
1632 | display_tree_part(); | ||
1633 | break; | ||
1634 | case SPLIT_VIEW: | ||
1635 | display_list(); | ||
1636 | break; | ||
1637 | case FULL_VIEW: | ||
1638 | display_tree(&rootmenu); | ||
1639 | break; | ||
1640 | } | ||
1641 | |||
1642 | gtk_main(); | ||
1643 | |||
1644 | return 0; | ||
1645 | } | ||
diff --git a/scripts/kconfig/gconf.glade b/scripts/kconfig/gconf.glade new file mode 100644 index 000000000..f8744ed64 --- /dev/null +++ b/scripts/kconfig/gconf.glade | |||
@@ -0,0 +1,648 @@ | |||
1 | <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> | ||
2 | <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> | ||
3 | |||
4 | <glade-interface> | ||
5 | |||
6 | <widget class="GtkWindow" id="window1"> | ||
7 | <property name="visible">True</property> | ||
8 | <property name="title" translatable="yes">Gtk Kernel Configurator</property> | ||
9 | <property name="type">GTK_WINDOW_TOPLEVEL</property> | ||
10 | <property name="window_position">GTK_WIN_POS_NONE</property> | ||
11 | <property name="modal">False</property> | ||
12 | <property name="default_width">640</property> | ||
13 | <property name="default_height">480</property> | ||
14 | <property name="resizable">True</property> | ||
15 | <property name="destroy_with_parent">False</property> | ||
16 | <property name="decorated">True</property> | ||
17 | <property name="skip_taskbar_hint">False</property> | ||
18 | <property name="skip_pager_hint">False</property> | ||
19 | <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> | ||
20 | <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> | ||
21 | <signal name="destroy" handler="on_window1_destroy" object="window1"/> | ||
22 | <signal name="size_request" handler="on_window1_size_request" object="vpaned1" last_modification_time="Fri, 11 Jan 2002 16:17:11 GMT"/> | ||
23 | <signal name="delete_event" handler="on_window1_delete_event" object="window1" last_modification_time="Sun, 09 Mar 2003 19:42:46 GMT"/> | ||
24 | |||
25 | <child> | ||
26 | <widget class="GtkVBox" id="vbox1"> | ||
27 | <property name="visible">True</property> | ||
28 | <property name="homogeneous">False</property> | ||
29 | <property name="spacing">0</property> | ||
30 | |||
31 | <child> | ||
32 | <widget class="GtkMenuBar" id="menubar1"> | ||
33 | <property name="visible">True</property> | ||
34 | |||
35 | <child> | ||
36 | <widget class="GtkMenuItem" id="file1"> | ||
37 | <property name="visible">True</property> | ||
38 | <property name="label" translatable="yes">_File</property> | ||
39 | <property name="use_underline">True</property> | ||
40 | |||
41 | <child> | ||
42 | <widget class="GtkMenu" id="file1_menu"> | ||
43 | |||
44 | <child> | ||
45 | <widget class="GtkImageMenuItem" id="load1"> | ||
46 | <property name="visible">True</property> | ||
47 | <property name="tooltip" translatable="yes">Load a config file</property> | ||
48 | <property name="label" translatable="yes">_Load</property> | ||
49 | <property name="use_underline">True</property> | ||
50 | <signal name="activate" handler="on_load1_activate"/> | ||
51 | <accelerator key="L" modifiers="GDK_CONTROL_MASK" signal="activate"/> | ||
52 | |||
53 | <child internal-child="image"> | ||
54 | <widget class="GtkImage" id="image39"> | ||
55 | <property name="visible">True</property> | ||
56 | <property name="stock">gtk-open</property> | ||
57 | <property name="icon_size">1</property> | ||
58 | <property name="xalign">0.5</property> | ||
59 | <property name="yalign">0.5</property> | ||
60 | <property name="xpad">0</property> | ||
61 | <property name="ypad">0</property> | ||
62 | </widget> | ||
63 | </child> | ||
64 | </widget> | ||
65 | </child> | ||
66 | |||
67 | <child> | ||
68 | <widget class="GtkImageMenuItem" id="save1"> | ||
69 | <property name="visible">True</property> | ||
70 | <property name="tooltip" translatable="yes">Save the config in .config</property> | ||
71 | <property name="label" translatable="yes">_Save</property> | ||
72 | <property name="use_underline">True</property> | ||
73 | <signal name="activate" handler="on_save1_activate"/> | ||
74 | <accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/> | ||
75 | |||
76 | <child internal-child="image"> | ||
77 | <widget class="GtkImage" id="image40"> | ||
78 | <property name="visible">True</property> | ||
79 | <property name="stock">gtk-save</property> | ||
80 | <property name="icon_size">1</property> | ||
81 | <property name="xalign">0.5</property> | ||
82 | <property name="yalign">0.5</property> | ||
83 | <property name="xpad">0</property> | ||
84 | <property name="ypad">0</property> | ||
85 | </widget> | ||
86 | </child> | ||
87 | </widget> | ||
88 | </child> | ||
89 | |||
90 | <child> | ||
91 | <widget class="GtkImageMenuItem" id="save_as1"> | ||
92 | <property name="visible">True</property> | ||
93 | <property name="tooltip" translatable="yes">Save the config in a file</property> | ||
94 | <property name="label" translatable="yes">Save _as</property> | ||
95 | <property name="use_underline">True</property> | ||
96 | <signal name="activate" handler="on_save_as1_activate"/> | ||
97 | |||
98 | <child internal-child="image"> | ||
99 | <widget class="GtkImage" id="image41"> | ||
100 | <property name="visible">True</property> | ||
101 | <property name="stock">gtk-save-as</property> | ||
102 | <property name="icon_size">1</property> | ||
103 | <property name="xalign">0.5</property> | ||
104 | <property name="yalign">0.5</property> | ||
105 | <property name="xpad">0</property> | ||
106 | <property name="ypad">0</property> | ||
107 | </widget> | ||
108 | </child> | ||
109 | </widget> | ||
110 | </child> | ||
111 | |||
112 | <child> | ||
113 | <widget class="GtkSeparatorMenuItem" id="separator1"> | ||
114 | <property name="visible">True</property> | ||
115 | </widget> | ||
116 | </child> | ||
117 | |||
118 | <child> | ||
119 | <widget class="GtkImageMenuItem" id="quit1"> | ||
120 | <property name="visible">True</property> | ||
121 | <property name="label" translatable="yes">_Quit</property> | ||
122 | <property name="use_underline">True</property> | ||
123 | <signal name="activate" handler="on_quit1_activate"/> | ||
124 | <accelerator key="Q" modifiers="GDK_CONTROL_MASK" signal="activate"/> | ||
125 | |||
126 | <child internal-child="image"> | ||
127 | <widget class="GtkImage" id="image42"> | ||
128 | <property name="visible">True</property> | ||
129 | <property name="stock">gtk-quit</property> | ||
130 | <property name="icon_size">1</property> | ||
131 | <property name="xalign">0.5</property> | ||
132 | <property name="yalign">0.5</property> | ||
133 | <property name="xpad">0</property> | ||
134 | <property name="ypad">0</property> | ||
135 | </widget> | ||
136 | </child> | ||
137 | </widget> | ||
138 | </child> | ||
139 | </widget> | ||
140 | </child> | ||
141 | </widget> | ||
142 | </child> | ||
143 | |||
144 | <child> | ||
145 | <widget class="GtkMenuItem" id="options1"> | ||
146 | <property name="visible">True</property> | ||
147 | <property name="label" translatable="yes">_Options</property> | ||
148 | <property name="use_underline">True</property> | ||
149 | |||
150 | <child> | ||
151 | <widget class="GtkMenu" id="options1_menu"> | ||
152 | |||
153 | <child> | ||
154 | <widget class="GtkCheckMenuItem" id="show_name1"> | ||
155 | <property name="visible">True</property> | ||
156 | <property name="tooltip" translatable="yes">Show name</property> | ||
157 | <property name="label" translatable="yes">Show _name</property> | ||
158 | <property name="use_underline">True</property> | ||
159 | <property name="active">False</property> | ||
160 | <signal name="activate" handler="on_show_name1_activate"/> | ||
161 | </widget> | ||
162 | </child> | ||
163 | |||
164 | <child> | ||
165 | <widget class="GtkCheckMenuItem" id="show_range1"> | ||
166 | <property name="visible">True</property> | ||
167 | <property name="tooltip" translatable="yes">Show range (Y/M/N)</property> | ||
168 | <property name="label" translatable="yes">Show _range</property> | ||
169 | <property name="use_underline">True</property> | ||
170 | <property name="active">False</property> | ||
171 | <signal name="activate" handler="on_show_range1_activate"/> | ||
172 | </widget> | ||
173 | </child> | ||
174 | |||
175 | <child> | ||
176 | <widget class="GtkCheckMenuItem" id="show_data1"> | ||
177 | <property name="visible">True</property> | ||
178 | <property name="tooltip" translatable="yes">Show value of the option</property> | ||
179 | <property name="label" translatable="yes">Show _data</property> | ||
180 | <property name="use_underline">True</property> | ||
181 | <property name="active">False</property> | ||
182 | <signal name="activate" handler="on_show_data1_activate"/> | ||
183 | </widget> | ||
184 | </child> | ||
185 | |||
186 | <child> | ||
187 | <widget class="GtkSeparatorMenuItem" id="separator2"> | ||
188 | <property name="visible">True</property> | ||
189 | </widget> | ||
190 | </child> | ||
191 | |||
192 | <child> | ||
193 | <widget class="GtkCheckMenuItem" id="show_all_options1"> | ||
194 | <property name="visible">True</property> | ||
195 | <property name="tooltip" translatable="yes">Show all options</property> | ||
196 | <property name="label" translatable="yes">Show all _options</property> | ||
197 | <property name="use_underline">True</property> | ||
198 | <property name="active">False</property> | ||
199 | <signal name="activate" handler="on_show_all_options1_activate"/> | ||
200 | </widget> | ||
201 | </child> | ||
202 | |||
203 | <child> | ||
204 | <widget class="GtkCheckMenuItem" id="show_debug_info1"> | ||
205 | <property name="visible">True</property> | ||
206 | <property name="tooltip" translatable="yes">Show masked options</property> | ||
207 | <property name="label" translatable="yes">Show _debug info</property> | ||
208 | <property name="use_underline">True</property> | ||
209 | <property name="active">False</property> | ||
210 | <signal name="activate" handler="on_show_debug_info1_activate"/> | ||
211 | </widget> | ||
212 | </child> | ||
213 | </widget> | ||
214 | </child> | ||
215 | </widget> | ||
216 | </child> | ||
217 | |||
218 | <child> | ||
219 | <widget class="GtkMenuItem" id="help1"> | ||
220 | <property name="visible">True</property> | ||
221 | <property name="label" translatable="yes">_Help</property> | ||
222 | <property name="use_underline">True</property> | ||
223 | |||
224 | <child> | ||
225 | <widget class="GtkMenu" id="help1_menu"> | ||
226 | |||
227 | <child> | ||
228 | <widget class="GtkImageMenuItem" id="introduction1"> | ||
229 | <property name="visible">True</property> | ||
230 | <property name="label" translatable="yes">_Introduction</property> | ||
231 | <property name="use_underline">True</property> | ||
232 | <signal name="activate" handler="on_introduction1_activate" last_modification_time="Fri, 15 Nov 2002 20:26:30 GMT"/> | ||
233 | <accelerator key="I" modifiers="GDK_CONTROL_MASK" signal="activate"/> | ||
234 | |||
235 | <child internal-child="image"> | ||
236 | <widget class="GtkImage" id="image43"> | ||
237 | <property name="visible">True</property> | ||
238 | <property name="stock">gtk-dialog-question</property> | ||
239 | <property name="icon_size">1</property> | ||
240 | <property name="xalign">0.5</property> | ||
241 | <property name="yalign">0.5</property> | ||
242 | <property name="xpad">0</property> | ||
243 | <property name="ypad">0</property> | ||
244 | </widget> | ||
245 | </child> | ||
246 | </widget> | ||
247 | </child> | ||
248 | |||
249 | <child> | ||
250 | <widget class="GtkImageMenuItem" id="about1"> | ||
251 | <property name="visible">True</property> | ||
252 | <property name="label" translatable="yes">_About</property> | ||
253 | <property name="use_underline">True</property> | ||
254 | <signal name="activate" handler="on_about1_activate" last_modification_time="Fri, 15 Nov 2002 20:26:30 GMT"/> | ||
255 | <accelerator key="A" modifiers="GDK_CONTROL_MASK" signal="activate"/> | ||
256 | |||
257 | <child internal-child="image"> | ||
258 | <widget class="GtkImage" id="image44"> | ||
259 | <property name="visible">True</property> | ||
260 | <property name="stock">gtk-properties</property> | ||
261 | <property name="icon_size">1</property> | ||
262 | <property name="xalign">0.5</property> | ||
263 | <property name="yalign">0.5</property> | ||
264 | <property name="xpad">0</property> | ||
265 | <property name="ypad">0</property> | ||
266 | </widget> | ||
267 | </child> | ||
268 | </widget> | ||
269 | </child> | ||
270 | |||
271 | <child> | ||
272 | <widget class="GtkImageMenuItem" id="license1"> | ||
273 | <property name="visible">True</property> | ||
274 | <property name="label" translatable="yes">_License</property> | ||
275 | <property name="use_underline">True</property> | ||
276 | <signal name="activate" handler="on_license1_activate" last_modification_time="Fri, 15 Nov 2002 20:26:30 GMT"/> | ||
277 | |||
278 | <child internal-child="image"> | ||
279 | <widget class="GtkImage" id="image45"> | ||
280 | <property name="visible">True</property> | ||
281 | <property name="stock">gtk-justify-fill</property> | ||
282 | <property name="icon_size">1</property> | ||
283 | <property name="xalign">0.5</property> | ||
284 | <property name="yalign">0.5</property> | ||
285 | <property name="xpad">0</property> | ||
286 | <property name="ypad">0</property> | ||
287 | </widget> | ||
288 | </child> | ||
289 | </widget> | ||
290 | </child> | ||
291 | </widget> | ||
292 | </child> | ||
293 | </widget> | ||
294 | </child> | ||
295 | </widget> | ||
296 | <packing> | ||
297 | <property name="padding">0</property> | ||
298 | <property name="expand">False</property> | ||
299 | <property name="fill">False</property> | ||
300 | </packing> | ||
301 | </child> | ||
302 | |||
303 | <child> | ||
304 | <widget class="GtkHandleBox" id="handlebox1"> | ||
305 | <property name="visible">True</property> | ||
306 | <property name="shadow_type">GTK_SHADOW_OUT</property> | ||
307 | <property name="handle_position">GTK_POS_LEFT</property> | ||
308 | <property name="snap_edge">GTK_POS_TOP</property> | ||
309 | |||
310 | <child> | ||
311 | <widget class="GtkToolbar" id="toolbar1"> | ||
312 | <property name="visible">True</property> | ||
313 | <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property> | ||
314 | <property name="toolbar_style">GTK_TOOLBAR_BOTH</property> | ||
315 | <property name="tooltips">True</property> | ||
316 | <property name="show_arrow">True</property> | ||
317 | |||
318 | <child> | ||
319 | <widget class="GtkToolButton" id="button1"> | ||
320 | <property name="visible">True</property> | ||
321 | <property name="tooltip" translatable="yes">Goes up of one level (single view)</property> | ||
322 | <property name="label" translatable="yes">Back</property> | ||
323 | <property name="use_underline">True</property> | ||
324 | <property name="stock_id">gtk-undo</property> | ||
325 | <property name="visible_horizontal">True</property> | ||
326 | <property name="visible_vertical">True</property> | ||
327 | <property name="is_important">False</property> | ||
328 | <signal name="clicked" handler="on_back_clicked"/> | ||
329 | </widget> | ||
330 | <packing> | ||
331 | <property name="expand">False</property> | ||
332 | <property name="homogeneous">True</property> | ||
333 | </packing> | ||
334 | </child> | ||
335 | |||
336 | <child> | ||
337 | <widget class="GtkToolItem" id="toolitem1"> | ||
338 | <property name="visible">True</property> | ||
339 | <property name="visible_horizontal">True</property> | ||
340 | <property name="visible_vertical">True</property> | ||
341 | <property name="is_important">False</property> | ||
342 | |||
343 | <child> | ||
344 | <widget class="GtkVSeparator" id="vseparator1"> | ||
345 | <property name="visible">True</property> | ||
346 | </widget> | ||
347 | </child> | ||
348 | </widget> | ||
349 | <packing> | ||
350 | <property name="expand">False</property> | ||
351 | <property name="homogeneous">False</property> | ||
352 | </packing> | ||
353 | </child> | ||
354 | |||
355 | <child> | ||
356 | <widget class="GtkToolButton" id="button2"> | ||
357 | <property name="visible">True</property> | ||
358 | <property name="tooltip" translatable="yes">Load a config file</property> | ||
359 | <property name="label" translatable="yes">Load</property> | ||
360 | <property name="use_underline">True</property> | ||
361 | <property name="stock_id">gtk-open</property> | ||
362 | <property name="visible_horizontal">True</property> | ||
363 | <property name="visible_vertical">True</property> | ||
364 | <property name="is_important">False</property> | ||
365 | <signal name="clicked" handler="on_load_clicked"/> | ||
366 | </widget> | ||
367 | <packing> | ||
368 | <property name="expand">False</property> | ||
369 | <property name="homogeneous">True</property> | ||
370 | </packing> | ||
371 | </child> | ||
372 | |||
373 | <child> | ||
374 | <widget class="GtkToolButton" id="button3"> | ||
375 | <property name="visible">True</property> | ||
376 | <property name="tooltip" translatable="yes">Save a config file</property> | ||
377 | <property name="label" translatable="yes">Save</property> | ||
378 | <property name="use_underline">True</property> | ||
379 | <property name="stock_id">gtk-save</property> | ||
380 | <property name="visible_horizontal">True</property> | ||
381 | <property name="visible_vertical">True</property> | ||
382 | <property name="is_important">False</property> | ||
383 | <signal name="clicked" handler="on_save_clicked"/> | ||
384 | </widget> | ||
385 | <packing> | ||
386 | <property name="expand">False</property> | ||
387 | <property name="homogeneous">True</property> | ||
388 | </packing> | ||
389 | </child> | ||
390 | |||
391 | <child> | ||
392 | <widget class="GtkToolItem" id="toolitem2"> | ||
393 | <property name="visible">True</property> | ||
394 | <property name="visible_horizontal">True</property> | ||
395 | <property name="visible_vertical">True</property> | ||
396 | <property name="is_important">False</property> | ||
397 | |||
398 | <child> | ||
399 | <widget class="GtkVSeparator" id="vseparator2"> | ||
400 | <property name="visible">True</property> | ||
401 | </widget> | ||
402 | </child> | ||
403 | </widget> | ||
404 | <packing> | ||
405 | <property name="expand">False</property> | ||
406 | <property name="homogeneous">False</property> | ||
407 | </packing> | ||
408 | </child> | ||
409 | |||
410 | <child> | ||
411 | <widget class="GtkToolButton" id="button4"> | ||
412 | <property name="visible">True</property> | ||
413 | <property name="tooltip" translatable="yes">Single view</property> | ||
414 | <property name="label" translatable="yes">Single</property> | ||
415 | <property name="use_underline">True</property> | ||
416 | <property name="stock_id">gtk-missing-image</property> | ||
417 | <property name="visible_horizontal">True</property> | ||
418 | <property name="visible_vertical">True</property> | ||
419 | <property name="is_important">False</property> | ||
420 | <signal name="clicked" handler="on_single_clicked" last_modification_time="Sun, 12 Jan 2003 14:28:39 GMT"/> | ||
421 | </widget> | ||
422 | <packing> | ||
423 | <property name="expand">False</property> | ||
424 | <property name="homogeneous">True</property> | ||
425 | </packing> | ||
426 | </child> | ||
427 | |||
428 | <child> | ||
429 | <widget class="GtkToolButton" id="button5"> | ||
430 | <property name="visible">True</property> | ||
431 | <property name="tooltip" translatable="yes">Split view</property> | ||
432 | <property name="label" translatable="yes">Split</property> | ||
433 | <property name="use_underline">True</property> | ||
434 | <property name="stock_id">gtk-missing-image</property> | ||
435 | <property name="visible_horizontal">True</property> | ||
436 | <property name="visible_vertical">True</property> | ||
437 | <property name="is_important">False</property> | ||
438 | <signal name="clicked" handler="on_split_clicked" last_modification_time="Sun, 12 Jan 2003 14:28:45 GMT"/> | ||
439 | </widget> | ||
440 | <packing> | ||
441 | <property name="expand">False</property> | ||
442 | <property name="homogeneous">True</property> | ||
443 | </packing> | ||
444 | </child> | ||
445 | |||
446 | <child> | ||
447 | <widget class="GtkToolButton" id="button6"> | ||
448 | <property name="visible">True</property> | ||
449 | <property name="tooltip" translatable="yes">Full view</property> | ||
450 | <property name="label" translatable="yes">Full</property> | ||
451 | <property name="use_underline">True</property> | ||
452 | <property name="stock_id">gtk-missing-image</property> | ||
453 | <property name="visible_horizontal">True</property> | ||
454 | <property name="visible_vertical">True</property> | ||
455 | <property name="is_important">False</property> | ||
456 | <signal name="clicked" handler="on_full_clicked" last_modification_time="Sun, 12 Jan 2003 14:28:50 GMT"/> | ||
457 | </widget> | ||
458 | <packing> | ||
459 | <property name="expand">False</property> | ||
460 | <property name="homogeneous">True</property> | ||
461 | </packing> | ||
462 | </child> | ||
463 | |||
464 | <child> | ||
465 | <widget class="GtkToolItem" id="toolitem3"> | ||
466 | <property name="visible">True</property> | ||
467 | <property name="visible_horizontal">True</property> | ||
468 | <property name="visible_vertical">True</property> | ||
469 | <property name="is_important">False</property> | ||
470 | |||
471 | <child> | ||
472 | <widget class="GtkVSeparator" id="vseparator3"> | ||
473 | <property name="visible">True</property> | ||
474 | </widget> | ||
475 | </child> | ||
476 | </widget> | ||
477 | <packing> | ||
478 | <property name="expand">False</property> | ||
479 | <property name="homogeneous">False</property> | ||
480 | </packing> | ||
481 | </child> | ||
482 | |||
483 | <child> | ||
484 | <widget class="GtkToolButton" id="button7"> | ||
485 | <property name="visible">True</property> | ||
486 | <property name="tooltip" translatable="yes">Collapse the whole tree in the right frame</property> | ||
487 | <property name="label" translatable="yes">Collapse</property> | ||
488 | <property name="use_underline">True</property> | ||
489 | <property name="stock_id">gtk-remove</property> | ||
490 | <property name="visible_horizontal">True</property> | ||
491 | <property name="visible_vertical">True</property> | ||
492 | <property name="is_important">False</property> | ||
493 | <signal name="clicked" handler="on_collapse_clicked"/> | ||
494 | </widget> | ||
495 | <packing> | ||
496 | <property name="expand">False</property> | ||
497 | <property name="homogeneous">True</property> | ||
498 | </packing> | ||
499 | </child> | ||
500 | |||
501 | <child> | ||
502 | <widget class="GtkToolButton" id="button8"> | ||
503 | <property name="visible">True</property> | ||
504 | <property name="tooltip" translatable="yes">Expand the whole tree in the right frame</property> | ||
505 | <property name="label" translatable="yes">Expand</property> | ||
506 | <property name="use_underline">True</property> | ||
507 | <property name="stock_id">gtk-add</property> | ||
508 | <property name="visible_horizontal">True</property> | ||
509 | <property name="visible_vertical">True</property> | ||
510 | <property name="is_important">False</property> | ||
511 | <signal name="clicked" handler="on_expand_clicked"/> | ||
512 | </widget> | ||
513 | <packing> | ||
514 | <property name="expand">False</property> | ||
515 | <property name="homogeneous">True</property> | ||
516 | </packing> | ||
517 | </child> | ||
518 | </widget> | ||
519 | </child> | ||
520 | </widget> | ||
521 | <packing> | ||
522 | <property name="padding">0</property> | ||
523 | <property name="expand">False</property> | ||
524 | <property name="fill">False</property> | ||
525 | </packing> | ||
526 | </child> | ||
527 | |||
528 | <child> | ||
529 | <widget class="GtkHPaned" id="hpaned1"> | ||
530 | <property name="width_request">1</property> | ||
531 | <property name="visible">True</property> | ||
532 | <property name="can_focus">True</property> | ||
533 | <property name="position">0</property> | ||
534 | |||
535 | <child> | ||
536 | <widget class="GtkScrolledWindow" id="scrolledwindow1"> | ||
537 | <property name="visible">True</property> | ||
538 | <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> | ||
539 | <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> | ||
540 | <property name="shadow_type">GTK_SHADOW_IN</property> | ||
541 | <property name="window_placement">GTK_CORNER_TOP_LEFT</property> | ||
542 | |||
543 | <child> | ||
544 | <widget class="GtkTreeView" id="treeview1"> | ||
545 | <property name="visible">True</property> | ||
546 | <property name="can_focus">True</property> | ||
547 | <property name="headers_visible">True</property> | ||
548 | <property name="rules_hint">False</property> | ||
549 | <property name="reorderable">False</property> | ||
550 | <property name="enable_search">True</property> | ||
551 | <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:58:22 GMT"/> | ||
552 | <signal name="button_press_event" handler="on_treeview1_button_press_event" last_modification_time="Sun, 12 Jan 2003 16:03:52 GMT"/> | ||
553 | <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 16:11:44 GMT"/> | ||
554 | </widget> | ||
555 | </child> | ||
556 | </widget> | ||
557 | <packing> | ||
558 | <property name="shrink">True</property> | ||
559 | <property name="resize">False</property> | ||
560 | </packing> | ||
561 | </child> | ||
562 | |||
563 | <child> | ||
564 | <widget class="GtkVPaned" id="vpaned1"> | ||
565 | <property name="visible">True</property> | ||
566 | <property name="can_focus">True</property> | ||
567 | <property name="position">0</property> | ||
568 | |||
569 | <child> | ||
570 | <widget class="GtkScrolledWindow" id="scrolledwindow2"> | ||
571 | <property name="visible">True</property> | ||
572 | <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> | ||
573 | <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> | ||
574 | <property name="shadow_type">GTK_SHADOW_IN</property> | ||
575 | <property name="window_placement">GTK_CORNER_TOP_LEFT</property> | ||
576 | |||
577 | <child> | ||
578 | <widget class="GtkTreeView" id="treeview2"> | ||
579 | <property name="visible">True</property> | ||
580 | <property name="can_focus">True</property> | ||
581 | <property name="has_focus">True</property> | ||
582 | <property name="headers_visible">True</property> | ||
583 | <property name="rules_hint">False</property> | ||
584 | <property name="reorderable">False</property> | ||
585 | <property name="enable_search">True</property> | ||
586 | <signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:57:55 GMT"/> | ||
587 | <signal name="button_press_event" handler="on_treeview2_button_press_event" last_modification_time="Sun, 12 Jan 2003 15:57:58 GMT"/> | ||
588 | <signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 15:58:01 GMT"/> | ||
589 | </widget> | ||
590 | </child> | ||
591 | </widget> | ||
592 | <packing> | ||
593 | <property name="shrink">True</property> | ||
594 | <property name="resize">False</property> | ||
595 | </packing> | ||
596 | </child> | ||
597 | |||
598 | <child> | ||
599 | <widget class="GtkScrolledWindow" id="scrolledwindow3"> | ||
600 | <property name="visible">True</property> | ||
601 | <property name="hscrollbar_policy">GTK_POLICY_NEVER</property> | ||
602 | <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> | ||
603 | <property name="shadow_type">GTK_SHADOW_IN</property> | ||
604 | <property name="window_placement">GTK_CORNER_TOP_LEFT</property> | ||
605 | |||
606 | <child> | ||
607 | <widget class="GtkTextView" id="textview3"> | ||
608 | <property name="visible">True</property> | ||
609 | <property name="can_focus">True</property> | ||
610 | <property name="editable">False</property> | ||
611 | <property name="overwrite">False</property> | ||
612 | <property name="accepts_tab">True</property> | ||
613 | <property name="justification">GTK_JUSTIFY_LEFT</property> | ||
614 | <property name="wrap_mode">GTK_WRAP_WORD</property> | ||
615 | <property name="cursor_visible">True</property> | ||
616 | <property name="pixels_above_lines">0</property> | ||
617 | <property name="pixels_below_lines">0</property> | ||
618 | <property name="pixels_inside_wrap">0</property> | ||
619 | <property name="left_margin">0</property> | ||
620 | <property name="right_margin">0</property> | ||
621 | <property name="indent">0</property> | ||
622 | <property name="text" translatable="yes">Sorry, no help available for this option yet.</property> | ||
623 | </widget> | ||
624 | </child> | ||
625 | </widget> | ||
626 | <packing> | ||
627 | <property name="shrink">True</property> | ||
628 | <property name="resize">True</property> | ||
629 | </packing> | ||
630 | </child> | ||
631 | </widget> | ||
632 | <packing> | ||
633 | <property name="shrink">True</property> | ||
634 | <property name="resize">True</property> | ||
635 | </packing> | ||
636 | </child> | ||
637 | </widget> | ||
638 | <packing> | ||
639 | <property name="padding">0</property> | ||
640 | <property name="expand">True</property> | ||
641 | <property name="fill">True</property> | ||
642 | </packing> | ||
643 | </child> | ||
644 | </widget> | ||
645 | </child> | ||
646 | </widget> | ||
647 | |||
648 | </glade-interface> | ||
diff --git a/scripts/kconfig/images.c b/scripts/kconfig/images.c new file mode 100644 index 000000000..d4f84bd4a --- /dev/null +++ b/scripts/kconfig/images.c | |||
@@ -0,0 +1,326 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
3 | * Released under the terms of the GNU GPL v2.0. | ||
4 | */ | ||
5 | |||
6 | static const char *xpm_load[] = { | ||
7 | "22 22 5 1", | ||
8 | ". c None", | ||
9 | "# c #000000", | ||
10 | "c c #838100", | ||
11 | "a c #ffff00", | ||
12 | "b c #ffffff", | ||
13 | "......................", | ||
14 | "......................", | ||
15 | "......................", | ||
16 | "............####....#.", | ||
17 | "...........#....##.##.", | ||
18 | "..................###.", | ||
19 | ".................####.", | ||
20 | ".####...........#####.", | ||
21 | "#abab##########.......", | ||
22 | "#babababababab#.......", | ||
23 | "#ababababababa#.......", | ||
24 | "#babababababab#.......", | ||
25 | "#ababab###############", | ||
26 | "#babab##cccccccccccc##", | ||
27 | "#abab##cccccccccccc##.", | ||
28 | "#bab##cccccccccccc##..", | ||
29 | "#ab##cccccccccccc##...", | ||
30 | "#b##cccccccccccc##....", | ||
31 | "###cccccccccccc##.....", | ||
32 | "##cccccccccccc##......", | ||
33 | "###############.......", | ||
34 | "......................"}; | ||
35 | |||
36 | static const char *xpm_save[] = { | ||
37 | "22 22 5 1", | ||
38 | ". c None", | ||
39 | "# c #000000", | ||
40 | "a c #838100", | ||
41 | "b c #c5c2c5", | ||
42 | "c c #cdb6d5", | ||
43 | "......................", | ||
44 | ".####################.", | ||
45 | ".#aa#bbbbbbbbbbbb#bb#.", | ||
46 | ".#aa#bbbbbbbbbbbb#bb#.", | ||
47 | ".#aa#bbbbbbbbbcbb####.", | ||
48 | ".#aa#bbbccbbbbbbb#aa#.", | ||
49 | ".#aa#bbbccbbbbbbb#aa#.", | ||
50 | ".#aa#bbbbbbbbbbbb#aa#.", | ||
51 | ".#aa#bbbbbbbbbbbb#aa#.", | ||
52 | ".#aa#bbbbbbbbbbbb#aa#.", | ||
53 | ".#aa#bbbbbbbbbbbb#aa#.", | ||
54 | ".#aaa############aaa#.", | ||
55 | ".#aaaaaaaaaaaaaaaaaa#.", | ||
56 | ".#aaaaaaaaaaaaaaaaaa#.", | ||
57 | ".#aaa#############aa#.", | ||
58 | ".#aaa#########bbb#aa#.", | ||
59 | ".#aaa#########bbb#aa#.", | ||
60 | ".#aaa#########bbb#aa#.", | ||
61 | ".#aaa#########bbb#aa#.", | ||
62 | ".#aaa#########bbb#aa#.", | ||
63 | "..##################..", | ||
64 | "......................"}; | ||
65 | |||
66 | static const char *xpm_back[] = { | ||
67 | "22 22 3 1", | ||
68 | ". c None", | ||
69 | "# c #000083", | ||
70 | "a c #838183", | ||
71 | "......................", | ||
72 | "......................", | ||
73 | "......................", | ||
74 | "......................", | ||
75 | "......................", | ||
76 | "...........######a....", | ||
77 | "..#......##########...", | ||
78 | "..##...####......##a..", | ||
79 | "..###.###.........##..", | ||
80 | "..######..........##..", | ||
81 | "..#####...........##..", | ||
82 | "..######..........##..", | ||
83 | "..#######.........##..", | ||
84 | "..########.......##a..", | ||
85 | "...............a###...", | ||
86 | "...............###....", | ||
87 | "......................", | ||
88 | "......................", | ||
89 | "......................", | ||
90 | "......................", | ||
91 | "......................", | ||
92 | "......................"}; | ||
93 | |||
94 | static const char *xpm_tree_view[] = { | ||
95 | "22 22 2 1", | ||
96 | ". c None", | ||
97 | "# c #000000", | ||
98 | "......................", | ||
99 | "......................", | ||
100 | "......#...............", | ||
101 | "......#...............", | ||
102 | "......#...............", | ||
103 | "......#...............", | ||
104 | "......#...............", | ||
105 | "......########........", | ||
106 | "......#...............", | ||
107 | "......#...............", | ||
108 | "......#...............", | ||
109 | "......#...............", | ||
110 | "......#...............", | ||
111 | "......########........", | ||
112 | "......#...............", | ||
113 | "......#...............", | ||
114 | "......#...............", | ||
115 | "......#...............", | ||
116 | "......#...............", | ||
117 | "......########........", | ||
118 | "......................", | ||
119 | "......................"}; | ||
120 | |||
121 | static const char *xpm_single_view[] = { | ||
122 | "22 22 2 1", | ||
123 | ". c None", | ||
124 | "# c #000000", | ||
125 | "......................", | ||
126 | "......................", | ||
127 | "..........#...........", | ||
128 | "..........#...........", | ||
129 | "..........#...........", | ||
130 | "..........#...........", | ||
131 | "..........#...........", | ||
132 | "..........#...........", | ||
133 | "..........#...........", | ||
134 | "..........#...........", | ||
135 | "..........#...........", | ||
136 | "..........#...........", | ||
137 | "..........#...........", | ||
138 | "..........#...........", | ||
139 | "..........#...........", | ||
140 | "..........#...........", | ||
141 | "..........#...........", | ||
142 | "..........#...........", | ||
143 | "..........#...........", | ||
144 | "..........#...........", | ||
145 | "......................", | ||
146 | "......................"}; | ||
147 | |||
148 | static const char *xpm_split_view[] = { | ||
149 | "22 22 2 1", | ||
150 | ". c None", | ||
151 | "# c #000000", | ||
152 | "......................", | ||
153 | "......................", | ||
154 | "......#......#........", | ||
155 | "......#......#........", | ||
156 | "......#......#........", | ||
157 | "......#......#........", | ||
158 | "......#......#........", | ||
159 | "......#......#........", | ||
160 | "......#......#........", | ||
161 | "......#......#........", | ||
162 | "......#......#........", | ||
163 | "......#......#........", | ||
164 | "......#......#........", | ||
165 | "......#......#........", | ||
166 | "......#......#........", | ||
167 | "......#......#........", | ||
168 | "......#......#........", | ||
169 | "......#......#........", | ||
170 | "......#......#........", | ||
171 | "......#......#........", | ||
172 | "......................", | ||
173 | "......................"}; | ||
174 | |||
175 | static const char *xpm_symbol_no[] = { | ||
176 | "12 12 2 1", | ||
177 | " c white", | ||
178 | ". c black", | ||
179 | " ", | ||
180 | " .......... ", | ||
181 | " . . ", | ||
182 | " . . ", | ||
183 | " . . ", | ||
184 | " . . ", | ||
185 | " . . ", | ||
186 | " . . ", | ||
187 | " . . ", | ||
188 | " . . ", | ||
189 | " .......... ", | ||
190 | " "}; | ||
191 | |||
192 | static const char *xpm_symbol_mod[] = { | ||
193 | "12 12 2 1", | ||
194 | " c white", | ||
195 | ". c black", | ||
196 | " ", | ||
197 | " .......... ", | ||
198 | " . . ", | ||
199 | " . . ", | ||
200 | " . .. . ", | ||
201 | " . .... . ", | ||
202 | " . .... . ", | ||
203 | " . .. . ", | ||
204 | " . . ", | ||
205 | " . . ", | ||
206 | " .......... ", | ||
207 | " "}; | ||
208 | |||
209 | static const char *xpm_symbol_yes[] = { | ||
210 | "12 12 2 1", | ||
211 | " c white", | ||
212 | ". c black", | ||
213 | " ", | ||
214 | " .......... ", | ||
215 | " . . ", | ||
216 | " . . ", | ||
217 | " . . . ", | ||
218 | " . .. . ", | ||
219 | " . . .. . ", | ||
220 | " . .... . ", | ||
221 | " . .. . ", | ||
222 | " . . ", | ||
223 | " .......... ", | ||
224 | " "}; | ||
225 | |||
226 | static const char *xpm_choice_no[] = { | ||
227 | "12 12 2 1", | ||
228 | " c white", | ||
229 | ". c black", | ||
230 | " ", | ||
231 | " .... ", | ||
232 | " .. .. ", | ||
233 | " . . ", | ||
234 | " . . ", | ||
235 | " . . ", | ||
236 | " . . ", | ||
237 | " . . ", | ||
238 | " . . ", | ||
239 | " .. .. ", | ||
240 | " .... ", | ||
241 | " "}; | ||
242 | |||
243 | static const char *xpm_choice_yes[] = { | ||
244 | "12 12 2 1", | ||
245 | " c white", | ||
246 | ". c black", | ||
247 | " ", | ||
248 | " .... ", | ||
249 | " .. .. ", | ||
250 | " . . ", | ||
251 | " . .. . ", | ||
252 | " . .... . ", | ||
253 | " . .... . ", | ||
254 | " . .. . ", | ||
255 | " . . ", | ||
256 | " .. .. ", | ||
257 | " .... ", | ||
258 | " "}; | ||
259 | |||
260 | static const char *xpm_menu[] = { | ||
261 | "12 12 2 1", | ||
262 | " c white", | ||
263 | ". c black", | ||
264 | " ", | ||
265 | " .......... ", | ||
266 | " . . ", | ||
267 | " . .. . ", | ||
268 | " . .... . ", | ||
269 | " . ...... . ", | ||
270 | " . ...... . ", | ||
271 | " . .... . ", | ||
272 | " . .. . ", | ||
273 | " . . ", | ||
274 | " .......... ", | ||
275 | " "}; | ||
276 | |||
277 | static const char *xpm_menu_inv[] = { | ||
278 | "12 12 2 1", | ||
279 | " c white", | ||
280 | ". c black", | ||
281 | " ", | ||
282 | " .......... ", | ||
283 | " .......... ", | ||
284 | " .. ...... ", | ||
285 | " .. .... ", | ||
286 | " .. .. ", | ||
287 | " .. .. ", | ||
288 | " .. .... ", | ||
289 | " .. ...... ", | ||
290 | " .......... ", | ||
291 | " .......... ", | ||
292 | " "}; | ||
293 | |||
294 | static const char *xpm_menuback[] = { | ||
295 | "12 12 2 1", | ||
296 | " c white", | ||
297 | ". c black", | ||
298 | " ", | ||
299 | " .......... ", | ||
300 | " . . ", | ||
301 | " . .. . ", | ||
302 | " . .... . ", | ||
303 | " . ...... . ", | ||
304 | " . ...... . ", | ||
305 | " . .... . ", | ||
306 | " . .. . ", | ||
307 | " . . ", | ||
308 | " .......... ", | ||
309 | " "}; | ||
310 | |||
311 | static const char *xpm_void[] = { | ||
312 | "12 12 2 1", | ||
313 | " c white", | ||
314 | ". c black", | ||
315 | " ", | ||
316 | " ", | ||
317 | " ", | ||
318 | " ", | ||
319 | " ", | ||
320 | " ", | ||
321 | " ", | ||
322 | " ", | ||
323 | " ", | ||
324 | " ", | ||
325 | " ", | ||
326 | " "}; | ||
diff --git a/scripts/kconfig/kconfig_load.c b/scripts/kconfig/kconfig_load.c new file mode 100644 index 000000000..dbdcaad82 --- /dev/null +++ b/scripts/kconfig/kconfig_load.c | |||
@@ -0,0 +1,35 @@ | |||
1 | #include <dlfcn.h> | ||
2 | #include <stdio.h> | ||
3 | #include <stdlib.h> | ||
4 | |||
5 | #include "lkc.h" | ||
6 | |||
7 | #define P(name,type,arg) type (*name ## _p) arg | ||
8 | #include "lkc_proto.h" | ||
9 | #undef P | ||
10 | |||
11 | void kconfig_load(void) | ||
12 | { | ||
13 | void *handle; | ||
14 | char *error; | ||
15 | |||
16 | handle = dlopen("./libkconfig.so", RTLD_LAZY); | ||
17 | if (!handle) { | ||
18 | handle = dlopen("./scripts/kconfig/libkconfig.so", RTLD_LAZY); | ||
19 | if (!handle) { | ||
20 | fprintf(stderr, "%s\n", dlerror()); | ||
21 | exit(1); | ||
22 | } | ||
23 | } | ||
24 | |||
25 | #define P(name,type,arg) \ | ||
26 | { \ | ||
27 | name ## _p = dlsym(handle, #name); \ | ||
28 | if ((error = dlerror())) { \ | ||
29 | fprintf(stderr, "%s\n", error); \ | ||
30 | exit(1); \ | ||
31 | } \ | ||
32 | } | ||
33 | #include "lkc_proto.h" | ||
34 | #undef P | ||
35 | } | ||
diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c new file mode 100644 index 000000000..abee55ca6 --- /dev/null +++ b/scripts/kconfig/kxgettext.c | |||
@@ -0,0 +1,227 @@ | |||
1 | /* | ||
2 | * Arnaldo Carvalho de Melo <acme@conectiva.com.br>, 2005 | ||
3 | * | ||
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 | |||
13 | static char *escape(const char* text, char *bf, int len) | ||
14 | { | ||
15 | char *bfp = bf; | ||
16 | int multiline = strchr(text, '\n') != NULL; | ||
17 | int eol = 0; | ||
18 | int textlen = strlen(text); | ||
19 | |||
20 | if ((textlen > 0) && (text[textlen-1] == '\n')) | ||
21 | eol = 1; | ||
22 | |||
23 | *bfp++ = '"'; | ||
24 | --len; | ||
25 | |||
26 | if (multiline) { | ||
27 | *bfp++ = '"'; | ||
28 | *bfp++ = '\n'; | ||
29 | *bfp++ = '"'; | ||
30 | len -= 3; | ||
31 | } | ||
32 | |||
33 | while (*text != '\0' && len > 1) { | ||
34 | if (*text == '"') | ||
35 | *bfp++ = '\\'; | ||
36 | else if (*text == '\n') { | ||
37 | *bfp++ = '\\'; | ||
38 | *bfp++ = 'n'; | ||
39 | *bfp++ = '"'; | ||
40 | *bfp++ = '\n'; | ||
41 | *bfp++ = '"'; | ||
42 | len -= 5; | ||
43 | ++text; | ||
44 | goto next; | ||
45 | } | ||
46 | *bfp++ = *text++; | ||
47 | next: | ||
48 | --len; | ||
49 | } | ||
50 | |||
51 | if (multiline && eol) | ||
52 | bfp -= 3; | ||
53 | |||
54 | *bfp++ = '"'; | ||
55 | *bfp = '\0'; | ||
56 | |||
57 | return bf; | ||
58 | } | ||
59 | |||
60 | struct file_line { | ||
61 | struct file_line *next; | ||
62 | char* file; | ||
63 | int lineno; | ||
64 | }; | ||
65 | |||
66 | static struct file_line *file_line__new(char *file, int lineno) | ||
67 | { | ||
68 | struct file_line *self = malloc(sizeof(*self)); | ||
69 | |||
70 | if (self == NULL) | ||
71 | goto out; | ||
72 | |||
73 | self->file = file; | ||
74 | self->lineno = lineno; | ||
75 | self->next = NULL; | ||
76 | out: | ||
77 | return self; | ||
78 | } | ||
79 | |||
80 | struct message { | ||
81 | const char *msg; | ||
82 | const char *option; | ||
83 | struct message *next; | ||
84 | struct file_line *files; | ||
85 | }; | ||
86 | |||
87 | static struct message *message__list; | ||
88 | |||
89 | static struct message *message__new(const char *msg, char *option, char *file, int lineno) | ||
90 | { | ||
91 | struct message *self = malloc(sizeof(*self)); | ||
92 | |||
93 | if (self == NULL) | ||
94 | goto out; | ||
95 | |||
96 | self->files = file_line__new(file, lineno); | ||
97 | if (self->files == NULL) | ||
98 | goto out_fail; | ||
99 | |||
100 | self->msg = strdup(msg); | ||
101 | if (self->msg == NULL) | ||
102 | goto out_fail_msg; | ||
103 | |||
104 | self->option = option; | ||
105 | self->next = NULL; | ||
106 | out: | ||
107 | return self; | ||
108 | out_fail_msg: | ||
109 | free(self->files); | ||
110 | out_fail: | ||
111 | free(self); | ||
112 | self = NULL; | ||
113 | goto out; | ||
114 | } | ||
115 | |||
116 | static struct message *mesage__find(const char *msg) | ||
117 | { | ||
118 | struct message *m = message__list; | ||
119 | |||
120 | while (m != NULL) { | ||
121 | if (strcmp(m->msg, msg) == 0) | ||
122 | break; | ||
123 | m = m->next; | ||
124 | } | ||
125 | |||
126 | return m; | ||
127 | } | ||
128 | |||
129 | static int message__add_file_line(struct message *self, char *file, int lineno) | ||
130 | { | ||
131 | int rc = -1; | ||
132 | struct file_line *fl = file_line__new(file, lineno); | ||
133 | |||
134 | if (fl == NULL) | ||
135 | goto out; | ||
136 | |||
137 | fl->next = self->files; | ||
138 | self->files = fl; | ||
139 | rc = 0; | ||
140 | out: | ||
141 | return rc; | ||
142 | } | ||
143 | |||
144 | static int message__add(const char *msg, char *option, char *file, int lineno) | ||
145 | { | ||
146 | int rc = 0; | ||
147 | char bf[16384]; | ||
148 | char *escaped = escape(msg, bf, sizeof(bf)); | ||
149 | struct message *m = mesage__find(escaped); | ||
150 | |||
151 | if (m != NULL) | ||
152 | rc = message__add_file_line(m, file, lineno); | ||
153 | else { | ||
154 | m = message__new(escaped, option, file, lineno); | ||
155 | |||
156 | if (m != NULL) { | ||
157 | m->next = message__list; | ||
158 | message__list = m; | ||
159 | } else | ||
160 | rc = -1; | ||
161 | } | ||
162 | return rc; | ||
163 | } | ||
164 | |||
165 | void menu_build_message_list(struct menu *menu) | ||
166 | { | ||
167 | struct menu *child; | ||
168 | |||
169 | message__add(menu_get_prompt(menu), NULL, | ||
170 | menu->file == NULL ? "Root Menu" : menu->file->name, | ||
171 | menu->lineno); | ||
172 | |||
173 | if (menu->sym != NULL && menu->sym->help != NULL) | ||
174 | message__add(menu->sym->help, menu->sym->name, | ||
175 | menu->file == NULL ? "Root Menu" : menu->file->name, | ||
176 | menu->lineno); | ||
177 | |||
178 | for (child = menu->list; child != NULL; child = child->next) | ||
179 | if (child->prompt != NULL) | ||
180 | menu_build_message_list(child); | ||
181 | } | ||
182 | |||
183 | static void message__print_file_lineno(struct message *self) | ||
184 | { | ||
185 | struct file_line *fl = self->files; | ||
186 | |||
187 | putchar('\n'); | ||
188 | if (self->option != NULL) | ||
189 | printf("# %s:00000\n", self->option); | ||
190 | |||
191 | printf("#: %s:%d", fl->file, fl->lineno); | ||
192 | fl = fl->next; | ||
193 | |||
194 | while (fl != NULL) { | ||
195 | printf(", %s:%d", fl->file, fl->lineno); | ||
196 | fl = fl->next; | ||
197 | } | ||
198 | |||
199 | putchar('\n'); | ||
200 | } | ||
201 | |||
202 | static void message__print_gettext_msgid_msgstr(struct message *self) | ||
203 | { | ||
204 | message__print_file_lineno(self); | ||
205 | |||
206 | printf("msgid %s\n" | ||
207 | "msgstr \"\"\n", self->msg); | ||
208 | } | ||
209 | |||
210 | void menu__xgettext(void) | ||
211 | { | ||
212 | struct message *m = message__list; | ||
213 | |||
214 | while (m != NULL) { | ||
215 | message__print_gettext_msgid_msgstr(m); | ||
216 | m = m->next; | ||
217 | } | ||
218 | } | ||
219 | |||
220 | int main(int ac, char **av) | ||
221 | { | ||
222 | conf_parse(av[1]); | ||
223 | |||
224 | menu_build_message_list(menu_get_root_menu(NULL)); | ||
225 | menu__xgettext(); | ||
226 | return 0; | ||
227 | } | ||
diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped new file mode 100644 index 000000000..24e3c8cbb --- /dev/null +++ b/scripts/kconfig/lex.zconf.c_shipped | |||
@@ -0,0 +1,2317 @@ | |||
1 | |||
2 | #line 3 "scripts/kconfig/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> | ||
35 | typedef int8_t flex_int8_t; | ||
36 | typedef uint8_t flex_uint8_t; | ||
37 | typedef int16_t flex_int16_t; | ||
38 | typedef uint16_t flex_uint16_t; | ||
39 | typedef int32_t flex_int32_t; | ||
40 | typedef uint32_t flex_uint32_t; | ||
41 | #else | ||
42 | typedef signed char flex_int8_t; | ||
43 | typedef short int flex_int16_t; | ||
44 | typedef int flex_int32_t; | ||
45 | typedef unsigned char flex_uint8_t; | ||
46 | typedef unsigned short int flex_uint16_t; | ||
47 | typedef 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 | ||
139 | typedef struct yy_buffer_state *YY_BUFFER_STATE; | ||
140 | #endif | ||
141 | |||
142 | extern int zconfleng; | ||
143 | |||
144 | extern 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 | ||
175 | typedef unsigned int yy_size_t; | ||
176 | #endif | ||
177 | |||
178 | #ifndef YY_STRUCT_YY_BUFFER_STATE | ||
179 | #define YY_STRUCT_YY_BUFFER_STATE | ||
180 | struct 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. */ | ||
244 | static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ | ||
245 | static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ | ||
246 | static 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. */ | ||
264 | static char yy_hold_char; | ||
265 | static int yy_n_chars; /* number of characters read into yy_ch_buf */ | ||
266 | int zconfleng; | ||
267 | |||
268 | /* Points to current character in buffer. */ | ||
269 | static char *yy_c_buf_p = (char *) 0; | ||
270 | static int yy_init = 1; /* whether we need to initialize */ | ||
271 | static 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 | */ | ||
276 | static int yy_did_buffer_switch_on_eof; | ||
277 | |||
278 | void zconfrestart (FILE *input_file ); | ||
279 | void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ); | ||
280 | YY_BUFFER_STATE zconf_create_buffer (FILE *file,int size ); | ||
281 | void zconf_delete_buffer (YY_BUFFER_STATE b ); | ||
282 | void zconf_flush_buffer (YY_BUFFER_STATE b ); | ||
283 | void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ); | ||
284 | void zconfpop_buffer_state (void ); | ||
285 | |||
286 | static void zconfensure_buffer_stack (void ); | ||
287 | static void zconf_load_buffer_state (void ); | ||
288 | static void zconf_init_buffer (YY_BUFFER_STATE b,FILE *file ); | ||
289 | |||
290 | #define YY_FLUSH_BUFFER zconf_flush_buffer(YY_CURRENT_BUFFER ) | ||
291 | |||
292 | YY_BUFFER_STATE zconf_scan_buffer (char *base,yy_size_t size ); | ||
293 | YY_BUFFER_STATE zconf_scan_string (yyconst char *yy_str ); | ||
294 | YY_BUFFER_STATE zconf_scan_bytes (yyconst char *bytes,int len ); | ||
295 | |||
296 | void *zconfalloc (yy_size_t ); | ||
297 | void *zconfrealloc (void *,yy_size_t ); | ||
298 | void 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() 1 | ||
327 | #define YY_SKIP_YYWRAP | ||
328 | |||
329 | typedef unsigned char YY_CHAR; | ||
330 | |||
331 | FILE *zconfin = (FILE *) 0, *zconfout = (FILE *) 0; | ||
332 | |||
333 | typedef int yy_state_type; | ||
334 | |||
335 | extern int zconflineno; | ||
336 | |||
337 | int zconflineno = 1; | ||
338 | |||
339 | extern char *zconftext; | ||
340 | #define yytext_ptr zconftext | ||
341 | static yyconst flex_int16_t yy_nxt[][17] = | ||
342 | { | ||
343 | { | ||
344 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
345 | 0, 0, 0, 0, 0, 0, 0 | ||
346 | }, | ||
347 | |||
348 | { | ||
349 | 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, | ||
350 | 12, 12, 12, 12, 12, 12, 12 | ||
351 | }, | ||
352 | |||
353 | { | ||
354 | 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, | ||
355 | 12, 12, 12, 12, 12, 12, 12 | ||
356 | }, | ||
357 | |||
358 | { | ||
359 | 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, | ||
360 | 16, 16, 16, 18, 16, 16, 16 | ||
361 | }, | ||
362 | |||
363 | { | ||
364 | 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, | ||
365 | 16, 16, 16, 18, 16, 16, 16 | ||
366 | |||
367 | }, | ||
368 | |||
369 | { | ||
370 | 11, 19, 20, 21, 19, 19, 19, 19, 19, 19, | ||
371 | 19, 19, 19, 19, 19, 19, 19 | ||
372 | }, | ||
373 | |||
374 | { | ||
375 | 11, 19, 20, 21, 19, 19, 19, 19, 19, 19, | ||
376 | 19, 19, 19, 19, 19, 19, 19 | ||
377 | }, | ||
378 | |||
379 | { | ||
380 | 11, 22, 22, 23, 22, 24, 22, 22, 24, 22, | ||
381 | 22, 22, 22, 22, 22, 25, 22 | ||
382 | }, | ||
383 | |||
384 | { | ||
385 | 11, 22, 22, 23, 22, 24, 22, 22, 24, 22, | ||
386 | 22, 22, 22, 22, 22, 25, 22 | ||
387 | }, | ||
388 | |||
389 | { | ||
390 | 11, 26, 26, 27, 28, 29, 30, 31, 29, 32, | ||
391 | 33, 34, 35, 35, 36, 37, 38 | ||
392 | |||
393 | }, | ||
394 | |||
395 | { | ||
396 | 11, 26, 26, 27, 28, 29, 30, 31, 29, 32, | ||
397 | 33, 34, 35, 35, 36, 37, 38 | ||
398 | }, | ||
399 | |||
400 | { | ||
401 | -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, | ||
402 | -11, -11, -11, -11, -11, -11, -11 | ||
403 | }, | ||
404 | |||
405 | { | ||
406 | 11, -12, -12, -12, -12, -12, -12, -12, -12, -12, | ||
407 | -12, -12, -12, -12, -12, -12, -12 | ||
408 | }, | ||
409 | |||
410 | { | ||
411 | 11, -13, 39, 40, -13, -13, 41, -13, -13, -13, | ||
412 | -13, -13, -13, -13, -13, -13, -13 | ||
413 | }, | ||
414 | |||
415 | { | ||
416 | 11, -14, -14, -14, -14, -14, -14, -14, -14, -14, | ||
417 | -14, -14, -14, -14, -14, -14, -14 | ||
418 | |||
419 | }, | ||
420 | |||
421 | { | ||
422 | 11, 42, 42, 43, 42, 42, 42, 42, 42, 42, | ||
423 | 42, 42, 42, 42, 42, 42, 42 | ||
424 | }, | ||
425 | |||
426 | { | ||
427 | 11, -16, -16, -16, -16, -16, -16, -16, -16, -16, | ||
428 | -16, -16, -16, -16, -16, -16, -16 | ||
429 | }, | ||
430 | |||
431 | { | ||
432 | 11, -17, -17, -17, -17, -17, -17, -17, -17, -17, | ||
433 | -17, -17, -17, -17, -17, -17, -17 | ||
434 | }, | ||
435 | |||
436 | { | ||
437 | 11, -18, -18, -18, -18, -18, -18, -18, -18, -18, | ||
438 | -18, -18, -18, 44, -18, -18, -18 | ||
439 | }, | ||
440 | |||
441 | { | ||
442 | 11, 45, 45, -19, 45, 45, 45, 45, 45, 45, | ||
443 | 45, 45, 45, 45, 45, 45, 45 | ||
444 | |||
445 | }, | ||
446 | |||
447 | { | ||
448 | 11, -20, 46, 47, -20, -20, -20, -20, -20, -20, | ||
449 | -20, -20, -20, -20, -20, -20, -20 | ||
450 | }, | ||
451 | |||
452 | { | ||
453 | 11, 48, -21, -21, 48, 48, 48, 48, 48, 48, | ||
454 | 48, 48, 48, 48, 48, 48, 48 | ||
455 | }, | ||
456 | |||
457 | { | ||
458 | 11, 49, 49, 50, 49, -22, 49, 49, -22, 49, | ||
459 | 49, 49, 49, 49, 49, -22, 49 | ||
460 | }, | ||
461 | |||
462 | { | ||
463 | 11, -23, -23, -23, -23, -23, -23, -23, -23, -23, | ||
464 | -23, -23, -23, -23, -23, -23, -23 | ||
465 | }, | ||
466 | |||
467 | { | ||
468 | 11, -24, -24, -24, -24, -24, -24, -24, -24, -24, | ||
469 | -24, -24, -24, -24, -24, -24, -24 | ||
470 | |||
471 | }, | ||
472 | |||
473 | { | ||
474 | 11, 51, 51, 52, 51, 51, 51, 51, 51, 51, | ||
475 | 51, 51, 51, 51, 51, 51, 51 | ||
476 | }, | ||
477 | |||
478 | { | ||
479 | 11, -26, -26, -26, -26, -26, -26, -26, -26, -26, | ||
480 | -26, -26, -26, -26, -26, -26, -26 | ||
481 | }, | ||
482 | |||
483 | { | ||
484 | 11, -27, -27, -27, -27, -27, -27, -27, -27, -27, | ||
485 | -27, -27, -27, -27, -27, -27, -27 | ||
486 | }, | ||
487 | |||
488 | { | ||
489 | 11, -28, -28, -28, -28, -28, -28, -28, -28, -28, | ||
490 | -28, -28, -28, -28, 53, -28, -28 | ||
491 | }, | ||
492 | |||
493 | { | ||
494 | 11, -29, -29, -29, -29, -29, -29, -29, -29, -29, | ||
495 | -29, -29, -29, -29, -29, -29, -29 | ||
496 | |||
497 | }, | ||
498 | |||
499 | { | ||
500 | 11, 54, 54, -30, 54, 54, 54, 54, 54, 54, | ||
501 | 54, 54, 54, 54, 54, 54, 54 | ||
502 | }, | ||
503 | |||
504 | { | ||
505 | 11, -31, -31, -31, -31, -31, -31, 55, -31, -31, | ||
506 | -31, -31, -31, -31, -31, -31, -31 | ||
507 | }, | ||
508 | |||
509 | { | ||
510 | 11, -32, -32, -32, -32, -32, -32, -32, -32, -32, | ||
511 | -32, -32, -32, -32, -32, -32, -32 | ||
512 | }, | ||
513 | |||
514 | { | ||
515 | 11, -33, -33, -33, -33, -33, -33, -33, -33, -33, | ||
516 | -33, -33, -33, -33, -33, -33, -33 | ||
517 | }, | ||
518 | |||
519 | { | ||
520 | 11, -34, -34, -34, -34, -34, -34, -34, -34, -34, | ||
521 | -34, 56, 57, 57, -34, -34, -34 | ||
522 | |||
523 | }, | ||
524 | |||
525 | { | ||
526 | 11, -35, -35, -35, -35, -35, -35, -35, -35, -35, | ||
527 | -35, 57, 57, 57, -35, -35, -35 | ||
528 | }, | ||
529 | |||
530 | { | ||
531 | 11, -36, -36, -36, -36, -36, -36, -36, -36, -36, | ||
532 | -36, -36, -36, -36, -36, -36, -36 | ||
533 | }, | ||
534 | |||
535 | { | ||
536 | 11, -37, -37, 58, -37, -37, -37, -37, -37, -37, | ||
537 | -37, -37, -37, -37, -37, -37, -37 | ||
538 | }, | ||
539 | |||
540 | { | ||
541 | 11, -38, -38, -38, -38, -38, -38, -38, -38, -38, | ||
542 | -38, -38, -38, -38, -38, -38, 59 | ||
543 | }, | ||
544 | |||
545 | { | ||
546 | 11, -39, 39, 40, -39, -39, 41, -39, -39, -39, | ||
547 | -39, -39, -39, -39, -39, -39, -39 | ||
548 | |||
549 | }, | ||
550 | |||
551 | { | ||
552 | 11, -40, -40, -40, -40, -40, -40, -40, -40, -40, | ||
553 | -40, -40, -40, -40, -40, -40, -40 | ||
554 | }, | ||
555 | |||
556 | { | ||
557 | 11, 42, 42, 43, 42, 42, 42, 42, 42, 42, | ||
558 | 42, 42, 42, 42, 42, 42, 42 | ||
559 | }, | ||
560 | |||
561 | { | ||
562 | 11, 42, 42, 43, 42, 42, 42, 42, 42, 42, | ||
563 | 42, 42, 42, 42, 42, 42, 42 | ||
564 | }, | ||
565 | |||
566 | { | ||
567 | 11, -43, -43, -43, -43, -43, -43, -43, -43, -43, | ||
568 | -43, -43, -43, -43, -43, -43, -43 | ||
569 | }, | ||
570 | |||
571 | { | ||
572 | 11, -44, -44, -44, -44, -44, -44, -44, -44, -44, | ||
573 | -44, -44, -44, 44, -44, -44, -44 | ||
574 | |||
575 | }, | ||
576 | |||
577 | { | ||
578 | 11, 45, 45, -45, 45, 45, 45, 45, 45, 45, | ||
579 | 45, 45, 45, 45, 45, 45, 45 | ||
580 | }, | ||
581 | |||
582 | { | ||
583 | 11, -46, 46, 47, -46, -46, -46, -46, -46, -46, | ||
584 | -46, -46, -46, -46, -46, -46, -46 | ||
585 | }, | ||
586 | |||
587 | { | ||
588 | 11, 48, -47, -47, 48, 48, 48, 48, 48, 48, | ||
589 | 48, 48, 48, 48, 48, 48, 48 | ||
590 | }, | ||
591 | |||
592 | { | ||
593 | 11, -48, -48, -48, -48, -48, -48, -48, -48, -48, | ||
594 | -48, -48, -48, -48, -48, -48, -48 | ||
595 | }, | ||
596 | |||
597 | { | ||
598 | 11, 49, 49, 50, 49, -49, 49, 49, -49, 49, | ||
599 | 49, 49, 49, 49, 49, -49, 49 | ||
600 | |||
601 | }, | ||
602 | |||
603 | { | ||
604 | 11, -50, -50, -50, -50, -50, -50, -50, -50, -50, | ||
605 | -50, -50, -50, -50, -50, -50, -50 | ||
606 | }, | ||
607 | |||
608 | { | ||
609 | 11, -51, -51, 52, -51, -51, -51, -51, -51, -51, | ||
610 | -51, -51, -51, -51, -51, -51, -51 | ||
611 | }, | ||
612 | |||
613 | { | ||
614 | 11, -52, -52, -52, -52, -52, -52, -52, -52, -52, | ||
615 | -52, -52, -52, -52, -52, -52, -52 | ||
616 | }, | ||
617 | |||
618 | { | ||
619 | 11, -53, -53, -53, -53, -53, -53, -53, -53, -53, | ||
620 | -53, -53, -53, -53, -53, -53, -53 | ||
621 | }, | ||
622 | |||
623 | { | ||
624 | 11, 54, 54, -54, 54, 54, 54, 54, 54, 54, | ||
625 | 54, 54, 54, 54, 54, 54, 54 | ||
626 | |||
627 | }, | ||
628 | |||
629 | { | ||
630 | 11, -55, -55, -55, -55, -55, -55, -55, -55, -55, | ||
631 | -55, -55, -55, -55, -55, -55, -55 | ||
632 | }, | ||
633 | |||
634 | { | ||
635 | 11, -56, -56, -56, -56, -56, -56, -56, -56, -56, | ||
636 | -56, 60, 57, 57, -56, -56, -56 | ||
637 | }, | ||
638 | |||
639 | { | ||
640 | 11, -57, -57, -57, -57, -57, -57, -57, -57, -57, | ||
641 | -57, 57, 57, 57, -57, -57, -57 | ||
642 | }, | ||
643 | |||
644 | { | ||
645 | 11, -58, -58, -58, -58, -58, -58, -58, -58, -58, | ||
646 | -58, -58, -58, -58, -58, -58, -58 | ||
647 | }, | ||
648 | |||
649 | { | ||
650 | 11, -59, -59, -59, -59, -59, -59, -59, -59, -59, | ||
651 | -59, -59, -59, -59, -59, -59, -59 | ||
652 | |||
653 | }, | ||
654 | |||
655 | { | ||
656 | 11, -60, -60, -60, -60, -60, -60, -60, -60, -60, | ||
657 | -60, 57, 57, 57, -60, -60, -60 | ||
658 | }, | ||
659 | |||
660 | } ; | ||
661 | |||
662 | static yy_state_type yy_get_previous_state (void ); | ||
663 | static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); | ||
664 | static int yy_get_next_buffer (void ); | ||
665 | static void yy_fatal_error (yyconst char msg[] ); | ||
666 | |||
667 | /* Done after the current pattern has been matched and before the | ||
668 | * corresponding action - sets up zconftext. | ||
669 | */ | ||
670 | #define YY_DO_BEFORE_ACTION \ | ||
671 | (yytext_ptr) = yy_bp; \ | ||
672 | zconfleng = (size_t) (yy_cp - yy_bp); \ | ||
673 | (yy_hold_char) = *yy_cp; \ | ||
674 | *yy_cp = '\0'; \ | ||
675 | (yy_c_buf_p) = yy_cp; | ||
676 | |||
677 | #define YY_NUM_RULES 33 | ||
678 | #define YY_END_OF_BUFFER 34 | ||
679 | /* This struct is not used in this scanner, | ||
680 | but its presence is necessary. */ | ||
681 | struct yy_trans_info | ||
682 | { | ||
683 | flex_int32_t yy_verify; | ||
684 | flex_int32_t yy_nxt; | ||
685 | }; | ||
686 | static yyconst flex_int16_t yy_accept[61] = | ||
687 | { 0, | ||
688 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
689 | 34, 5, 4, 2, 3, 7, 8, 6, 32, 29, | ||
690 | 31, 24, 28, 27, 26, 22, 17, 13, 16, 20, | ||
691 | 22, 11, 12, 19, 19, 14, 22, 22, 4, 2, | ||
692 | 3, 3, 1, 6, 32, 29, 31, 30, 24, 23, | ||
693 | 26, 25, 15, 20, 9, 19, 19, 21, 10, 18 | ||
694 | } ; | ||
695 | |||
696 | static yyconst flex_int32_t yy_ec[256] = | ||
697 | { 0, | ||
698 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, | ||
699 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
700 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
701 | 1, 2, 4, 5, 6, 1, 1, 7, 8, 9, | ||
702 | 10, 1, 1, 1, 11, 12, 12, 13, 13, 13, | ||
703 | 13, 13, 13, 13, 13, 13, 13, 1, 1, 1, | ||
704 | 14, 1, 1, 1, 13, 13, 13, 13, 13, 13, | ||
705 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, | ||
706 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, | ||
707 | 1, 15, 1, 1, 13, 1, 13, 13, 13, 13, | ||
708 | |||
709 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, | ||
710 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, | ||
711 | 13, 13, 1, 16, 1, 1, 1, 1, 1, 1, | ||
712 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
713 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
714 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
715 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
716 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
717 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
718 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
719 | |||
720 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
721 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
722 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
723 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
724 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
725 | 1, 1, 1, 1, 1 | ||
726 | } ; | ||
727 | |||
728 | extern int zconf_flex_debug; | ||
729 | int zconf_flex_debug = 0; | ||
730 | |||
731 | /* The intent behind this definition is that it'll catch | ||
732 | * any uses of REJECT which flex missed. | ||
733 | */ | ||
734 | #define REJECT reject_used_but_not_detected | ||
735 | #define yymore() yymore_used_but_not_detected | ||
736 | #define YY_MORE_ADJ 0 | ||
737 | #define YY_RESTORE_YY_MORE_OFFSET | ||
738 | char *zconftext; | ||
739 | |||
740 | /* | ||
741 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
742 | * Released under the terms of the GNU GPL v2.0. | ||
743 | */ | ||
744 | |||
745 | #include <limits.h> | ||
746 | #include <stdio.h> | ||
747 | #include <stdlib.h> | ||
748 | #include <string.h> | ||
749 | #include <unistd.h> | ||
750 | |||
751 | #define LKC_DIRECT_LINK | ||
752 | #include "lkc.h" | ||
753 | |||
754 | #define START_STRSIZE 16 | ||
755 | |||
756 | static struct { | ||
757 | struct file *file; | ||
758 | int lineno; | ||
759 | } current_pos; | ||
760 | |||
761 | static char *text; | ||
762 | static int text_size, text_asize; | ||
763 | |||
764 | struct buffer { | ||
765 | struct buffer *parent; | ||
766 | YY_BUFFER_STATE state; | ||
767 | }; | ||
768 | |||
769 | struct buffer *current_buf; | ||
770 | |||
771 | static int last_ts, first_ts; | ||
772 | |||
773 | static void zconf_endhelp(void); | ||
774 | static void zconf_endfile(void); | ||
775 | |||
776 | void new_string(void) | ||
777 | { | ||
778 | text = malloc(START_STRSIZE); | ||
779 | text_asize = START_STRSIZE; | ||
780 | text_size = 0; | ||
781 | *text = 0; | ||
782 | } | ||
783 | |||
784 | void append_string(const char *str, int size) | ||
785 | { | ||
786 | int new_size = text_size + size + 1; | ||
787 | if (new_size > text_asize) { | ||
788 | new_size += START_STRSIZE - 1; | ||
789 | new_size &= -START_STRSIZE; | ||
790 | text = realloc(text, new_size); | ||
791 | text_asize = new_size; | ||
792 | } | ||
793 | memcpy(text + text_size, str, size); | ||
794 | text_size += size; | ||
795 | text[text_size] = 0; | ||
796 | } | ||
797 | |||
798 | void alloc_string(const char *str, int size) | ||
799 | { | ||
800 | text = malloc(size + 1); | ||
801 | memcpy(text, str, size); | ||
802 | text[size] = 0; | ||
803 | } | ||
804 | |||
805 | #define INITIAL 0 | ||
806 | #define COMMAND 1 | ||
807 | #define HELP 2 | ||
808 | #define STRING 3 | ||
809 | #define PARAM 4 | ||
810 | |||
811 | #ifndef YY_NO_UNISTD_H | ||
812 | /* Special case for "unistd.h", since it is non-ANSI. We include it way | ||
813 | * down here because we want the user's section 1 to have been scanned first. | ||
814 | * The user has a chance to override it with an option. | ||
815 | */ | ||
816 | #include <unistd.h> | ||
817 | #endif | ||
818 | |||
819 | #ifndef YY_EXTRA_TYPE | ||
820 | #define YY_EXTRA_TYPE void * | ||
821 | #endif | ||
822 | |||
823 | /* Macros after this point can all be overridden by user definitions in | ||
824 | * section 1. | ||
825 | */ | ||
826 | |||
827 | #ifndef YY_SKIP_YYWRAP | ||
828 | #ifdef __cplusplus | ||
829 | extern "C" int zconfwrap (void ); | ||
830 | #else | ||
831 | extern int zconfwrap (void ); | ||
832 | #endif | ||
833 | #endif | ||
834 | |||
835 | static void yyunput (int c,char *buf_ptr ); | ||
836 | |||
837 | #ifndef yytext_ptr | ||
838 | static void yy_flex_strncpy (char *,yyconst char *,int ); | ||
839 | #endif | ||
840 | |||
841 | #ifdef YY_NEED_STRLEN | ||
842 | static int yy_flex_strlen (yyconst char * ); | ||
843 | #endif | ||
844 | |||
845 | #ifndef YY_NO_INPUT | ||
846 | |||
847 | #ifdef __cplusplus | ||
848 | static int yyinput (void ); | ||
849 | #else | ||
850 | static int input (void ); | ||
851 | #endif | ||
852 | |||
853 | #endif | ||
854 | |||
855 | /* Amount of stuff to slurp up with each read. */ | ||
856 | #ifndef YY_READ_BUF_SIZE | ||
857 | #define YY_READ_BUF_SIZE 8192 | ||
858 | #endif | ||
859 | |||
860 | /* Copy whatever the last rule matched to the standard output. */ | ||
861 | #ifndef ECHO | ||
862 | /* This used to be an fputs(), but since the string might contain NUL's, | ||
863 | * we now use fwrite(). | ||
864 | */ | ||
865 | #define ECHO (void) fwrite( zconftext, zconfleng, 1, zconfout ) | ||
866 | #endif | ||
867 | |||
868 | /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, | ||
869 | * is returned in "result". | ||
870 | */ | ||
871 | #ifndef YY_INPUT | ||
872 | #define YY_INPUT(buf,result,max_size) \ | ||
873 | errno=0; \ | ||
874 | while ( (result = read( fileno(zconfin), (char *) buf, max_size )) < 0 ) \ | ||
875 | { \ | ||
876 | if( errno != EINTR) \ | ||
877 | { \ | ||
878 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ | ||
879 | break; \ | ||
880 | } \ | ||
881 | errno=0; \ | ||
882 | clearerr(zconfin); \ | ||
883 | }\ | ||
884 | \ | ||
885 | |||
886 | #endif | ||
887 | |||
888 | /* No semi-colon after return; correct usage is to write "yyterminate();" - | ||
889 | * we don't want an extra ';' after the "return" because that will cause | ||
890 | * some compilers to complain about unreachable statements. | ||
891 | */ | ||
892 | #ifndef yyterminate | ||
893 | #define yyterminate() return YY_NULL | ||
894 | #endif | ||
895 | |||
896 | /* Number of entries by which start-condition stack grows. */ | ||
897 | #ifndef YY_START_STACK_INCR | ||
898 | #define YY_START_STACK_INCR 25 | ||
899 | #endif | ||
900 | |||
901 | /* Report a fatal error. */ | ||
902 | #ifndef YY_FATAL_ERROR | ||
903 | #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) | ||
904 | #endif | ||
905 | |||
906 | /* end tables serialization structures and prototypes */ | ||
907 | |||
908 | /* Default declaration of generated scanner - a define so the user can | ||
909 | * easily add parameters. | ||
910 | */ | ||
911 | #ifndef YY_DECL | ||
912 | #define YY_DECL_IS_OURS 1 | ||
913 | |||
914 | extern int zconflex (void); | ||
915 | |||
916 | #define YY_DECL int zconflex (void) | ||
917 | #endif /* !YY_DECL */ | ||
918 | |||
919 | /* Code executed at the beginning of each rule, after zconftext and zconfleng | ||
920 | * have been set up. | ||
921 | */ | ||
922 | #ifndef YY_USER_ACTION | ||
923 | #define YY_USER_ACTION | ||
924 | #endif | ||
925 | |||
926 | /* Code executed at the end of each rule. */ | ||
927 | #ifndef YY_BREAK | ||
928 | #define YY_BREAK break; | ||
929 | #endif | ||
930 | |||
931 | #define YY_RULE_SETUP \ | ||
932 | YY_USER_ACTION | ||
933 | |||
934 | /** The main scanner function which does all the work. | ||
935 | */ | ||
936 | YY_DECL | ||
937 | { | ||
938 | register yy_state_type yy_current_state; | ||
939 | register char *yy_cp, *yy_bp; | ||
940 | register int yy_act; | ||
941 | |||
942 | int str = 0; | ||
943 | int ts, i; | ||
944 | |||
945 | if ( (yy_init) ) | ||
946 | { | ||
947 | (yy_init) = 0; | ||
948 | |||
949 | #ifdef YY_USER_INIT | ||
950 | YY_USER_INIT; | ||
951 | #endif | ||
952 | |||
953 | if ( ! (yy_start) ) | ||
954 | (yy_start) = 1; /* first start state */ | ||
955 | |||
956 | if ( ! zconfin ) | ||
957 | zconfin = stdin; | ||
958 | |||
959 | if ( ! zconfout ) | ||
960 | zconfout = stdout; | ||
961 | |||
962 | if ( ! YY_CURRENT_BUFFER ) { | ||
963 | zconfensure_buffer_stack (); | ||
964 | YY_CURRENT_BUFFER_LVALUE = | ||
965 | zconf_create_buffer(zconfin,YY_BUF_SIZE ); | ||
966 | } | ||
967 | |||
968 | zconf_load_buffer_state( ); | ||
969 | } | ||
970 | |||
971 | while ( 1 ) /* loops until end-of-file is reached */ | ||
972 | { | ||
973 | yy_cp = (yy_c_buf_p); | ||
974 | |||
975 | /* Support of zconftext. */ | ||
976 | *yy_cp = (yy_hold_char); | ||
977 | |||
978 | /* yy_bp points to the position in yy_ch_buf of the start of | ||
979 | * the current run. | ||
980 | */ | ||
981 | yy_bp = yy_cp; | ||
982 | |||
983 | yy_current_state = (yy_start); | ||
984 | yy_match: | ||
985 | while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 ) | ||
986 | ++yy_cp; | ||
987 | |||
988 | yy_current_state = -yy_current_state; | ||
989 | |||
990 | yy_find_action: | ||
991 | yy_act = yy_accept[yy_current_state]; | ||
992 | |||
993 | YY_DO_BEFORE_ACTION; | ||
994 | |||
995 | do_action: /* This label is used only to access EOF actions. */ | ||
996 | |||
997 | switch ( yy_act ) | ||
998 | { /* beginning of action switch */ | ||
999 | case 1: | ||
1000 | /* rule 1 can match eol */ | ||
1001 | case 2: | ||
1002 | /* rule 2 can match eol */ | ||
1003 | YY_RULE_SETUP | ||
1004 | { | ||
1005 | current_file->lineno++; | ||
1006 | return T_EOL; | ||
1007 | } | ||
1008 | YY_BREAK | ||
1009 | case 3: | ||
1010 | YY_RULE_SETUP | ||
1011 | |||
1012 | YY_BREAK | ||
1013 | case 4: | ||
1014 | YY_RULE_SETUP | ||
1015 | { | ||
1016 | BEGIN(COMMAND); | ||
1017 | } | ||
1018 | YY_BREAK | ||
1019 | case 5: | ||
1020 | YY_RULE_SETUP | ||
1021 | { | ||
1022 | unput(zconftext[0]); | ||
1023 | BEGIN(COMMAND); | ||
1024 | } | ||
1025 | YY_BREAK | ||
1026 | |||
1027 | case 6: | ||
1028 | YY_RULE_SETUP | ||
1029 | { | ||
1030 | struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng); | ||
1031 | BEGIN(PARAM); | ||
1032 | current_pos.file = current_file; | ||
1033 | current_pos.lineno = current_file->lineno; | ||
1034 | if (id && id->flags & TF_COMMAND) { | ||
1035 | zconflval.id = id; | ||
1036 | return id->token; | ||
1037 | } | ||
1038 | alloc_string(zconftext, zconfleng); | ||
1039 | zconflval.string = text; | ||
1040 | return T_WORD; | ||
1041 | } | ||
1042 | YY_BREAK | ||
1043 | case 7: | ||
1044 | YY_RULE_SETUP | ||
1045 | |||
1046 | YY_BREAK | ||
1047 | case 8: | ||
1048 | /* rule 8 can match eol */ | ||
1049 | YY_RULE_SETUP | ||
1050 | { | ||
1051 | BEGIN(INITIAL); | ||
1052 | current_file->lineno++; | ||
1053 | return T_EOL; | ||
1054 | } | ||
1055 | YY_BREAK | ||
1056 | |||
1057 | case 9: | ||
1058 | YY_RULE_SETUP | ||
1059 | return T_AND; | ||
1060 | YY_BREAK | ||
1061 | case 10: | ||
1062 | YY_RULE_SETUP | ||
1063 | return T_OR; | ||
1064 | YY_BREAK | ||
1065 | case 11: | ||
1066 | YY_RULE_SETUP | ||
1067 | return T_OPEN_PAREN; | ||
1068 | YY_BREAK | ||
1069 | case 12: | ||
1070 | YY_RULE_SETUP | ||
1071 | return T_CLOSE_PAREN; | ||
1072 | YY_BREAK | ||
1073 | case 13: | ||
1074 | YY_RULE_SETUP | ||
1075 | return T_NOT; | ||
1076 | YY_BREAK | ||
1077 | case 14: | ||
1078 | YY_RULE_SETUP | ||
1079 | return T_EQUAL; | ||
1080 | YY_BREAK | ||
1081 | case 15: | ||
1082 | YY_RULE_SETUP | ||
1083 | return T_UNEQUAL; | ||
1084 | YY_BREAK | ||
1085 | case 16: | ||
1086 | YY_RULE_SETUP | ||
1087 | { | ||
1088 | str = zconftext[0]; | ||
1089 | new_string(); | ||
1090 | BEGIN(STRING); | ||
1091 | } | ||
1092 | YY_BREAK | ||
1093 | case 17: | ||
1094 | /* rule 17 can match eol */ | ||
1095 | YY_RULE_SETUP | ||
1096 | BEGIN(INITIAL); current_file->lineno++; return T_EOL; | ||
1097 | YY_BREAK | ||
1098 | case 18: | ||
1099 | YY_RULE_SETUP | ||
1100 | /* ignore */ | ||
1101 | YY_BREAK | ||
1102 | case 19: | ||
1103 | YY_RULE_SETUP | ||
1104 | { | ||
1105 | struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng); | ||
1106 | if (id && id->flags & TF_PARAM) { | ||
1107 | zconflval.id = id; | ||
1108 | return id->token; | ||
1109 | } | ||
1110 | alloc_string(zconftext, zconfleng); | ||
1111 | zconflval.string = text; | ||
1112 | return T_WORD; | ||
1113 | } | ||
1114 | YY_BREAK | ||
1115 | case 20: | ||
1116 | YY_RULE_SETUP | ||
1117 | /* comment */ | ||
1118 | YY_BREAK | ||
1119 | case 21: | ||
1120 | /* rule 21 can match eol */ | ||
1121 | YY_RULE_SETUP | ||
1122 | current_file->lineno++; | ||
1123 | YY_BREAK | ||
1124 | case 22: | ||
1125 | YY_RULE_SETUP | ||
1126 | |||
1127 | YY_BREAK | ||
1128 | case YY_STATE_EOF(PARAM): | ||
1129 | { | ||
1130 | BEGIN(INITIAL); | ||
1131 | } | ||
1132 | YY_BREAK | ||
1133 | |||
1134 | case 23: | ||
1135 | /* rule 23 can match eol */ | ||
1136 | *yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ | ||
1137 | (yy_c_buf_p) = yy_cp -= 1; | ||
1138 | YY_DO_BEFORE_ACTION; /* set up zconftext again */ | ||
1139 | YY_RULE_SETUP | ||
1140 | { | ||
1141 | append_string(zconftext, zconfleng); | ||
1142 | zconflval.string = text; | ||
1143 | return T_WORD_QUOTE; | ||
1144 | } | ||
1145 | YY_BREAK | ||
1146 | case 24: | ||
1147 | YY_RULE_SETUP | ||
1148 | { | ||
1149 | append_string(zconftext, zconfleng); | ||
1150 | } | ||
1151 | YY_BREAK | ||
1152 | case 25: | ||
1153 | /* rule 25 can match eol */ | ||
1154 | *yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ | ||
1155 | (yy_c_buf_p) = yy_cp -= 1; | ||
1156 | YY_DO_BEFORE_ACTION; /* set up zconftext again */ | ||
1157 | YY_RULE_SETUP | ||
1158 | { | ||
1159 | append_string(zconftext + 1, zconfleng - 1); | ||
1160 | zconflval.string = text; | ||
1161 | return T_WORD_QUOTE; | ||
1162 | } | ||
1163 | YY_BREAK | ||
1164 | case 26: | ||
1165 | YY_RULE_SETUP | ||
1166 | { | ||
1167 | append_string(zconftext + 1, zconfleng - 1); | ||
1168 | } | ||
1169 | YY_BREAK | ||
1170 | case 27: | ||
1171 | YY_RULE_SETUP | ||
1172 | { | ||
1173 | if (str == zconftext[0]) { | ||
1174 | BEGIN(PARAM); | ||
1175 | zconflval.string = text; | ||
1176 | return T_WORD_QUOTE; | ||
1177 | } else | ||
1178 | append_string(zconftext, 1); | ||
1179 | } | ||
1180 | YY_BREAK | ||
1181 | case 28: | ||
1182 | /* rule 28 can match eol */ | ||
1183 | YY_RULE_SETUP | ||
1184 | { | ||
1185 | printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); | ||
1186 | current_file->lineno++; | ||
1187 | BEGIN(INITIAL); | ||
1188 | return T_EOL; | ||
1189 | } | ||
1190 | YY_BREAK | ||
1191 | case YY_STATE_EOF(STRING): | ||
1192 | { | ||
1193 | BEGIN(INITIAL); | ||
1194 | } | ||
1195 | YY_BREAK | ||
1196 | |||
1197 | case 29: | ||
1198 | YY_RULE_SETUP | ||
1199 | { | ||
1200 | ts = 0; | ||
1201 | for (i = 0; i < zconfleng; i++) { | ||
1202 | if (zconftext[i] == '\t') | ||
1203 | ts = (ts & ~7) + 8; | ||
1204 | else | ||
1205 | ts++; | ||
1206 | } | ||
1207 | last_ts = ts; | ||
1208 | if (first_ts) { | ||
1209 | if (ts < first_ts) { | ||
1210 | zconf_endhelp(); | ||
1211 | return T_HELPTEXT; | ||
1212 | } | ||
1213 | ts -= first_ts; | ||
1214 | while (ts > 8) { | ||
1215 | append_string(" ", 8); | ||
1216 | ts -= 8; | ||
1217 | } | ||
1218 | append_string(" ", ts); | ||
1219 | } | ||
1220 | } | ||
1221 | YY_BREAK | ||
1222 | case 30: | ||
1223 | /* rule 30 can match eol */ | ||
1224 | *yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ | ||
1225 | (yy_c_buf_p) = yy_cp -= 1; | ||
1226 | YY_DO_BEFORE_ACTION; /* set up zconftext again */ | ||
1227 | YY_RULE_SETUP | ||
1228 | { | ||
1229 | current_file->lineno++; | ||
1230 | zconf_endhelp(); | ||
1231 | return T_HELPTEXT; | ||
1232 | } | ||
1233 | YY_BREAK | ||
1234 | case 31: | ||
1235 | /* rule 31 can match eol */ | ||
1236 | YY_RULE_SETUP | ||
1237 | { | ||
1238 | current_file->lineno++; | ||
1239 | append_string("\n", 1); | ||
1240 | } | ||
1241 | YY_BREAK | ||
1242 | case 32: | ||
1243 | YY_RULE_SETUP | ||
1244 | { | ||
1245 | append_string(zconftext, zconfleng); | ||
1246 | if (!first_ts) | ||
1247 | first_ts = last_ts; | ||
1248 | } | ||
1249 | YY_BREAK | ||
1250 | case YY_STATE_EOF(HELP): | ||
1251 | { | ||
1252 | zconf_endhelp(); | ||
1253 | return T_HELPTEXT; | ||
1254 | } | ||
1255 | YY_BREAK | ||
1256 | |||
1257 | case YY_STATE_EOF(INITIAL): | ||
1258 | case YY_STATE_EOF(COMMAND): | ||
1259 | { | ||
1260 | if (current_file) { | ||
1261 | zconf_endfile(); | ||
1262 | return T_EOL; | ||
1263 | } | ||
1264 | fclose(zconfin); | ||
1265 | yyterminate(); | ||
1266 | } | ||
1267 | YY_BREAK | ||
1268 | case 33: | ||
1269 | YY_RULE_SETUP | ||
1270 | YY_FATAL_ERROR( "flex scanner jammed" ); | ||
1271 | YY_BREAK | ||
1272 | |||
1273 | case YY_END_OF_BUFFER: | ||
1274 | { | ||
1275 | /* Amount of text matched not including the EOB char. */ | ||
1276 | int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; | ||
1277 | |||
1278 | /* Undo the effects of YY_DO_BEFORE_ACTION. */ | ||
1279 | *yy_cp = (yy_hold_char); | ||
1280 | YY_RESTORE_YY_MORE_OFFSET | ||
1281 | |||
1282 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) | ||
1283 | { | ||
1284 | /* We're scanning a new file or input source. It's | ||
1285 | * possible that this happened because the user | ||
1286 | * just pointed zconfin at a new source and called | ||
1287 | * zconflex(). If so, then we have to assure | ||
1288 | * consistency between YY_CURRENT_BUFFER and our | ||
1289 | * globals. Here is the right place to do so, because | ||
1290 | * this is the first action (other than possibly a | ||
1291 | * back-up) that will match for the new input source. | ||
1292 | */ | ||
1293 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; | ||
1294 | YY_CURRENT_BUFFER_LVALUE->yy_input_file = zconfin; | ||
1295 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; | ||
1296 | } | ||
1297 | |||
1298 | /* Note that here we test for yy_c_buf_p "<=" to the position | ||
1299 | * of the first EOB in the buffer, since yy_c_buf_p will | ||
1300 | * already have been incremented past the NUL character | ||
1301 | * (since all states make transitions on EOB to the | ||
1302 | * end-of-buffer state). Contrast this with the test | ||
1303 | * in input(). | ||
1304 | */ | ||
1305 | if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) | ||
1306 | { /* This was really a NUL. */ | ||
1307 | yy_state_type yy_next_state; | ||
1308 | |||
1309 | (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; | ||
1310 | |||
1311 | yy_current_state = yy_get_previous_state( ); | ||
1312 | |||
1313 | /* Okay, we're now positioned to make the NUL | ||
1314 | * transition. We couldn't have | ||
1315 | * yy_get_previous_state() go ahead and do it | ||
1316 | * for us because it doesn't know how to deal | ||
1317 | * with the possibility of jamming (and we don't | ||
1318 | * want to build jamming into it because then it | ||
1319 | * will run more slowly). | ||
1320 | */ | ||
1321 | |||
1322 | yy_next_state = yy_try_NUL_trans( yy_current_state ); | ||
1323 | |||
1324 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | ||
1325 | |||
1326 | if ( yy_next_state ) | ||
1327 | { | ||
1328 | /* Consume the NUL. */ | ||
1329 | yy_cp = ++(yy_c_buf_p); | ||
1330 | yy_current_state = yy_next_state; | ||
1331 | goto yy_match; | ||
1332 | } | ||
1333 | |||
1334 | else | ||
1335 | { | ||
1336 | yy_cp = (yy_c_buf_p); | ||
1337 | goto yy_find_action; | ||
1338 | } | ||
1339 | } | ||
1340 | |||
1341 | else switch ( yy_get_next_buffer( ) ) | ||
1342 | { | ||
1343 | case EOB_ACT_END_OF_FILE: | ||
1344 | { | ||
1345 | (yy_did_buffer_switch_on_eof) = 0; | ||
1346 | |||
1347 | if ( zconfwrap( ) ) | ||
1348 | { | ||
1349 | /* Note: because we've taken care in | ||
1350 | * yy_get_next_buffer() to have set up | ||
1351 | * zconftext, we can now set up | ||
1352 | * yy_c_buf_p so that if some total | ||
1353 | * hoser (like flex itself) wants to | ||
1354 | * call the scanner after we return the | ||
1355 | * YY_NULL, it'll still work - another | ||
1356 | * YY_NULL will get returned. | ||
1357 | */ | ||
1358 | (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; | ||
1359 | |||
1360 | yy_act = YY_STATE_EOF(YY_START); | ||
1361 | goto do_action; | ||
1362 | } | ||
1363 | |||
1364 | else | ||
1365 | { | ||
1366 | if ( ! (yy_did_buffer_switch_on_eof) ) | ||
1367 | YY_NEW_FILE; | ||
1368 | } | ||
1369 | break; | ||
1370 | } | ||
1371 | |||
1372 | case EOB_ACT_CONTINUE_SCAN: | ||
1373 | (yy_c_buf_p) = | ||
1374 | (yytext_ptr) + yy_amount_of_matched_text; | ||
1375 | |||
1376 | yy_current_state = yy_get_previous_state( ); | ||
1377 | |||
1378 | yy_cp = (yy_c_buf_p); | ||
1379 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | ||
1380 | goto yy_match; | ||
1381 | |||
1382 | case EOB_ACT_LAST_MATCH: | ||
1383 | (yy_c_buf_p) = | ||
1384 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; | ||
1385 | |||
1386 | yy_current_state = yy_get_previous_state( ); | ||
1387 | |||
1388 | yy_cp = (yy_c_buf_p); | ||
1389 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | ||
1390 | goto yy_find_action; | ||
1391 | } | ||
1392 | break; | ||
1393 | } | ||
1394 | |||
1395 | default: | ||
1396 | YY_FATAL_ERROR( | ||
1397 | "fatal flex scanner internal error--no action found" ); | ||
1398 | } /* end of action switch */ | ||
1399 | } /* end of scanning one token */ | ||
1400 | } /* end of zconflex */ | ||
1401 | |||
1402 | /* yy_get_next_buffer - try to read in a new buffer | ||
1403 | * | ||
1404 | * Returns a code representing an action: | ||
1405 | * EOB_ACT_LAST_MATCH - | ||
1406 | * EOB_ACT_CONTINUE_SCAN - continue scanning from current position | ||
1407 | * EOB_ACT_END_OF_FILE - end of file | ||
1408 | */ | ||
1409 | static int yy_get_next_buffer (void) | ||
1410 | { | ||
1411 | register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; | ||
1412 | register char *source = (yytext_ptr); | ||
1413 | register int number_to_move, i; | ||
1414 | int ret_val; | ||
1415 | |||
1416 | if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) | ||
1417 | YY_FATAL_ERROR( | ||
1418 | "fatal flex scanner internal error--end of buffer missed" ); | ||
1419 | |||
1420 | if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) | ||
1421 | { /* Don't try to fill the buffer, so this is an EOF. */ | ||
1422 | if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) | ||
1423 | { | ||
1424 | /* We matched a single character, the EOB, so | ||
1425 | * treat this as a final EOF. | ||
1426 | */ | ||
1427 | return EOB_ACT_END_OF_FILE; | ||
1428 | } | ||
1429 | |||
1430 | else | ||
1431 | { | ||
1432 | /* We matched some text prior to the EOB, first | ||
1433 | * process it. | ||
1434 | */ | ||
1435 | return EOB_ACT_LAST_MATCH; | ||
1436 | } | ||
1437 | } | ||
1438 | |||
1439 | /* Try to read more data. */ | ||
1440 | |||
1441 | /* First move last chars to start of buffer. */ | ||
1442 | number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; | ||
1443 | |||
1444 | for ( i = 0; i < number_to_move; ++i ) | ||
1445 | *(dest++) = *(source++); | ||
1446 | |||
1447 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) | ||
1448 | /* don't do the read, it's not guaranteed to return an EOF, | ||
1449 | * just force an EOF | ||
1450 | */ | ||
1451 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; | ||
1452 | |||
1453 | else | ||
1454 | { | ||
1455 | size_t num_to_read = | ||
1456 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; | ||
1457 | |||
1458 | while ( num_to_read <= 0 ) | ||
1459 | { /* Not enough room in the buffer - grow it. */ | ||
1460 | |||
1461 | /* just a shorter name for the current buffer */ | ||
1462 | YY_BUFFER_STATE b = YY_CURRENT_BUFFER; | ||
1463 | |||
1464 | int yy_c_buf_p_offset = | ||
1465 | (int) ((yy_c_buf_p) - b->yy_ch_buf); | ||
1466 | |||
1467 | if ( b->yy_is_our_buffer ) | ||
1468 | { | ||
1469 | int new_size = b->yy_buf_size * 2; | ||
1470 | |||
1471 | if ( new_size <= 0 ) | ||
1472 | b->yy_buf_size += b->yy_buf_size / 8; | ||
1473 | else | ||
1474 | b->yy_buf_size *= 2; | ||
1475 | |||
1476 | b->yy_ch_buf = (char *) | ||
1477 | /* Include room in for 2 EOB chars. */ | ||
1478 | zconfrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); | ||
1479 | } | ||
1480 | else | ||
1481 | /* Can't grow it, we don't own it. */ | ||
1482 | b->yy_ch_buf = 0; | ||
1483 | |||
1484 | if ( ! b->yy_ch_buf ) | ||
1485 | YY_FATAL_ERROR( | ||
1486 | "fatal error - scanner input buffer overflow" ); | ||
1487 | |||
1488 | (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; | ||
1489 | |||
1490 | num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - | ||
1491 | number_to_move - 1; | ||
1492 | |||
1493 | } | ||
1494 | |||
1495 | if ( num_to_read > YY_READ_BUF_SIZE ) | ||
1496 | num_to_read = YY_READ_BUF_SIZE; | ||
1497 | |||
1498 | /* Read in more data. */ | ||
1499 | YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), | ||
1500 | (yy_n_chars), num_to_read ); | ||
1501 | |||
1502 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | ||
1503 | } | ||
1504 | |||
1505 | if ( (yy_n_chars) == 0 ) | ||
1506 | { | ||
1507 | if ( number_to_move == YY_MORE_ADJ ) | ||
1508 | { | ||
1509 | ret_val = EOB_ACT_END_OF_FILE; | ||
1510 | zconfrestart(zconfin ); | ||
1511 | } | ||
1512 | |||
1513 | else | ||
1514 | { | ||
1515 | ret_val = EOB_ACT_LAST_MATCH; | ||
1516 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = | ||
1517 | YY_BUFFER_EOF_PENDING; | ||
1518 | } | ||
1519 | } | ||
1520 | |||
1521 | else | ||
1522 | ret_val = EOB_ACT_CONTINUE_SCAN; | ||
1523 | |||
1524 | (yy_n_chars) += number_to_move; | ||
1525 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; | ||
1526 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; | ||
1527 | |||
1528 | (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; | ||
1529 | |||
1530 | return ret_val; | ||
1531 | } | ||
1532 | |||
1533 | /* yy_get_previous_state - get the state just before the EOB char was reached */ | ||
1534 | |||
1535 | static yy_state_type yy_get_previous_state (void) | ||
1536 | { | ||
1537 | register yy_state_type yy_current_state; | ||
1538 | register char *yy_cp; | ||
1539 | |||
1540 | yy_current_state = (yy_start); | ||
1541 | |||
1542 | for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) | ||
1543 | { | ||
1544 | yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)]; | ||
1545 | } | ||
1546 | |||
1547 | return yy_current_state; | ||
1548 | } | ||
1549 | |||
1550 | /* yy_try_NUL_trans - try to make a transition on the NUL character | ||
1551 | * | ||
1552 | * synopsis | ||
1553 | * next_state = yy_try_NUL_trans( current_state ); | ||
1554 | */ | ||
1555 | static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) | ||
1556 | { | ||
1557 | register int yy_is_jam; | ||
1558 | |||
1559 | yy_current_state = yy_nxt[yy_current_state][1]; | ||
1560 | yy_is_jam = (yy_current_state <= 0); | ||
1561 | |||
1562 | return yy_is_jam ? 0 : yy_current_state; | ||
1563 | } | ||
1564 | |||
1565 | static void yyunput (int c, register char * yy_bp ) | ||
1566 | { | ||
1567 | register char *yy_cp; | ||
1568 | |||
1569 | yy_cp = (yy_c_buf_p); | ||
1570 | |||
1571 | /* undo effects of setting up zconftext */ | ||
1572 | *yy_cp = (yy_hold_char); | ||
1573 | |||
1574 | if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) | ||
1575 | { /* need to shift things up to make room */ | ||
1576 | /* +2 for EOB chars. */ | ||
1577 | register int number_to_move = (yy_n_chars) + 2; | ||
1578 | register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ | ||
1579 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; | ||
1580 | register char *source = | ||
1581 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; | ||
1582 | |||
1583 | while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) | ||
1584 | *--dest = *--source; | ||
1585 | |||
1586 | yy_cp += (int) (dest - source); | ||
1587 | yy_bp += (int) (dest - source); | ||
1588 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = | ||
1589 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; | ||
1590 | |||
1591 | if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) | ||
1592 | YY_FATAL_ERROR( "flex scanner push-back overflow" ); | ||
1593 | } | ||
1594 | |||
1595 | *--yy_cp = (char) c; | ||
1596 | |||
1597 | (yytext_ptr) = yy_bp; | ||
1598 | (yy_hold_char) = *yy_cp; | ||
1599 | (yy_c_buf_p) = yy_cp; | ||
1600 | } | ||
1601 | |||
1602 | #ifndef YY_NO_INPUT | ||
1603 | #ifdef __cplusplus | ||
1604 | static int yyinput (void) | ||
1605 | #else | ||
1606 | static int input (void) | ||
1607 | #endif | ||
1608 | |||
1609 | { | ||
1610 | int c; | ||
1611 | |||
1612 | *(yy_c_buf_p) = (yy_hold_char); | ||
1613 | |||
1614 | if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) | ||
1615 | { | ||
1616 | /* yy_c_buf_p now points to the character we want to return. | ||
1617 | * If this occurs *before* the EOB characters, then it's a | ||
1618 | * valid NUL; if not, then we've hit the end of the buffer. | ||
1619 | */ | ||
1620 | if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) | ||
1621 | /* This was really a NUL. */ | ||
1622 | *(yy_c_buf_p) = '\0'; | ||
1623 | |||
1624 | else | ||
1625 | { /* need more input */ | ||
1626 | int offset = (yy_c_buf_p) - (yytext_ptr); | ||
1627 | ++(yy_c_buf_p); | ||
1628 | |||
1629 | switch ( yy_get_next_buffer( ) ) | ||
1630 | { | ||
1631 | case EOB_ACT_LAST_MATCH: | ||
1632 | /* This happens because yy_g_n_b() | ||
1633 | * sees that we've accumulated a | ||
1634 | * token and flags that we need to | ||
1635 | * try matching the token before | ||
1636 | * proceeding. But for input(), | ||
1637 | * there's no matching to consider. | ||
1638 | * So convert the EOB_ACT_LAST_MATCH | ||
1639 | * to EOB_ACT_END_OF_FILE. | ||
1640 | */ | ||
1641 | |||
1642 | /* Reset buffer status. */ | ||
1643 | zconfrestart(zconfin ); | ||
1644 | |||
1645 | /*FALLTHROUGH*/ | ||
1646 | |||
1647 | case EOB_ACT_END_OF_FILE: | ||
1648 | { | ||
1649 | if ( zconfwrap( ) ) | ||
1650 | return EOF; | ||
1651 | |||
1652 | if ( ! (yy_did_buffer_switch_on_eof) ) | ||
1653 | YY_NEW_FILE; | ||
1654 | #ifdef __cplusplus | ||
1655 | return yyinput(); | ||
1656 | #else | ||
1657 | return input(); | ||
1658 | #endif | ||
1659 | } | ||
1660 | |||
1661 | case EOB_ACT_CONTINUE_SCAN: | ||
1662 | (yy_c_buf_p) = (yytext_ptr) + offset; | ||
1663 | break; | ||
1664 | } | ||
1665 | } | ||
1666 | } | ||
1667 | |||
1668 | c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ | ||
1669 | *(yy_c_buf_p) = '\0'; /* preserve zconftext */ | ||
1670 | (yy_hold_char) = *++(yy_c_buf_p); | ||
1671 | |||
1672 | return c; | ||
1673 | } | ||
1674 | #endif /* ifndef YY_NO_INPUT */ | ||
1675 | |||
1676 | /** Immediately switch to a different input stream. | ||
1677 | * @param input_file A readable stream. | ||
1678 | * | ||
1679 | * @note This function does not reset the start condition to @c INITIAL . | ||
1680 | */ | ||
1681 | void zconfrestart (FILE * input_file ) | ||
1682 | { | ||
1683 | |||
1684 | if ( ! YY_CURRENT_BUFFER ){ | ||
1685 | zconfensure_buffer_stack (); | ||
1686 | YY_CURRENT_BUFFER_LVALUE = | ||
1687 | zconf_create_buffer(zconfin,YY_BUF_SIZE ); | ||
1688 | } | ||
1689 | |||
1690 | zconf_init_buffer(YY_CURRENT_BUFFER,input_file ); | ||
1691 | zconf_load_buffer_state( ); | ||
1692 | } | ||
1693 | |||
1694 | /** Switch to a different input buffer. | ||
1695 | * @param new_buffer The new input buffer. | ||
1696 | * | ||
1697 | */ | ||
1698 | void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ) | ||
1699 | { | ||
1700 | |||
1701 | /* TODO. We should be able to replace this entire function body | ||
1702 | * with | ||
1703 | * zconfpop_buffer_state(); | ||
1704 | * zconfpush_buffer_state(new_buffer); | ||
1705 | */ | ||
1706 | zconfensure_buffer_stack (); | ||
1707 | if ( YY_CURRENT_BUFFER == new_buffer ) | ||
1708 | return; | ||
1709 | |||
1710 | if ( YY_CURRENT_BUFFER ) | ||
1711 | { | ||
1712 | /* Flush out information for old buffer. */ | ||
1713 | *(yy_c_buf_p) = (yy_hold_char); | ||
1714 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); | ||
1715 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | ||
1716 | } | ||
1717 | |||
1718 | YY_CURRENT_BUFFER_LVALUE = new_buffer; | ||
1719 | zconf_load_buffer_state( ); | ||
1720 | |||
1721 | /* We don't actually know whether we did this switch during | ||
1722 | * EOF (zconfwrap()) processing, but the only time this flag | ||
1723 | * is looked at is after zconfwrap() is called, so it's safe | ||
1724 | * to go ahead and always set it. | ||
1725 | */ | ||
1726 | (yy_did_buffer_switch_on_eof) = 1; | ||
1727 | } | ||
1728 | |||
1729 | static void zconf_load_buffer_state (void) | ||
1730 | { | ||
1731 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; | ||
1732 | (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; | ||
1733 | zconfin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; | ||
1734 | (yy_hold_char) = *(yy_c_buf_p); | ||
1735 | } | ||
1736 | |||
1737 | /** Allocate and initialize an input buffer state. | ||
1738 | * @param file A readable stream. | ||
1739 | * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. | ||
1740 | * | ||
1741 | * @return the allocated buffer state. | ||
1742 | */ | ||
1743 | YY_BUFFER_STATE zconf_create_buffer (FILE * file, int size ) | ||
1744 | { | ||
1745 | YY_BUFFER_STATE b; | ||
1746 | |||
1747 | b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); | ||
1748 | if ( ! b ) | ||
1749 | YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); | ||
1750 | |||
1751 | b->yy_buf_size = size; | ||
1752 | |||
1753 | /* yy_ch_buf has to be 2 characters longer than the size given because | ||
1754 | * we need to put in 2 end-of-buffer characters. | ||
1755 | */ | ||
1756 | b->yy_ch_buf = (char *) zconfalloc(b->yy_buf_size + 2 ); | ||
1757 | if ( ! b->yy_ch_buf ) | ||
1758 | YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); | ||
1759 | |||
1760 | b->yy_is_our_buffer = 1; | ||
1761 | |||
1762 | zconf_init_buffer(b,file ); | ||
1763 | |||
1764 | return b; | ||
1765 | } | ||
1766 | |||
1767 | /** Destroy the buffer. | ||
1768 | * @param b a buffer created with zconf_create_buffer() | ||
1769 | * | ||
1770 | */ | ||
1771 | void zconf_delete_buffer (YY_BUFFER_STATE b ) | ||
1772 | { | ||
1773 | |||
1774 | if ( ! b ) | ||
1775 | return; | ||
1776 | |||
1777 | if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ | ||
1778 | YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; | ||
1779 | |||
1780 | if ( b->yy_is_our_buffer ) | ||
1781 | zconffree((void *) b->yy_ch_buf ); | ||
1782 | |||
1783 | zconffree((void *) b ); | ||
1784 | } | ||
1785 | |||
1786 | /* Initializes or reinitializes a buffer. | ||
1787 | * This function is sometimes called more than once on the same buffer, | ||
1788 | * such as during a zconfrestart() or at EOF. | ||
1789 | */ | ||
1790 | static void zconf_init_buffer (YY_BUFFER_STATE b, FILE * file ) | ||
1791 | |||
1792 | { | ||
1793 | int oerrno = errno; | ||
1794 | |||
1795 | zconf_flush_buffer(b ); | ||
1796 | |||
1797 | b->yy_input_file = file; | ||
1798 | b->yy_fill_buffer = 1; | ||
1799 | |||
1800 | /* If b is the current buffer, then zconf_init_buffer was _probably_ | ||
1801 | * called from zconfrestart() or through yy_get_next_buffer. | ||
1802 | * In that case, we don't want to reset the lineno or column. | ||
1803 | */ | ||
1804 | if (b != YY_CURRENT_BUFFER){ | ||
1805 | b->yy_bs_lineno = 1; | ||
1806 | b->yy_bs_column = 0; | ||
1807 | } | ||
1808 | |||
1809 | b->yy_is_interactive = 0; | ||
1810 | |||
1811 | errno = oerrno; | ||
1812 | } | ||
1813 | |||
1814 | /** Discard all buffered characters. On the next scan, YY_INPUT will be called. | ||
1815 | * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. | ||
1816 | * | ||
1817 | */ | ||
1818 | void zconf_flush_buffer (YY_BUFFER_STATE b ) | ||
1819 | { | ||
1820 | if ( ! b ) | ||
1821 | return; | ||
1822 | |||
1823 | b->yy_n_chars = 0; | ||
1824 | |||
1825 | /* We always need two end-of-buffer characters. The first causes | ||
1826 | * a transition to the end-of-buffer state. The second causes | ||
1827 | * a jam in that state. | ||
1828 | */ | ||
1829 | b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; | ||
1830 | b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; | ||
1831 | |||
1832 | b->yy_buf_pos = &b->yy_ch_buf[0]; | ||
1833 | |||
1834 | b->yy_at_bol = 1; | ||
1835 | b->yy_buffer_status = YY_BUFFER_NEW; | ||
1836 | |||
1837 | if ( b == YY_CURRENT_BUFFER ) | ||
1838 | zconf_load_buffer_state( ); | ||
1839 | } | ||
1840 | |||
1841 | /** Pushes the new state onto the stack. The new state becomes | ||
1842 | * the current state. This function will allocate the stack | ||
1843 | * if necessary. | ||
1844 | * @param new_buffer The new state. | ||
1845 | * | ||
1846 | */ | ||
1847 | void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ) | ||
1848 | { | ||
1849 | if (new_buffer == NULL) | ||
1850 | return; | ||
1851 | |||
1852 | zconfensure_buffer_stack(); | ||
1853 | |||
1854 | /* This block is copied from zconf_switch_to_buffer. */ | ||
1855 | if ( YY_CURRENT_BUFFER ) | ||
1856 | { | ||
1857 | /* Flush out information for old buffer. */ | ||
1858 | *(yy_c_buf_p) = (yy_hold_char); | ||
1859 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); | ||
1860 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | ||
1861 | } | ||
1862 | |||
1863 | /* Only push if top exists. Otherwise, replace top. */ | ||
1864 | if (YY_CURRENT_BUFFER) | ||
1865 | (yy_buffer_stack_top)++; | ||
1866 | YY_CURRENT_BUFFER_LVALUE = new_buffer; | ||
1867 | |||
1868 | /* copied from zconf_switch_to_buffer. */ | ||
1869 | zconf_load_buffer_state( ); | ||
1870 | (yy_did_buffer_switch_on_eof) = 1; | ||
1871 | } | ||
1872 | |||
1873 | /** Removes and deletes the top of the stack, if present. | ||
1874 | * The next element becomes the new top. | ||
1875 | * | ||
1876 | */ | ||
1877 | void zconfpop_buffer_state (void) | ||
1878 | { | ||
1879 | if (!YY_CURRENT_BUFFER) | ||
1880 | return; | ||
1881 | |||
1882 | zconf_delete_buffer(YY_CURRENT_BUFFER ); | ||
1883 | YY_CURRENT_BUFFER_LVALUE = NULL; | ||
1884 | if ((yy_buffer_stack_top) > 0) | ||
1885 | --(yy_buffer_stack_top); | ||
1886 | |||
1887 | if (YY_CURRENT_BUFFER) { | ||
1888 | zconf_load_buffer_state( ); | ||
1889 | (yy_did_buffer_switch_on_eof) = 1; | ||
1890 | } | ||
1891 | } | ||
1892 | |||
1893 | /* Allocates the stack if it does not exist. | ||
1894 | * Guarantees space for at least one push. | ||
1895 | */ | ||
1896 | static void zconfensure_buffer_stack (void) | ||
1897 | { | ||
1898 | int num_to_alloc; | ||
1899 | |||
1900 | if (!(yy_buffer_stack)) { | ||
1901 | |||
1902 | /* First allocation is just for 2 elements, since we don't know if this | ||
1903 | * scanner will even need a stack. We use 2 instead of 1 to avoid an | ||
1904 | * immediate realloc on the next call. | ||
1905 | */ | ||
1906 | num_to_alloc = 1; | ||
1907 | (yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc | ||
1908 | (num_to_alloc * sizeof(struct yy_buffer_state*) | ||
1909 | ); | ||
1910 | |||
1911 | memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); | ||
1912 | |||
1913 | (yy_buffer_stack_max) = num_to_alloc; | ||
1914 | (yy_buffer_stack_top) = 0; | ||
1915 | return; | ||
1916 | } | ||
1917 | |||
1918 | if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ | ||
1919 | |||
1920 | /* Increase the buffer to prepare for a possible push. */ | ||
1921 | int grow_size = 8 /* arbitrary grow size */; | ||
1922 | |||
1923 | num_to_alloc = (yy_buffer_stack_max) + grow_size; | ||
1924 | (yy_buffer_stack) = (struct yy_buffer_state**)zconfrealloc | ||
1925 | ((yy_buffer_stack), | ||
1926 | num_to_alloc * sizeof(struct yy_buffer_state*) | ||
1927 | ); | ||
1928 | |||
1929 | /* zero only the new slots.*/ | ||
1930 | memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); | ||
1931 | (yy_buffer_stack_max) = num_to_alloc; | ||
1932 | } | ||
1933 | } | ||
1934 | |||
1935 | /** Setup the input buffer state to scan directly from a user-specified character buffer. | ||
1936 | * @param base the character buffer | ||
1937 | * @param size the size in bytes of the character buffer | ||
1938 | * | ||
1939 | * @return the newly allocated buffer state object. | ||
1940 | */ | ||
1941 | YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size ) | ||
1942 | { | ||
1943 | YY_BUFFER_STATE b; | ||
1944 | |||
1945 | if ( size < 2 || | ||
1946 | base[size-2] != YY_END_OF_BUFFER_CHAR || | ||
1947 | base[size-1] != YY_END_OF_BUFFER_CHAR ) | ||
1948 | /* They forgot to leave room for the EOB's. */ | ||
1949 | return 0; | ||
1950 | |||
1951 | b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); | ||
1952 | if ( ! b ) | ||
1953 | YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_buffer()" ); | ||
1954 | |||
1955 | b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ | ||
1956 | b->yy_buf_pos = b->yy_ch_buf = base; | ||
1957 | b->yy_is_our_buffer = 0; | ||
1958 | b->yy_input_file = 0; | ||
1959 | b->yy_n_chars = b->yy_buf_size; | ||
1960 | b->yy_is_interactive = 0; | ||
1961 | b->yy_at_bol = 1; | ||
1962 | b->yy_fill_buffer = 0; | ||
1963 | b->yy_buffer_status = YY_BUFFER_NEW; | ||
1964 | |||
1965 | zconf_switch_to_buffer(b ); | ||
1966 | |||
1967 | return b; | ||
1968 | } | ||
1969 | |||
1970 | /** Setup the input buffer state to scan a string. The next call to zconflex() will | ||
1971 | * scan from a @e copy of @a str. | ||
1972 | * @param yy_str a NUL-terminated string to scan | ||
1973 | * | ||
1974 | * @return the newly allocated buffer state object. | ||
1975 | * @note If you want to scan bytes that may contain NUL values, then use | ||
1976 | * zconf_scan_bytes() instead. | ||
1977 | */ | ||
1978 | YY_BUFFER_STATE zconf_scan_string (yyconst char * yy_str ) | ||
1979 | { | ||
1980 | |||
1981 | return zconf_scan_bytes(yy_str,strlen(yy_str) ); | ||
1982 | } | ||
1983 | |||
1984 | /** Setup the input buffer state to scan the given bytes. The next call to zconflex() will | ||
1985 | * scan from a @e copy of @a bytes. | ||
1986 | * @param bytes the byte buffer to scan | ||
1987 | * @param len the number of bytes in the buffer pointed to by @a bytes. | ||
1988 | * | ||
1989 | * @return the newly allocated buffer state object. | ||
1990 | */ | ||
1991 | YY_BUFFER_STATE zconf_scan_bytes (yyconst char * bytes, int len ) | ||
1992 | { | ||
1993 | YY_BUFFER_STATE b; | ||
1994 | char *buf; | ||
1995 | yy_size_t n; | ||
1996 | int i; | ||
1997 | |||
1998 | /* Get memory for full buffer, including space for trailing EOB's. */ | ||
1999 | n = len + 2; | ||
2000 | buf = (char *) zconfalloc(n ); | ||
2001 | if ( ! buf ) | ||
2002 | YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_bytes()" ); | ||
2003 | |||
2004 | for ( i = 0; i < len; ++i ) | ||
2005 | buf[i] = bytes[i]; | ||
2006 | |||
2007 | buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; | ||
2008 | |||
2009 | b = zconf_scan_buffer(buf,n ); | ||
2010 | if ( ! b ) | ||
2011 | YY_FATAL_ERROR( "bad buffer in zconf_scan_bytes()" ); | ||
2012 | |||
2013 | /* It's okay to grow etc. this buffer, and we should throw it | ||
2014 | * away when we're done. | ||
2015 | */ | ||
2016 | b->yy_is_our_buffer = 1; | ||
2017 | |||
2018 | return b; | ||
2019 | } | ||
2020 | |||
2021 | #ifndef YY_EXIT_FAILURE | ||
2022 | #define YY_EXIT_FAILURE 2 | ||
2023 | #endif | ||
2024 | |||
2025 | static void yy_fatal_error (yyconst char* msg ) | ||
2026 | { | ||
2027 | (void) fprintf( stderr, "%s\n", msg ); | ||
2028 | exit( YY_EXIT_FAILURE ); | ||
2029 | } | ||
2030 | |||
2031 | /* Redefine yyless() so it works in section 3 code. */ | ||
2032 | |||
2033 | #undef yyless | ||
2034 | #define yyless(n) \ | ||
2035 | do \ | ||
2036 | { \ | ||
2037 | /* Undo effects of setting up zconftext. */ \ | ||
2038 | int yyless_macro_arg = (n); \ | ||
2039 | YY_LESS_LINENO(yyless_macro_arg);\ | ||
2040 | zconftext[zconfleng] = (yy_hold_char); \ | ||
2041 | (yy_c_buf_p) = zconftext + yyless_macro_arg; \ | ||
2042 | (yy_hold_char) = *(yy_c_buf_p); \ | ||
2043 | *(yy_c_buf_p) = '\0'; \ | ||
2044 | zconfleng = yyless_macro_arg; \ | ||
2045 | } \ | ||
2046 | while ( 0 ) | ||
2047 | |||
2048 | /* Accessor methods (get/set functions) to struct members. */ | ||
2049 | |||
2050 | /** Get the current line number. | ||
2051 | * | ||
2052 | */ | ||
2053 | int zconfget_lineno (void) | ||
2054 | { | ||
2055 | |||
2056 | return zconflineno; | ||
2057 | } | ||
2058 | |||
2059 | /** Get the input stream. | ||
2060 | * | ||
2061 | */ | ||
2062 | FILE *zconfget_in (void) | ||
2063 | { | ||
2064 | return zconfin; | ||
2065 | } | ||
2066 | |||
2067 | /** Get the output stream. | ||
2068 | * | ||
2069 | */ | ||
2070 | FILE *zconfget_out (void) | ||
2071 | { | ||
2072 | return zconfout; | ||
2073 | } | ||
2074 | |||
2075 | /** Get the length of the current token. | ||
2076 | * | ||
2077 | */ | ||
2078 | int zconfget_leng (void) | ||
2079 | { | ||
2080 | return zconfleng; | ||
2081 | } | ||
2082 | |||
2083 | /** Get the current token. | ||
2084 | * | ||
2085 | */ | ||
2086 | |||
2087 | char *zconfget_text (void) | ||
2088 | { | ||
2089 | return zconftext; | ||
2090 | } | ||
2091 | |||
2092 | /** Set the current line number. | ||
2093 | * @param line_number | ||
2094 | * | ||
2095 | */ | ||
2096 | void zconfset_lineno (int line_number ) | ||
2097 | { | ||
2098 | |||
2099 | zconflineno = line_number; | ||
2100 | } | ||
2101 | |||
2102 | /** Set the input stream. This does not discard the current | ||
2103 | * input buffer. | ||
2104 | * @param in_str A readable stream. | ||
2105 | * | ||
2106 | * @see zconf_switch_to_buffer | ||
2107 | */ | ||
2108 | void zconfset_in (FILE * in_str ) | ||
2109 | { | ||
2110 | zconfin = in_str ; | ||
2111 | } | ||
2112 | |||
2113 | void zconfset_out (FILE * out_str ) | ||
2114 | { | ||
2115 | zconfout = out_str ; | ||
2116 | } | ||
2117 | |||
2118 | int zconfget_debug (void) | ||
2119 | { | ||
2120 | return zconf_flex_debug; | ||
2121 | } | ||
2122 | |||
2123 | void zconfset_debug (int bdebug ) | ||
2124 | { | ||
2125 | zconf_flex_debug = bdebug ; | ||
2126 | } | ||
2127 | |||
2128 | /* zconflex_destroy is for both reentrant and non-reentrant scanners. */ | ||
2129 | int zconflex_destroy (void) | ||
2130 | { | ||
2131 | |||
2132 | /* Pop the buffer stack, destroying each element. */ | ||
2133 | while(YY_CURRENT_BUFFER){ | ||
2134 | zconf_delete_buffer(YY_CURRENT_BUFFER ); | ||
2135 | YY_CURRENT_BUFFER_LVALUE = NULL; | ||
2136 | zconfpop_buffer_state(); | ||
2137 | } | ||
2138 | |||
2139 | /* Destroy the stack itself. */ | ||
2140 | zconffree((yy_buffer_stack) ); | ||
2141 | (yy_buffer_stack) = NULL; | ||
2142 | |||
2143 | return 0; | ||
2144 | } | ||
2145 | |||
2146 | /* | ||
2147 | * Internal utility routines. | ||
2148 | */ | ||
2149 | |||
2150 | #ifndef yytext_ptr | ||
2151 | static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) | ||
2152 | { | ||
2153 | register int i; | ||
2154 | for ( i = 0; i < n; ++i ) | ||
2155 | s1[i] = s2[i]; | ||
2156 | } | ||
2157 | #endif | ||
2158 | |||
2159 | #ifdef YY_NEED_STRLEN | ||
2160 | static int yy_flex_strlen (yyconst char * s ) | ||
2161 | { | ||
2162 | register int n; | ||
2163 | for ( n = 0; s[n]; ++n ) | ||
2164 | ; | ||
2165 | |||
2166 | return n; | ||
2167 | } | ||
2168 | #endif | ||
2169 | |||
2170 | void *zconfalloc (yy_size_t size ) | ||
2171 | { | ||
2172 | return (void *) malloc( size ); | ||
2173 | } | ||
2174 | |||
2175 | void *zconfrealloc (void * ptr, yy_size_t size ) | ||
2176 | { | ||
2177 | /* The cast to (char *) in the following accommodates both | ||
2178 | * implementations that use char* generic pointers, and those | ||
2179 | * that use void* generic pointers. It works with the latter | ||
2180 | * because both ANSI C and C++ allow castless assignment from | ||
2181 | * any pointer type to void*, and deal with argument conversions | ||
2182 | * as though doing an assignment. | ||
2183 | */ | ||
2184 | return (void *) realloc( (char *) ptr, size ); | ||
2185 | } | ||
2186 | |||
2187 | void zconffree (void * ptr ) | ||
2188 | { | ||
2189 | free( (char *) ptr ); /* see zconfrealloc() for (char *) cast */ | ||
2190 | } | ||
2191 | |||
2192 | #define YYTABLES_NAME "yytables" | ||
2193 | |||
2194 | #undef YY_NEW_FILE | ||
2195 | #undef YY_FLUSH_BUFFER | ||
2196 | #undef yy_set_bol | ||
2197 | #undef yy_new_buffer | ||
2198 | #undef yy_set_interactive | ||
2199 | #undef yytext_ptr | ||
2200 | #undef YY_DO_BEFORE_ACTION | ||
2201 | |||
2202 | #ifdef YY_DECL_IS_OURS | ||
2203 | #undef YY_DECL_IS_OURS | ||
2204 | #undef YY_DECL | ||
2205 | #endif | ||
2206 | |||
2207 | void zconf_starthelp(void) | ||
2208 | { | ||
2209 | new_string(); | ||
2210 | last_ts = first_ts = 0; | ||
2211 | BEGIN(HELP); | ||
2212 | } | ||
2213 | |||
2214 | static void zconf_endhelp(void) | ||
2215 | { | ||
2216 | zconflval.string = text; | ||
2217 | BEGIN(INITIAL); | ||
2218 | } | ||
2219 | |||
2220 | /* | ||
2221 | * Try to open specified file with following names: | ||
2222 | * ./name | ||
2223 | * $(srctree)/name | ||
2224 | * The latter is used when srctree is separate from objtree | ||
2225 | * when compiling the kernel. | ||
2226 | * Return NULL if file is not found. | ||
2227 | */ | ||
2228 | FILE *zconf_fopen(const char *name) | ||
2229 | { | ||
2230 | char *env, fullname[PATH_MAX+1]; | ||
2231 | FILE *f; | ||
2232 | |||
2233 | f = fopen(name, "r"); | ||
2234 | if (!f && name[0] != '/') { | ||
2235 | env = getenv(SRCTREE); | ||
2236 | if (env) { | ||
2237 | sprintf(fullname, "%s/%s", env, name); | ||
2238 | f = fopen(fullname, "r"); | ||
2239 | } | ||
2240 | } | ||
2241 | return f; | ||
2242 | } | ||
2243 | |||
2244 | void zconf_initscan(const char *name) | ||
2245 | { | ||
2246 | zconfin = zconf_fopen(name); | ||
2247 | if (!zconfin) { | ||
2248 | printf("can't find file %s\n", name); | ||
2249 | exit(1); | ||
2250 | } | ||
2251 | |||
2252 | current_buf = malloc(sizeof(*current_buf)); | ||
2253 | memset(current_buf, 0, sizeof(*current_buf)); | ||
2254 | |||
2255 | current_file = file_lookup(name); | ||
2256 | current_file->lineno = 1; | ||
2257 | current_file->flags = FILE_BUSY; | ||
2258 | } | ||
2259 | |||
2260 | void zconf_nextfile(const char *name) | ||
2261 | { | ||
2262 | struct file *file = file_lookup(name); | ||
2263 | struct buffer *buf = malloc(sizeof(*buf)); | ||
2264 | memset(buf, 0, sizeof(*buf)); | ||
2265 | |||
2266 | current_buf->state = YY_CURRENT_BUFFER; | ||
2267 | zconfin = zconf_fopen(name); | ||
2268 | if (!zconfin) { | ||
2269 | printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name); | ||
2270 | exit(1); | ||
2271 | } | ||
2272 | zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE)); | ||
2273 | buf->parent = current_buf; | ||
2274 | current_buf = buf; | ||
2275 | |||
2276 | if (file->flags & FILE_BUSY) { | ||
2277 | printf("recursive scan (%s)?\n", name); | ||
2278 | exit(1); | ||
2279 | } | ||
2280 | if (file->flags & FILE_SCANNED) { | ||
2281 | printf("file %s already scanned?\n", name); | ||
2282 | exit(1); | ||
2283 | } | ||
2284 | file->flags |= FILE_BUSY; | ||
2285 | file->lineno = 1; | ||
2286 | file->parent = current_file; | ||
2287 | current_file = file; | ||
2288 | } | ||
2289 | |||
2290 | static void zconf_endfile(void) | ||
2291 | { | ||
2292 | struct buffer *parent; | ||
2293 | |||
2294 | current_file->flags |= FILE_SCANNED; | ||
2295 | current_file->flags &= ~FILE_BUSY; | ||
2296 | current_file = current_file->parent; | ||
2297 | |||
2298 | parent = current_buf->parent; | ||
2299 | if (parent) { | ||
2300 | fclose(zconfin); | ||
2301 | zconf_delete_buffer(YY_CURRENT_BUFFER); | ||
2302 | zconf_switch_to_buffer(parent->state); | ||
2303 | } | ||
2304 | free(current_buf); | ||
2305 | current_buf = parent; | ||
2306 | } | ||
2307 | |||
2308 | int zconf_lineno(void) | ||
2309 | { | ||
2310 | return current_pos.lineno; | ||
2311 | } | ||
2312 | |||
2313 | char *zconf_curname(void) | ||
2314 | { | ||
2315 | return current_pos.file ? current_pos.file->name : "<none>"; | ||
2316 | } | ||
2317 | |||
diff --git a/scripts/config/lkc.h b/scripts/kconfig/lkc.h index 8c38f1f87..527f60c99 100644 --- a/scripts/config/lkc.h +++ b/scripts/kconfig/lkc.h | |||
@@ -1,4 +1,3 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | 1 | /* |
3 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
4 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
@@ -9,6 +8,14 @@ | |||
9 | 8 | ||
10 | #include "expr.h" | 9 | #include "expr.h" |
11 | 10 | ||
11 | #ifndef KBUILD_NO_NLS | ||
12 | # include <libintl.h> | ||
13 | #else | ||
14 | # define gettext(Msgid) ((const char *) (Msgid)) | ||
15 | # define textdomain(Domainname) ((const char *) (Domainname)) | ||
16 | # define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) | ||
17 | #endif | ||
18 | |||
12 | #ifdef __cplusplus | 19 | #ifdef __cplusplus |
13 | extern "C" { | 20 | extern "C" { |
14 | #endif | 21 | #endif |
@@ -24,6 +31,23 @@ extern "C" { | |||
24 | 31 | ||
25 | #define SRCTREE "srctree" | 32 | #define SRCTREE "srctree" |
26 | 33 | ||
34 | #define PACKAGE "linux" | ||
35 | #define LOCALEDIR "/usr/share/locale" | ||
36 | |||
37 | #define _(text) gettext(text) | ||
38 | #define N_(text) (text) | ||
39 | |||
40 | |||
41 | #define TF_COMMAND 0x0001 | ||
42 | #define TF_PARAM 0x0002 | ||
43 | |||
44 | struct kconf_id { | ||
45 | int name; | ||
46 | int token; | ||
47 | unsigned int flags; | ||
48 | enum symbol_type stype; | ||
49 | }; | ||
50 | |||
27 | int zconfparse(void); | 51 | int zconfparse(void); |
28 | void zconfdump(FILE *out); | 52 | void zconfdump(FILE *out); |
29 | 53 | ||
@@ -37,7 +61,6 @@ char *zconf_curname(void); | |||
37 | 61 | ||
38 | /* confdata.c */ | 62 | /* confdata.c */ |
39 | extern const char conf_def_filename[]; | 63 | extern const char conf_def_filename[]; |
40 | extern char conf_filename[]; | ||
41 | 64 | ||
42 | char *conf_get_default_confname(void); | 65 | char *conf_get_default_confname(void); |
43 | 66 | ||
@@ -46,13 +69,13 @@ void kconfig_load(void); | |||
46 | 69 | ||
47 | /* menu.c */ | 70 | /* menu.c */ |
48 | void menu_init(void); | 71 | void menu_init(void); |
49 | void menu_add_menu(void); | 72 | struct menu *menu_add_menu(void); |
50 | void menu_end_menu(void); | 73 | void menu_end_menu(void); |
51 | void menu_add_entry(struct symbol *sym); | 74 | void menu_add_entry(struct symbol *sym); |
52 | void menu_end_entry(void); | 75 | void menu_end_entry(void); |
53 | void menu_add_dep(struct expr *dep); | 76 | void menu_add_dep(struct expr *dep); |
54 | struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); | 77 | struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); |
55 | void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); | 78 | struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); |
56 | void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); | 79 | void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); |
57 | void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); | 80 | void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); |
58 | void menu_finalize(struct menu *parent); | 81 | void menu_finalize(struct menu *parent); |
diff --git a/scripts/config/lkc_proto.h b/scripts/kconfig/lkc_proto.h index c416357df..b6a389c5f 100644 --- a/scripts/config/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h | |||
@@ -1,8 +1,8 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | 1 | ||
3 | /* confdata.c */ | 2 | /* confdata.c */ |
4 | P(conf_parse,void,(const char *name)); | 3 | P(conf_parse,void,(const char *name)); |
5 | P(conf_read,int,(const char *name)); | 4 | P(conf_read,int,(const char *name)); |
5 | P(conf_read_simple,int,(const char *name)); | ||
6 | P(conf_write,int,(const char *name)); | 6 | P(conf_write,int,(const char *name)); |
7 | 7 | ||
8 | /* menu.c */ | 8 | /* menu.c */ |
diff --git a/scripts/config/lxdialog/BIG.FAT.WARNING b/scripts/kconfig/lxdialog/BIG.FAT.WARNING index 7cb5a7ec9..a8999d82b 100644 --- a/scripts/config/lxdialog/BIG.FAT.WARNING +++ b/scripts/kconfig/lxdialog/BIG.FAT.WARNING | |||
@@ -1,4 +1,4 @@ | |||
1 | This is NOT the official version of dialog. This version has been | 1 | This is NOT the official version of dialog. This version has been |
2 | significantly modified from the original. It is for use by the Linux | 2 | significantly modified from the original. It is for use by the Linux |
3 | kernel configuration script. Please do not bother Savio Lam with | 3 | kernel configuration script. Please do not bother Savio Lam with |
4 | questions about this program. | 4 | questions about this program. |
diff --git a/scripts/kconfig/lxdialog/Makefile b/scripts/kconfig/lxdialog/Makefile new file mode 100644 index 000000000..a8b026326 --- /dev/null +++ b/scripts/kconfig/lxdialog/Makefile | |||
@@ -0,0 +1,21 @@ | |||
1 | # Makefile to build lxdialog package | ||
2 | # | ||
3 | |||
4 | check-lxdialog := $(srctree)/$(src)/check-lxdialog.sh | ||
5 | |||
6 | # Use reursively expanded variables so we do not call gcc unless | ||
7 | # we really need to do so. (Do not call gcc as part of make mrproper) | ||
8 | HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) | ||
9 | HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) | ||
10 | |||
11 | HOST_EXTRACFLAGS += -DLOCALE | ||
12 | |||
13 | PHONY += dochecklxdialog | ||
14 | $(obj)/dochecklxdialog: | ||
15 | $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES) | ||
16 | |||
17 | hostprogs-y := lxdialog | ||
18 | always := $(hostprogs-y) dochecklxdialog | ||
19 | |||
20 | lxdialog-objs := checklist.o menubox.o textbox.o yesno.o inputbox.o \ | ||
21 | util.o lxdialog.o msgbox.o | ||
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh new file mode 100644 index 000000000..120d624e6 --- /dev/null +++ b/scripts/kconfig/lxdialog/check-lxdialog.sh | |||
@@ -0,0 +1,84 @@ | |||
1 | #!/bin/sh | ||
2 | # Check ncurses compatibility | ||
3 | |||
4 | # What library to link | ||
5 | ldflags() | ||
6 | { | ||
7 | $cc -print-file-name=libncursesw.so | grep -q / | ||
8 | if [ $? -eq 0 ]; then | ||
9 | echo '-lncursesw' | ||
10 | exit | ||
11 | fi | ||
12 | $cc -print-file-name=libncurses.so | grep -q / | ||
13 | if [ $? -eq 0 ]; then | ||
14 | echo '-lncurses' | ||
15 | exit | ||
16 | fi | ||
17 | $cc -print-file-name=libcurses.so | grep -q / | ||
18 | if [ $? -eq 0 ]; then | ||
19 | echo '-lcurses' | ||
20 | exit | ||
21 | fi | ||
22 | exit 1 | ||
23 | } | ||
24 | |||
25 | # Where is ncurses.h? | ||
26 | ccflags() | ||
27 | { | ||
28 | if [ -f /usr/include/ncurses/ncurses.h ]; then | ||
29 | echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"' | ||
30 | elif [ -f /usr/include/ncurses/curses.h ]; then | ||
31 | echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"' | ||
32 | elif [ -f /usr/include/ncurses.h ]; then | ||
33 | echo '-DCURSES_LOC="<ncurses.h>"' | ||
34 | else | ||
35 | echo '-DCURSES_LOC="<curses.h>"' | ||
36 | fi | ||
37 | } | ||
38 | |||
39 | # Temp file, try to clean up after us | ||
40 | tmp=.lxdialog.tmp | ||
41 | trap "rm -f $tmp" 0 1 2 3 15 | ||
42 | |||
43 | # Check if we can link to ncurses | ||
44 | check() { | ||
45 | echo "main() {}" | $cc -xc - -o $tmp 2> /dev/null | ||
46 | if [ $? != 0 ]; then | ||
47 | echo " *** Unable to find the ncurses libraries." 1>&2 | ||
48 | echo " *** make menuconfig require the ncurses libraries" 1>&2 | ||
49 | echo " *** " 1>&2 | ||
50 | echo " *** Install ncurses (ncurses-devel) and try again" 1>&2 | ||
51 | echo " *** " 1>&2 | ||
52 | exit 1 | ||
53 | fi | ||
54 | } | ||
55 | |||
56 | usage() { | ||
57 | printf "Usage: $0 [-check compiler options|-header|-library]\n" | ||
58 | } | ||
59 | |||
60 | if [ $# == 0 ]; then | ||
61 | usage | ||
62 | exit 1 | ||
63 | fi | ||
64 | |||
65 | cc="" | ||
66 | case "$1" in | ||
67 | "-check") | ||
68 | shift | ||
69 | cc="$@" | ||
70 | check | ||
71 | ;; | ||
72 | "-ccflags") | ||
73 | ccflags | ||
74 | ;; | ||
75 | "-ldflags") | ||
76 | shift | ||
77 | cc="$@" | ||
78 | ldflags | ||
79 | ;; | ||
80 | "*") | ||
81 | usage | ||
82 | exit 1 | ||
83 | ;; | ||
84 | esac | ||
diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c new file mode 100644 index 000000000..be0200e9c --- /dev/null +++ b/scripts/kconfig/lxdialog/checklist.c | |||
@@ -0,0 +1,333 @@ | |||
1 | /* | ||
2 | * checklist.c -- implements the checklist box | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension | ||
6 | * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two | ||
7 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License | ||
11 | * as published by the Free Software Foundation; either version 2 | ||
12 | * of the License, or (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
22 | */ | ||
23 | |||
24 | #include "dialog.h" | ||
25 | |||
26 | static int list_width, check_x, item_x; | ||
27 | |||
28 | /* | ||
29 | * Print list item | ||
30 | */ | ||
31 | static void print_item(WINDOW * win, const char *item, int status, int choice, | ||
32 | int selected) | ||
33 | { | ||
34 | int i; | ||
35 | |||
36 | /* Clear 'residue' of last item */ | ||
37 | wattrset(win, menubox_attr); | ||
38 | wmove(win, choice, 0); | ||
39 | for (i = 0; i < list_width; i++) | ||
40 | waddch(win, ' '); | ||
41 | |||
42 | wmove(win, choice, check_x); | ||
43 | wattrset(win, selected ? check_selected_attr : check_attr); | ||
44 | wprintw(win, "(%c)", status ? 'X' : ' '); | ||
45 | |||
46 | wattrset(win, selected ? tag_selected_attr : tag_attr); | ||
47 | mvwaddch(win, choice, item_x, item[0]); | ||
48 | wattrset(win, selected ? item_selected_attr : item_attr); | ||
49 | waddstr(win, (char *)item + 1); | ||
50 | if (selected) { | ||
51 | wmove(win, choice, check_x + 1); | ||
52 | wrefresh(win); | ||
53 | } | ||
54 | } | ||
55 | |||
56 | /* | ||
57 | * Print the scroll indicators. | ||
58 | */ | ||
59 | static void print_arrows(WINDOW * win, int choice, int item_no, int scroll, | ||
60 | int y, int x, int height) | ||
61 | { | ||
62 | wmove(win, y, x); | ||
63 | |||
64 | if (scroll > 0) { | ||
65 | wattrset(win, uarrow_attr); | ||
66 | waddch(win, ACS_UARROW); | ||
67 | waddstr(win, "(-)"); | ||
68 | } else { | ||
69 | wattrset(win, menubox_attr); | ||
70 | waddch(win, ACS_HLINE); | ||
71 | waddch(win, ACS_HLINE); | ||
72 | waddch(win, ACS_HLINE); | ||
73 | waddch(win, ACS_HLINE); | ||
74 | } | ||
75 | |||
76 | y = y + height + 1; | ||
77 | wmove(win, y, x); | ||
78 | |||
79 | if ((height < item_no) && (scroll + choice < item_no - 1)) { | ||
80 | wattrset(win, darrow_attr); | ||
81 | waddch(win, ACS_DARROW); | ||
82 | waddstr(win, "(+)"); | ||
83 | } else { | ||
84 | wattrset(win, menubox_border_attr); | ||
85 | waddch(win, ACS_HLINE); | ||
86 | waddch(win, ACS_HLINE); | ||
87 | waddch(win, ACS_HLINE); | ||
88 | waddch(win, ACS_HLINE); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | /* | ||
93 | * Display the termination buttons | ||
94 | */ | ||
95 | static void print_buttons(WINDOW * dialog, int height, int width, int selected) | ||
96 | { | ||
97 | int x = width / 2 - 11; | ||
98 | int y = height - 2; | ||
99 | |||
100 | print_button(dialog, "Select", y, x, selected == 0); | ||
101 | print_button(dialog, " Help ", y, x + 14, selected == 1); | ||
102 | |||
103 | wmove(dialog, y, x + 1 + 14 * selected); | ||
104 | wrefresh(dialog); | ||
105 | } | ||
106 | |||
107 | /* | ||
108 | * Display a dialog box with a list of options that can be turned on or off | ||
109 | * in the style of radiolist (only one option turned on at a time). | ||
110 | */ | ||
111 | int dialog_checklist(const char *title, const char *prompt, int height, | ||
112 | int width, int list_height, int item_no, | ||
113 | const char *const *items) | ||
114 | { | ||
115 | int i, x, y, box_x, box_y; | ||
116 | int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; | ||
117 | WINDOW *dialog, *list; | ||
118 | |||
119 | /* Allocate space for storing item on/off status */ | ||
120 | if ((status = malloc(sizeof(int) * item_no)) == NULL) { | ||
121 | endwin(); | ||
122 | fprintf(stderr, | ||
123 | "\nCan't allocate memory in dialog_checklist().\n"); | ||
124 | exit(-1); | ||
125 | } | ||
126 | |||
127 | /* Initializes status */ | ||
128 | for (i = 0; i < item_no; i++) { | ||
129 | status[i] = !strcasecmp(items[i * 3 + 2], "on"); | ||
130 | if ((!choice && status[i]) | ||
131 | || !strcasecmp(items[i * 3 + 2], "selected")) | ||
132 | choice = i + 1; | ||
133 | } | ||
134 | if (choice) | ||
135 | choice--; | ||
136 | |||
137 | max_choice = MIN(list_height, item_no); | ||
138 | |||
139 | /* center dialog box on screen */ | ||
140 | x = (COLS - width) / 2; | ||
141 | y = (LINES - height) / 2; | ||
142 | |||
143 | draw_shadow(stdscr, y, x, height, width); | ||
144 | |||
145 | dialog = newwin(height, width, y, x); | ||
146 | keypad(dialog, TRUE); | ||
147 | |||
148 | draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); | ||
149 | wattrset(dialog, border_attr); | ||
150 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); | ||
151 | for (i = 0; i < width - 2; i++) | ||
152 | waddch(dialog, ACS_HLINE); | ||
153 | wattrset(dialog, dialog_attr); | ||
154 | waddch(dialog, ACS_RTEE); | ||
155 | |||
156 | print_title(dialog, title, width); | ||
157 | |||
158 | wattrset(dialog, dialog_attr); | ||
159 | print_autowrap(dialog, prompt, width - 2, 1, 3); | ||
160 | |||
161 | list_width = width - 6; | ||
162 | box_y = height - list_height - 5; | ||
163 | box_x = (width - list_width) / 2 - 1; | ||
164 | |||
165 | /* create new window for the list */ | ||
166 | list = subwin(dialog, list_height, list_width, y + box_y + 1, | ||
167 | x + box_x + 1); | ||
168 | |||
169 | keypad(list, TRUE); | ||
170 | |||
171 | /* draw a box around the list items */ | ||
172 | draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2, | ||
173 | menubox_border_attr, menubox_attr); | ||
174 | |||
175 | /* Find length of longest item in order to center checklist */ | ||
176 | check_x = 0; | ||
177 | for (i = 0; i < item_no; i++) | ||
178 | check_x = MAX(check_x, +strlen(items[i * 3 + 1]) + 4); | ||
179 | |||
180 | check_x = (list_width - check_x) / 2; | ||
181 | item_x = check_x + 4; | ||
182 | |||
183 | if (choice >= list_height) { | ||
184 | scroll = choice - list_height + 1; | ||
185 | choice -= scroll; | ||
186 | } | ||
187 | |||
188 | /* Print the list */ | ||
189 | for (i = 0; i < max_choice; i++) { | ||
190 | print_item(list, items[(scroll + i) * 3 + 1], | ||
191 | status[i + scroll], i, i == choice); | ||
192 | } | ||
193 | |||
194 | print_arrows(dialog, choice, item_no, scroll, | ||
195 | box_y, box_x + check_x + 5, list_height); | ||
196 | |||
197 | print_buttons(dialog, height, width, 0); | ||
198 | |||
199 | wnoutrefresh(dialog); | ||
200 | wnoutrefresh(list); | ||
201 | doupdate(); | ||
202 | |||
203 | while (key != ESC) { | ||
204 | key = wgetch(dialog); | ||
205 | |||
206 | for (i = 0; i < max_choice; i++) | ||
207 | if (toupper(key) == | ||
208 | toupper(items[(scroll + i) * 3 + 1][0])) | ||
209 | break; | ||
210 | |||
211 | if (i < max_choice || key == KEY_UP || key == KEY_DOWN || | ||
212 | key == '+' || key == '-') { | ||
213 | if (key == KEY_UP || key == '-') { | ||
214 | if (!choice) { | ||
215 | if (!scroll) | ||
216 | continue; | ||
217 | /* Scroll list down */ | ||
218 | if (list_height > 1) { | ||
219 | /* De-highlight current first item */ | ||
220 | print_item(list, items[scroll * 3 + 1], | ||
221 | status[scroll], 0, FALSE); | ||
222 | scrollok(list, TRUE); | ||
223 | wscrl(list, -1); | ||
224 | scrollok(list, FALSE); | ||
225 | } | ||
226 | scroll--; | ||
227 | print_item(list, items[scroll * 3 + 1], status[scroll], 0, TRUE); | ||
228 | print_arrows(dialog, choice, item_no, | ||
229 | scroll, box_y, box_x + check_x + 5, list_height); | ||
230 | |||
231 | wnoutrefresh(dialog); | ||
232 | wrefresh(list); | ||
233 | |||
234 | continue; /* wait for another key press */ | ||
235 | } else | ||
236 | i = choice - 1; | ||
237 | } else if (key == KEY_DOWN || key == '+') { | ||
238 | if (choice == max_choice - 1) { | ||
239 | if (scroll + choice >= item_no - 1) | ||
240 | continue; | ||
241 | /* Scroll list up */ | ||
242 | if (list_height > 1) { | ||
243 | /* De-highlight current last item before scrolling up */ | ||
244 | print_item(list, items[(scroll + max_choice - 1) * 3 + 1], | ||
245 | status[scroll + max_choice - 1], | ||
246 | max_choice - 1, FALSE); | ||
247 | scrollok(list, TRUE); | ||
248 | wscrl(list, 1); | ||
249 | scrollok(list, FALSE); | ||
250 | } | ||
251 | scroll++; | ||
252 | print_item(list, items[(scroll + max_choice - 1) * 3 + 1], | ||
253 | status[scroll + max_choice - 1], max_choice - 1, TRUE); | ||
254 | |||
255 | print_arrows(dialog, choice, item_no, | ||
256 | scroll, box_y, box_x + check_x + 5, list_height); | ||
257 | |||
258 | wnoutrefresh(dialog); | ||
259 | wrefresh(list); | ||
260 | |||
261 | continue; /* wait for another key press */ | ||
262 | } else | ||
263 | i = choice + 1; | ||
264 | } | ||
265 | if (i != choice) { | ||
266 | /* De-highlight current item */ | ||
267 | print_item(list, items[(scroll + choice) * 3 + 1], | ||
268 | status[scroll + choice], choice, FALSE); | ||
269 | /* Highlight new item */ | ||
270 | choice = i; | ||
271 | print_item(list, items[(scroll + choice) * 3 + 1], | ||
272 | status[scroll + choice], choice, TRUE); | ||
273 | wnoutrefresh(dialog); | ||
274 | wrefresh(list); | ||
275 | } | ||
276 | continue; /* wait for another key press */ | ||
277 | } | ||
278 | switch (key) { | ||
279 | case 'H': | ||
280 | case 'h': | ||
281 | case '?': | ||
282 | fprintf(stderr, "%s", items[(scroll + choice) * 3]); | ||
283 | delwin(dialog); | ||
284 | free(status); | ||
285 | return 1; | ||
286 | case TAB: | ||
287 | case KEY_LEFT: | ||
288 | case KEY_RIGHT: | ||
289 | button = ((key == KEY_LEFT ? --button : ++button) < 0) | ||
290 | ? 1 : (button > 1 ? 0 : button); | ||
291 | |||
292 | print_buttons(dialog, height, width, button); | ||
293 | wrefresh(dialog); | ||
294 | break; | ||
295 | case 'S': | ||
296 | case 's': | ||
297 | case ' ': | ||
298 | case '\n': | ||
299 | if (!button) { | ||
300 | if (!status[scroll + choice]) { | ||
301 | for (i = 0; i < item_no; i++) | ||
302 | status[i] = 0; | ||
303 | status[scroll + choice] = 1; | ||
304 | for (i = 0; i < max_choice; i++) | ||
305 | print_item(list, items[(scroll + i) * 3 + 1], | ||
306 | status[scroll + i], i, i == choice); | ||
307 | } | ||
308 | wnoutrefresh(dialog); | ||
309 | wrefresh(list); | ||
310 | |||
311 | for (i = 0; i < item_no; i++) | ||
312 | if (status[i]) | ||
313 | fprintf(stderr, "%s", items[i * 3]); | ||
314 | } else | ||
315 | fprintf(stderr, "%s", items[(scroll + choice) * 3]); | ||
316 | delwin(dialog); | ||
317 | free(status); | ||
318 | return button; | ||
319 | case 'X': | ||
320 | case 'x': | ||
321 | key = ESC; | ||
322 | case ESC: | ||
323 | break; | ||
324 | } | ||
325 | |||
326 | /* Now, update everything... */ | ||
327 | doupdate(); | ||
328 | } | ||
329 | |||
330 | delwin(dialog); | ||
331 | free(status); | ||
332 | return -1; /* ESC pressed */ | ||
333 | } | ||
diff --git a/scripts/config/lxdialog/colors.h b/scripts/kconfig/lxdialog/colors.h index 4a2d06421..db071df12 100644 --- a/scripts/config/lxdialog/colors.h +++ b/scripts/kconfig/lxdialog/colors.h | |||
@@ -1,4 +1,3 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | 1 | /* |
3 | * colors.h -- color attribute definitions | 2 | * colors.h -- color attribute definitions |
4 | * | 3 | * |
@@ -19,7 +18,6 @@ | |||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | */ | 19 | */ |
21 | 20 | ||
22 | |||
23 | /* | 21 | /* |
24 | * Default color definitions | 22 | * Default color definitions |
25 | * | 23 | * |
@@ -153,10 +151,4 @@ | |||
153 | * Global variables | 151 | * Global variables |
154 | */ | 152 | */ |
155 | 153 | ||
156 | typedef struct { | ||
157 | char name[COLOR_NAME_LEN]; | ||
158 | int value; | ||
159 | } color_names_st; | ||
160 | |||
161 | extern color_names_st color_names[]; | ||
162 | extern int color_table[][3]; | 154 | extern int color_table[][3]; |
diff --git a/scripts/config/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index 236a68dce..af3cf716e 100644 --- a/scripts/config/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h | |||
@@ -1,5 +1,3 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | |||
3 | /* | 1 | /* |
4 | * dialog.h -- common declarations for all dialog modules | 2 | * dialog.h -- common declarations for all dialog modules |
5 | * | 3 | * |
@@ -27,7 +25,6 @@ | |||
27 | #include <stdlib.h> | 25 | #include <stdlib.h> |
28 | #include <string.h> | 26 | #include <string.h> |
29 | 27 | ||
30 | #ifdef CURSES_LOC | ||
31 | #ifdef __sun__ | 28 | #ifdef __sun__ |
32 | #define CURS_MACROS | 29 | #define CURS_MACROS |
33 | #endif | 30 | #endif |
@@ -44,7 +41,7 @@ | |||
44 | #if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE) | 41 | #if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE) |
45 | #define OLD_NCURSES 1 | 42 | #define OLD_NCURSES 1 |
46 | #undef wbkgdset | 43 | #undef wbkgdset |
47 | #define wbkgdset(w,p) /*nothing*/ | 44 | #define wbkgdset(w,p) /*nothing */ |
48 | #else | 45 | #else |
49 | #define OLD_NCURSES 0 | 46 | #define OLD_NCURSES 0 |
50 | #endif | 47 | #endif |
@@ -58,7 +55,6 @@ | |||
58 | #define MIN(x,y) (x < y ? x : y) | 55 | #define MIN(x,y) (x < y ? x : y) |
59 | #define MAX(x,y) (x > y ? x : y) | 56 | #define MAX(x,y) (x > y ? x : y) |
60 | 57 | ||
61 | |||
62 | #ifndef ACS_ULCORNER | 58 | #ifndef ACS_ULCORNER |
63 | #define ACS_ULCORNER '+' | 59 | #define ACS_ULCORNER '+' |
64 | #endif | 60 | #endif |
@@ -130,53 +126,44 @@ | |||
130 | * Global variables | 126 | * Global variables |
131 | */ | 127 | */ |
132 | extern bool use_colors; | 128 | extern bool use_colors; |
129 | extern bool use_shadow; | ||
133 | 130 | ||
134 | extern chtype attributes[]; | 131 | extern chtype attributes[]; |
135 | #endif | ||
136 | 132 | ||
137 | extern const char *backtitle; | 133 | extern const char *backtitle; |
138 | 134 | ||
139 | struct dialog_list_item { | ||
140 | char *name; | ||
141 | int namelen; | ||
142 | char *tag; | ||
143 | int selected; /* Set to 1 by dialog_*() function. */ | ||
144 | }; | ||
145 | |||
146 | /* | 135 | /* |
147 | * Function prototypes | 136 | * Function prototypes |
148 | */ | 137 | */ |
149 | 138 | extern void create_rc(const char *filename); | |
150 | void init_dialog (void); | 139 | extern int parse_rc(void); |
151 | void end_dialog (void); | 140 | |
152 | void dialog_clear (void); | 141 | void init_dialog(void); |
153 | #ifdef CURSES_LOC | 142 | void end_dialog(void); |
154 | void attr_clear (WINDOW * win, int height, int width, chtype attr); | 143 | void attr_clear(WINDOW * win, int height, int width, chtype attr); |
155 | void color_setup (void); | 144 | void dialog_clear(void); |
156 | void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x); | 145 | void color_setup(void); |
157 | void print_button (WINDOW * win, const char *label, int y, int x, int selected); | 146 | void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x); |
158 | void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box, | 147 | void print_button(WINDOW * win, const char *label, int y, int x, int selected); |
159 | chtype border); | 148 | void print_title(WINDOW *dialog, const char *title, int width); |
160 | void draw_shadow (WINDOW * win, int y, int x, int height, int width); | 149 | void draw_box(WINDOW * win, int y, int x, int height, int width, chtype box, |
161 | #endif | 150 | chtype border); |
162 | 151 | void draw_shadow(WINDOW * win, int y, int x, int height, int width); | |
163 | int first_alpha (const char *string, const char *exempt); | 152 | |
164 | int dialog_yesno (const char *title, const char *prompt, int height, int width); | 153 | int first_alpha(const char *string, const char *exempt); |
165 | int dialog_msgbox (const char *title, const char *prompt, int height, | 154 | int dialog_yesno(const char *title, const char *prompt, int height, int width); |
166 | int width, int pause); | 155 | int dialog_msgbox(const char *title, const char *prompt, int height, |
167 | int dialog_textbox (const char *title, const char *file, int height, int width); | 156 | int width, int pause); |
168 | int dialog_menu (const char *title, const char *prompt, int height, int width, | 157 | int dialog_textbox(const char *title, const char *file, int height, int width); |
158 | int dialog_menu(const char *title, const char *prompt, int height, int width, | ||
169 | int menu_height, const char *choice, int item_no, | 159 | int menu_height, const char *choice, int item_no, |
170 | struct dialog_list_item ** items); | 160 | const char *const *items); |
171 | int dialog_checklist (const char *title, const char *prompt, int height, | 161 | int dialog_checklist(const char *title, const char *prompt, int height, |
172 | int width, int list_height, int item_no, | 162 | int width, int list_height, int item_no, |
173 | struct dialog_list_item ** items, int flag); | 163 | const char *const *items); |
174 | extern char dialog_input_result[]; | 164 | extern char dialog_input_result[]; |
175 | int dialog_inputbox (const char *title, const char *prompt, int height, | 165 | int dialog_inputbox(const char *title, const char *prompt, int height, |
176 | int width, const char *init); | 166 | int width, const char *init); |
177 | |||
178 | struct dialog_list_item *first_sel_item(int item_no, | ||
179 | struct dialog_list_item ** items); | ||
180 | 167 | ||
181 | /* | 168 | /* |
182 | * This is the base for fictitious keys, which activate | 169 | * This is the base for fictitious keys, which activate |
@@ -187,14 +174,4 @@ struct dialog_list_item *first_sel_item(int item_no, | |||
187 | * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o') | 174 | * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o') |
188 | * -- uppercase chars are used to invoke the button (M_EVENT + 'O') | 175 | * -- uppercase chars are used to invoke the button (M_EVENT + 'O') |
189 | */ | 176 | */ |
190 | #ifdef CURSES_LOC | ||
191 | #define M_EVENT (KEY_MAX+1) | 177 | #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/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c new file mode 100644 index 000000000..779503726 --- /dev/null +++ b/scripts/kconfig/lxdialog/inputbox.c | |||
@@ -0,0 +1,224 @@ | |||
1 | /* | ||
2 | * inputbox.c -- implements the input box | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) | ||
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 | #include "dialog.h" | ||
23 | |||
24 | char dialog_input_result[MAX_LEN + 1]; | ||
25 | |||
26 | /* | ||
27 | * Print the termination buttons | ||
28 | */ | ||
29 | static void print_buttons(WINDOW * dialog, int height, int width, int selected) | ||
30 | { | ||
31 | int x = width / 2 - 11; | ||
32 | int y = height - 2; | ||
33 | |||
34 | print_button(dialog, " Ok ", y, x, selected == 0); | ||
35 | print_button(dialog, " Help ", y, x + 14, selected == 1); | ||
36 | |||
37 | wmove(dialog, y, x + 1 + 14 * selected); | ||
38 | wrefresh(dialog); | ||
39 | } | ||
40 | |||
41 | /* | ||
42 | * Display a dialog box for inputing a string | ||
43 | */ | ||
44 | int dialog_inputbox(const char *title, const char *prompt, int height, int width, | ||
45 | const char *init) | ||
46 | { | ||
47 | int i, x, y, box_y, box_x, box_width; | ||
48 | int input_x = 0, scroll = 0, key = 0, button = -1; | ||
49 | char *instr = dialog_input_result; | ||
50 | WINDOW *dialog; | ||
51 | |||
52 | /* center dialog box on screen */ | ||
53 | x = (COLS - width) / 2; | ||
54 | y = (LINES - height) / 2; | ||
55 | |||
56 | draw_shadow(stdscr, y, x, height, width); | ||
57 | |||
58 | dialog = newwin(height, width, y, x); | ||
59 | keypad(dialog, TRUE); | ||
60 | |||
61 | draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); | ||
62 | wattrset(dialog, border_attr); | ||
63 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); | ||
64 | for (i = 0; i < width - 2; i++) | ||
65 | waddch(dialog, ACS_HLINE); | ||
66 | wattrset(dialog, dialog_attr); | ||
67 | waddch(dialog, ACS_RTEE); | ||
68 | |||
69 | print_title(dialog, title, width); | ||
70 | |||
71 | wattrset(dialog, dialog_attr); | ||
72 | print_autowrap(dialog, prompt, width - 2, 1, 3); | ||
73 | |||
74 | /* Draw the input field box */ | ||
75 | box_width = width - 6; | ||
76 | getyx(dialog, y, x); | ||
77 | box_y = y + 2; | ||
78 | box_x = (width - box_width) / 2; | ||
79 | draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, border_attr, dialog_attr); | ||
80 | |||
81 | print_buttons(dialog, height, width, 0); | ||
82 | |||
83 | /* Set up the initial value */ | ||
84 | wmove(dialog, box_y, box_x); | ||
85 | wattrset(dialog, inputbox_attr); | ||
86 | |||
87 | if (!init) | ||
88 | instr[0] = '\0'; | ||
89 | else | ||
90 | strcpy(instr, init); | ||
91 | |||
92 | input_x = strlen(instr); | ||
93 | |||
94 | if (input_x >= box_width) { | ||
95 | scroll = input_x - box_width + 1; | ||
96 | input_x = box_width - 1; | ||
97 | for (i = 0; i < box_width - 1; i++) | ||
98 | waddch(dialog, instr[scroll + i]); | ||
99 | } else { | ||
100 | waddstr(dialog, instr); | ||
101 | } | ||
102 | |||
103 | wmove(dialog, box_y, box_x + input_x); | ||
104 | |||
105 | wrefresh(dialog); | ||
106 | |||
107 | while (key != ESC) { | ||
108 | key = wgetch(dialog); | ||
109 | |||
110 | if (button == -1) { /* Input box selected */ | ||
111 | switch (key) { | ||
112 | case TAB: | ||
113 | case KEY_UP: | ||
114 | case KEY_DOWN: | ||
115 | break; | ||
116 | case KEY_LEFT: | ||
117 | continue; | ||
118 | case KEY_RIGHT: | ||
119 | continue; | ||
120 | case KEY_BACKSPACE: | ||
121 | case 127: | ||
122 | if (input_x || scroll) { | ||
123 | wattrset(dialog, inputbox_attr); | ||
124 | if (!input_x) { | ||
125 | scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); | ||
126 | wmove(dialog, box_y, box_x); | ||
127 | for (i = 0; i < box_width; i++) | ||
128 | waddch(dialog, | ||
129 | instr[scroll + input_x + i] ? | ||
130 | instr[scroll + input_x + i] : ' '); | ||
131 | input_x = strlen(instr) - scroll; | ||
132 | } else | ||
133 | input_x--; | ||
134 | instr[scroll + input_x] = '\0'; | ||
135 | mvwaddch(dialog, box_y, input_x + box_x, ' '); | ||
136 | wmove(dialog, box_y, input_x + box_x); | ||
137 | wrefresh(dialog); | ||
138 | } | ||
139 | continue; | ||
140 | default: | ||
141 | if (key < 0x100 && isprint(key)) { | ||
142 | if (scroll + input_x < MAX_LEN) { | ||
143 | wattrset(dialog, inputbox_attr); | ||
144 | instr[scroll + input_x] = key; | ||
145 | instr[scroll + input_x + 1] = '\0'; | ||
146 | if (input_x == box_width - 1) { | ||
147 | scroll++; | ||
148 | wmove(dialog, box_y, box_x); | ||
149 | for (i = 0; i < box_width - 1; i++) | ||
150 | waddch(dialog, instr [scroll + i]); | ||
151 | } else { | ||
152 | wmove(dialog, box_y, input_x++ + box_x); | ||
153 | waddch(dialog, key); | ||
154 | } | ||
155 | wrefresh(dialog); | ||
156 | } else | ||
157 | flash(); /* Alarm user about overflow */ | ||
158 | continue; | ||
159 | } | ||
160 | } | ||
161 | } | ||
162 | switch (key) { | ||
163 | case 'O': | ||
164 | case 'o': | ||
165 | delwin(dialog); | ||
166 | return 0; | ||
167 | case 'H': | ||
168 | case 'h': | ||
169 | delwin(dialog); | ||
170 | return 1; | ||
171 | case KEY_UP: | ||
172 | case KEY_LEFT: | ||
173 | switch (button) { | ||
174 | case -1: | ||
175 | button = 1; /* Indicates "Cancel" button is selected */ | ||
176 | print_buttons(dialog, height, width, 1); | ||
177 | break; | ||
178 | case 0: | ||
179 | button = -1; /* Indicates input box is selected */ | ||
180 | print_buttons(dialog, height, width, 0); | ||
181 | wmove(dialog, box_y, box_x + input_x); | ||
182 | wrefresh(dialog); | ||
183 | break; | ||
184 | case 1: | ||
185 | button = 0; /* Indicates "OK" button is selected */ | ||
186 | print_buttons(dialog, height, width, 0); | ||
187 | break; | ||
188 | } | ||
189 | break; | ||
190 | case TAB: | ||
191 | case KEY_DOWN: | ||
192 | case KEY_RIGHT: | ||
193 | switch (button) { | ||
194 | case -1: | ||
195 | button = 0; /* Indicates "OK" button is selected */ | ||
196 | print_buttons(dialog, height, width, 0); | ||
197 | break; | ||
198 | case 0: | ||
199 | button = 1; /* Indicates "Cancel" button is selected */ | ||
200 | print_buttons(dialog, height, width, 1); | ||
201 | break; | ||
202 | case 1: | ||
203 | button = -1; /* Indicates input box is selected */ | ||
204 | print_buttons(dialog, height, width, 0); | ||
205 | wmove(dialog, box_y, box_x + input_x); | ||
206 | wrefresh(dialog); | ||
207 | break; | ||
208 | } | ||
209 | break; | ||
210 | case ' ': | ||
211 | case '\n': | ||
212 | delwin(dialog); | ||
213 | return (button == -1 ? 0 : button); | ||
214 | case 'X': | ||
215 | case 'x': | ||
216 | key = ESC; | ||
217 | case ESC: | ||
218 | break; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | delwin(dialog); | ||
223 | return -1; /* ESC pressed */ | ||
224 | } | ||
diff --git a/scripts/kconfig/lxdialog/lxdialog.c b/scripts/kconfig/lxdialog/lxdialog.c new file mode 100644 index 000000000..79f6c5fb5 --- /dev/null +++ b/scripts/kconfig/lxdialog/lxdialog.c | |||
@@ -0,0 +1,204 @@ | |||
1 | /* | ||
2 | * dialog - Display simple dialog boxes from shell scripts | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) | ||
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 | #include "dialog.h" | ||
23 | |||
24 | static void Usage(const char *name); | ||
25 | |||
26 | typedef int (jumperFn) (const char *title, int argc, const char *const *argv); | ||
27 | |||
28 | struct Mode { | ||
29 | char *name; | ||
30 | int argmin, argmax, argmod; | ||
31 | jumperFn *jumper; | ||
32 | }; | ||
33 | |||
34 | jumperFn j_menu, j_radiolist, j_yesno, j_textbox, j_inputbox; | ||
35 | jumperFn j_msgbox, j_infobox; | ||
36 | |||
37 | static struct Mode modes[] = { | ||
38 | {"--menu", 9, 0, 3, j_menu}, | ||
39 | {"--radiolist", 9, 0, 3, j_radiolist}, | ||
40 | {"--yesno", 5, 5, 1, j_yesno}, | ||
41 | {"--textbox", 5, 5, 1, j_textbox}, | ||
42 | {"--inputbox", 5, 6, 1, j_inputbox}, | ||
43 | {"--msgbox", 5, 5, 1, j_msgbox}, | ||
44 | {"--infobox", 5, 5, 1, j_infobox}, | ||
45 | {NULL, 0, 0, 0, NULL} | ||
46 | }; | ||
47 | |||
48 | static struct Mode *modePtr; | ||
49 | |||
50 | #ifdef LOCALE | ||
51 | #include <locale.h> | ||
52 | #endif | ||
53 | |||
54 | int main(int argc, const char *const *argv) | ||
55 | { | ||
56 | int offset = 0, opt_clear = 0, end_common_opts = 0, retval; | ||
57 | const char *title = NULL; | ||
58 | |||
59 | #ifdef LOCALE | ||
60 | (void)setlocale(LC_ALL, ""); | ||
61 | #endif | ||
62 | |||
63 | #ifdef TRACE | ||
64 | trace(TRACE_CALLS | TRACE_UPDATE); | ||
65 | #endif | ||
66 | if (argc < 2) { | ||
67 | Usage(argv[0]); | ||
68 | exit(-1); | ||
69 | } | ||
70 | |||
71 | while (offset < argc - 1 && !end_common_opts) { /* Common options */ | ||
72 | if (!strcmp(argv[offset + 1], "--title")) { | ||
73 | if (argc - offset < 3 || title != NULL) { | ||
74 | Usage(argv[0]); | ||
75 | exit(-1); | ||
76 | } else { | ||
77 | title = argv[offset + 2]; | ||
78 | offset += 2; | ||
79 | } | ||
80 | } else if (!strcmp(argv[offset + 1], "--backtitle")) { | ||
81 | if (backtitle != NULL) { | ||
82 | Usage(argv[0]); | ||
83 | exit(-1); | ||
84 | } else { | ||
85 | backtitle = argv[offset + 2]; | ||
86 | offset += 2; | ||
87 | } | ||
88 | } else if (!strcmp(argv[offset + 1], "--clear")) { | ||
89 | if (opt_clear) { /* Hey, "--clear" can't appear twice! */ | ||
90 | Usage(argv[0]); | ||
91 | exit(-1); | ||
92 | } else if (argc == 2) { /* we only want to clear the screen */ | ||
93 | init_dialog(); | ||
94 | refresh(); /* init_dialog() will clear the screen for us */ | ||
95 | end_dialog(); | ||
96 | return 0; | ||
97 | } else { | ||
98 | opt_clear = 1; | ||
99 | offset++; | ||
100 | } | ||
101 | } else /* no more common options */ | ||
102 | end_common_opts = 1; | ||
103 | } | ||
104 | |||
105 | if (argc - 1 == offset) { /* no more options */ | ||
106 | Usage(argv[0]); | ||
107 | exit(-1); | ||
108 | } | ||
109 | /* use a table to look for the requested mode, to avoid code duplication */ | ||
110 | |||
111 | for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */ | ||
112 | if (!strcmp(argv[offset + 1], modePtr->name)) | ||
113 | break; | ||
114 | |||
115 | if (!modePtr->name) | ||
116 | Usage(argv[0]); | ||
117 | if (argc - offset < modePtr->argmin) | ||
118 | Usage(argv[0]); | ||
119 | if (modePtr->argmax && argc - offset > modePtr->argmax) | ||
120 | Usage(argv[0]); | ||
121 | |||
122 | init_dialog(); | ||
123 | retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset); | ||
124 | |||
125 | if (opt_clear) { /* clear screen before exit */ | ||
126 | attr_clear(stdscr, LINES, COLS, screen_attr); | ||
127 | refresh(); | ||
128 | } | ||
129 | end_dialog(); | ||
130 | |||
131 | exit(retval); | ||
132 | } | ||
133 | |||
134 | /* | ||
135 | * Print program usage | ||
136 | */ | ||
137 | static void Usage(const char *name) | ||
138 | { | ||
139 | fprintf(stderr, "\ | ||
140 | \ndialog, by Savio Lam (lam836@cs.cuhk.hk).\ | ||
141 | \n patched by Stuart Herbert (S.Herbert@shef.ac.uk)\ | ||
142 | \n modified/gutted for use as a Linux kernel config tool by \ | ||
143 | \n William Roadcap (roadcapw@cfw.com)\ | ||
144 | \n\ | ||
145 | \n* Display dialog boxes from shell scripts *\ | ||
146 | \n\ | ||
147 | \nUsage: %s --clear\ | ||
148 | \n %s [--title <title>] [--backtitle <backtitle>] --clear <Box options>\ | ||
149 | \n\ | ||
150 | \nBox options:\ | ||
151 | \n\ | ||
152 | \n --menu <text> <height> <width> <menu height> <tag1> <item1>...\ | ||
153 | \n --radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>...\ | ||
154 | \n --textbox <file> <height> <width>\ | ||
155 | \n --inputbox <text> <height> <width> [<init>]\ | ||
156 | \n --yesno <text> <height> <width>\ | ||
157 | \n", name, name); | ||
158 | exit(-1); | ||
159 | } | ||
160 | |||
161 | /* | ||
162 | * These are the program jumpers | ||
163 | */ | ||
164 | |||
165 | int j_menu(const char *t, int ac, const char *const *av) | ||
166 | { | ||
167 | return dialog_menu(t, av[2], atoi(av[3]), atoi(av[4]), | ||
168 | atoi(av[5]), av[6], (ac - 6) / 2, av + 7); | ||
169 | } | ||
170 | |||
171 | int j_radiolist(const char *t, int ac, const char *const *av) | ||
172 | { | ||
173 | return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]), | ||
174 | atoi(av[5]), (ac - 6) / 3, av + 6); | ||
175 | } | ||
176 | |||
177 | int j_textbox(const char *t, int ac, const char *const *av) | ||
178 | { | ||
179 | return dialog_textbox(t, av[2], atoi(av[3]), atoi(av[4])); | ||
180 | } | ||
181 | |||
182 | int j_yesno(const char *t, int ac, const char *const *av) | ||
183 | { | ||
184 | return dialog_yesno(t, av[2], atoi(av[3]), atoi(av[4])); | ||
185 | } | ||
186 | |||
187 | int j_inputbox(const char *t, int ac, const char *const *av) | ||
188 | { | ||
189 | int ret = dialog_inputbox(t, av[2], atoi(av[3]), atoi(av[4]), | ||
190 | ac == 6 ? av[5] : (char *)NULL); | ||
191 | if (ret == 0) | ||
192 | fprintf(stderr, dialog_input_result); | ||
193 | return ret; | ||
194 | } | ||
195 | |||
196 | int j_msgbox(const char *t, int ac, const char *const *av) | ||
197 | { | ||
198 | return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 1); | ||
199 | } | ||
200 | |||
201 | int j_infobox(const char *t, int ac, const char *const *av) | ||
202 | { | ||
203 | return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 0); | ||
204 | } | ||
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c new file mode 100644 index 000000000..bf8052f4f --- /dev/null +++ b/scripts/kconfig/lxdialog/menubox.c | |||
@@ -0,0 +1,426 @@ | |||
1 | /* | ||
2 | * menubox.c -- implements the menu box | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) | ||
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 | * Changes by Clifford Wolf (god@clifford.at) | ||
24 | * | ||
25 | * [ 1998-06-13 ] | ||
26 | * | ||
27 | * *) A bugfix for the Page-Down problem | ||
28 | * | ||
29 | * *) Formerly when I used Page Down and Page Up, the cursor would be set | ||
30 | * to the first position in the menu box. Now lxdialog is a bit | ||
31 | * smarter and works more like other menu systems (just have a look at | ||
32 | * it). | ||
33 | * | ||
34 | * *) Formerly if I selected something my scrolling would be broken because | ||
35 | * lxdialog is re-invoked by the Menuconfig shell script, can't | ||
36 | * remember the last scrolling position, and just sets it so that the | ||
37 | * cursor is at the bottom of the box. Now it writes the temporary file | ||
38 | * lxdialog.scrltmp which contains this information. The file is | ||
39 | * deleted by lxdialog if the user leaves a submenu or enters a new | ||
40 | * one, but it would be nice if Menuconfig could make another "rm -f" | ||
41 | * just to be sure. Just try it out - you will recognise a difference! | ||
42 | * | ||
43 | * [ 1998-06-14 ] | ||
44 | * | ||
45 | * *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files | ||
46 | * and menus change their size on the fly. | ||
47 | * | ||
48 | * *) If for some reason the last scrolling position is not saved by | ||
49 | * lxdialog, it sets the scrolling so that the selected item is in the | ||
50 | * middle of the menu box, not at the bottom. | ||
51 | * | ||
52 | * 02 January 1999, Michael Elizabeth Chastain (mec@shout.net) | ||
53 | * Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus. | ||
54 | * This fixes a bug in Menuconfig where using ' ' to descend into menus | ||
55 | * would leave mis-synchronized lxdialog.scrltmp files lying around, | ||
56 | * fscanf would read in 'scroll', and eventually that value would get used. | ||
57 | */ | ||
58 | |||
59 | #include "dialog.h" | ||
60 | |||
61 | static int menu_width, item_x; | ||
62 | |||
63 | /* | ||
64 | * Print menu item | ||
65 | */ | ||
66 | static void do_print_item(WINDOW * win, const char *item, int choice, | ||
67 | int selected, int hotkey) | ||
68 | { | ||
69 | int j; | ||
70 | char *menu_item = malloc(menu_width + 1); | ||
71 | |||
72 | strncpy(menu_item, item, menu_width - item_x); | ||
73 | menu_item[menu_width] = 0; | ||
74 | j = first_alpha(menu_item, "YyNnMmHh"); | ||
75 | |||
76 | /* Clear 'residue' of last item */ | ||
77 | wattrset(win, menubox_attr); | ||
78 | wmove(win, choice, 0); | ||
79 | #if OLD_NCURSES | ||
80 | { | ||
81 | int i; | ||
82 | for (i = 0; i < menu_width; i++) | ||
83 | waddch(win, ' '); | ||
84 | } | ||
85 | #else | ||
86 | wclrtoeol(win); | ||
87 | #endif | ||
88 | wattrset(win, selected ? item_selected_attr : item_attr); | ||
89 | mvwaddstr(win, choice, item_x, menu_item); | ||
90 | if (hotkey) { | ||
91 | wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); | ||
92 | mvwaddch(win, choice, item_x + j, menu_item[j]); | ||
93 | } | ||
94 | if (selected) { | ||
95 | wmove(win, choice, item_x + 1); | ||
96 | } | ||
97 | free(menu_item); | ||
98 | wrefresh(win); | ||
99 | } | ||
100 | |||
101 | #define print_item(index, choice, selected) \ | ||
102 | do {\ | ||
103 | int hotkey = (items[(index) * 2][0] != ':'); \ | ||
104 | do_print_item(menu, items[(index) * 2 + 1], choice, selected, hotkey); \ | ||
105 | } while (0) | ||
106 | |||
107 | /* | ||
108 | * Print the scroll indicators. | ||
109 | */ | ||
110 | static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, | ||
111 | int height) | ||
112 | { | ||
113 | int cur_y, cur_x; | ||
114 | |||
115 | getyx(win, cur_y, cur_x); | ||
116 | |||
117 | wmove(win, y, x); | ||
118 | |||
119 | if (scroll > 0) { | ||
120 | wattrset(win, uarrow_attr); | ||
121 | waddch(win, ACS_UARROW); | ||
122 | waddstr(win, "(-)"); | ||
123 | } else { | ||
124 | wattrset(win, menubox_attr); | ||
125 | waddch(win, ACS_HLINE); | ||
126 | waddch(win, ACS_HLINE); | ||
127 | waddch(win, ACS_HLINE); | ||
128 | waddch(win, ACS_HLINE); | ||
129 | } | ||
130 | |||
131 | y = y + height + 1; | ||
132 | wmove(win, y, x); | ||
133 | wrefresh(win); | ||
134 | |||
135 | if ((height < item_no) && (scroll + height < item_no)) { | ||
136 | wattrset(win, darrow_attr); | ||
137 | waddch(win, ACS_DARROW); | ||
138 | waddstr(win, "(+)"); | ||
139 | } else { | ||
140 | wattrset(win, menubox_border_attr); | ||
141 | waddch(win, ACS_HLINE); | ||
142 | waddch(win, ACS_HLINE); | ||
143 | waddch(win, ACS_HLINE); | ||
144 | waddch(win, ACS_HLINE); | ||
145 | } | ||
146 | |||
147 | wmove(win, cur_y, cur_x); | ||
148 | wrefresh(win); | ||
149 | } | ||
150 | |||
151 | /* | ||
152 | * Display the termination buttons. | ||
153 | */ | ||
154 | static void print_buttons(WINDOW * win, int height, int width, int selected) | ||
155 | { | ||
156 | int x = width / 2 - 16; | ||
157 | int y = height - 2; | ||
158 | |||
159 | print_button(win, "Select", y, x, selected == 0); | ||
160 | print_button(win, " Exit ", y, x + 12, selected == 1); | ||
161 | print_button(win, " Help ", y, x + 24, selected == 2); | ||
162 | |||
163 | wmove(win, y, x + 1 + 12 * selected); | ||
164 | wrefresh(win); | ||
165 | } | ||
166 | |||
167 | /* scroll up n lines (n may be negative) */ | ||
168 | static void do_scroll(WINDOW *win, int *scroll, int n) | ||
169 | { | ||
170 | /* Scroll menu up */ | ||
171 | scrollok(win, TRUE); | ||
172 | wscrl(win, n); | ||
173 | scrollok(win, FALSE); | ||
174 | *scroll = *scroll + n; | ||
175 | wrefresh(win); | ||
176 | } | ||
177 | |||
178 | /* | ||
179 | * Display a menu for choosing among a number of options | ||
180 | */ | ||
181 | int dialog_menu(const char *title, const char *prompt, int height, int width, | ||
182 | int menu_height, const char *current, int item_no, | ||
183 | const char *const *items) | ||
184 | { | ||
185 | int i, j, x, y, box_x, box_y; | ||
186 | int key = 0, button = 0, scroll = 0, choice = 0; | ||
187 | int first_item = 0, max_choice; | ||
188 | WINDOW *dialog, *menu; | ||
189 | FILE *f; | ||
190 | |||
191 | max_choice = MIN(menu_height, item_no); | ||
192 | |||
193 | /* center dialog box on screen */ | ||
194 | x = (COLS - width) / 2; | ||
195 | y = (LINES - height) / 2; | ||
196 | |||
197 | draw_shadow(stdscr, y, x, height, width); | ||
198 | |||
199 | dialog = newwin(height, width, y, x); | ||
200 | keypad(dialog, TRUE); | ||
201 | |||
202 | draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); | ||
203 | wattrset(dialog, border_attr); | ||
204 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); | ||
205 | for (i = 0; i < width - 2; i++) | ||
206 | waddch(dialog, ACS_HLINE); | ||
207 | wattrset(dialog, dialog_attr); | ||
208 | wbkgdset(dialog, dialog_attr & A_COLOR); | ||
209 | waddch(dialog, ACS_RTEE); | ||
210 | |||
211 | print_title(dialog, title, width); | ||
212 | |||
213 | wattrset(dialog, dialog_attr); | ||
214 | print_autowrap(dialog, prompt, width - 2, 1, 3); | ||
215 | |||
216 | menu_width = width - 6; | ||
217 | box_y = height - menu_height - 5; | ||
218 | box_x = (width - menu_width) / 2 - 1; | ||
219 | |||
220 | /* create new window for the menu */ | ||
221 | menu = subwin(dialog, menu_height, menu_width, | ||
222 | y + box_y + 1, x + box_x + 1); | ||
223 | keypad(menu, TRUE); | ||
224 | |||
225 | /* draw a box around the menu items */ | ||
226 | draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, | ||
227 | menubox_border_attr, menubox_attr); | ||
228 | |||
229 | item_x = (menu_width - 70) / 2; | ||
230 | |||
231 | /* Set choice to default item */ | ||
232 | for (i = 0; i < item_no; i++) | ||
233 | if (strcmp(current, items[i * 2]) == 0) | ||
234 | choice = i; | ||
235 | |||
236 | /* get the scroll info from the temp file */ | ||
237 | if ((f = fopen("lxdialog.scrltmp", "r")) != NULL) { | ||
238 | if ((fscanf(f, "%d\n", &scroll) == 1) && (scroll <= choice) && | ||
239 | (scroll + max_choice > choice) && (scroll >= 0) && | ||
240 | (scroll + max_choice <= item_no)) { | ||
241 | first_item = scroll; | ||
242 | choice = choice - scroll; | ||
243 | fclose(f); | ||
244 | } else { | ||
245 | scroll = 0; | ||
246 | remove("lxdialog.scrltmp"); | ||
247 | fclose(f); | ||
248 | f = NULL; | ||
249 | } | ||
250 | } | ||
251 | if ((choice >= max_choice) || (f == NULL && choice >= max_choice / 2)) { | ||
252 | if (choice >= item_no - max_choice / 2) | ||
253 | scroll = first_item = item_no - max_choice; | ||
254 | else | ||
255 | scroll = first_item = choice - max_choice / 2; | ||
256 | choice = choice - scroll; | ||
257 | } | ||
258 | |||
259 | /* Print the menu */ | ||
260 | for (i = 0; i < max_choice; i++) { | ||
261 | print_item(first_item + i, i, i == choice); | ||
262 | } | ||
263 | |||
264 | wnoutrefresh(menu); | ||
265 | |||
266 | print_arrows(dialog, item_no, scroll, | ||
267 | box_y, box_x + item_x + 1, menu_height); | ||
268 | |||
269 | print_buttons(dialog, height, width, 0); | ||
270 | wmove(menu, choice, item_x + 1); | ||
271 | wrefresh(menu); | ||
272 | |||
273 | while (key != ESC) { | ||
274 | key = wgetch(menu); | ||
275 | |||
276 | if (key < 256 && isalpha(key)) | ||
277 | key = tolower(key); | ||
278 | |||
279 | if (strchr("ynmh", key)) | ||
280 | i = max_choice; | ||
281 | else { | ||
282 | for (i = choice + 1; i < max_choice; i++) { | ||
283 | j = first_alpha(items[(scroll + i) * 2 + 1], "YyNnMmHh"); | ||
284 | if (key == tolower(items[(scroll + i) * 2 + 1][j])) | ||
285 | break; | ||
286 | } | ||
287 | if (i == max_choice) | ||
288 | for (i = 0; i < max_choice; i++) { | ||
289 | j = first_alpha(items [(scroll + i) * 2 + 1], "YyNnMmHh"); | ||
290 | if (key == tolower(items[(scroll + i) * 2 + 1][j])) | ||
291 | break; | ||
292 | } | ||
293 | } | ||
294 | |||
295 | if (i < max_choice || | ||
296 | key == KEY_UP || key == KEY_DOWN || | ||
297 | key == '-' || key == '+' || | ||
298 | key == KEY_PPAGE || key == KEY_NPAGE) { | ||
299 | /* Remove highligt of current item */ | ||
300 | print_item(scroll + choice, choice, FALSE); | ||
301 | |||
302 | if (key == KEY_UP || key == '-') { | ||
303 | if (choice < 2 && scroll) { | ||
304 | /* Scroll menu down */ | ||
305 | do_scroll(menu, &scroll, -1); | ||
306 | |||
307 | print_item(scroll, 0, FALSE); | ||
308 | } else | ||
309 | choice = MAX(choice - 1, 0); | ||
310 | |||
311 | } else if (key == KEY_DOWN || key == '+') { | ||
312 | print_item(scroll+choice, choice, FALSE); | ||
313 | |||
314 | if ((choice > max_choice - 3) && | ||
315 | (scroll + max_choice < item_no)) { | ||
316 | /* Scroll menu up */ | ||
317 | do_scroll(menu, &scroll, 1); | ||
318 | |||
319 | print_item(scroll+max_choice - 1, | ||
320 | max_choice - 1, FALSE); | ||
321 | } else | ||
322 | choice = MIN(choice + 1, max_choice - 1); | ||
323 | |||
324 | } else if (key == KEY_PPAGE) { | ||
325 | scrollok(menu, TRUE); | ||
326 | for (i = 0; (i < max_choice); i++) { | ||
327 | if (scroll > 0) { | ||
328 | do_scroll(menu, &scroll, -1); | ||
329 | print_item(scroll, 0, FALSE); | ||
330 | } else { | ||
331 | if (choice > 0) | ||
332 | choice--; | ||
333 | } | ||
334 | } | ||
335 | |||
336 | } else if (key == KEY_NPAGE) { | ||
337 | for (i = 0; (i < max_choice); i++) { | ||
338 | if (scroll + max_choice < item_no) { | ||
339 | do_scroll(menu, &scroll, 1); | ||
340 | print_item(scroll+max_choice-1, | ||
341 | max_choice - 1, FALSE); | ||
342 | } else { | ||
343 | if (choice + 1 < max_choice) | ||
344 | choice++; | ||
345 | } | ||
346 | } | ||
347 | } else | ||
348 | choice = i; | ||
349 | |||
350 | print_item(scroll + choice, choice, TRUE); | ||
351 | |||
352 | print_arrows(dialog, item_no, scroll, | ||
353 | box_y, box_x + item_x + 1, menu_height); | ||
354 | |||
355 | wnoutrefresh(dialog); | ||
356 | wrefresh(menu); | ||
357 | |||
358 | continue; /* wait for another key press */ | ||
359 | } | ||
360 | |||
361 | switch (key) { | ||
362 | case KEY_LEFT: | ||
363 | case TAB: | ||
364 | case KEY_RIGHT: | ||
365 | button = ((key == KEY_LEFT ? --button : ++button) < 0) | ||
366 | ? 2 : (button > 2 ? 0 : button); | ||
367 | |||
368 | print_buttons(dialog, height, width, button); | ||
369 | wrefresh(menu); | ||
370 | break; | ||
371 | case ' ': | ||
372 | case 's': | ||
373 | case 'y': | ||
374 | case 'n': | ||
375 | case 'm': | ||
376 | case '/': | ||
377 | /* save scroll info */ | ||
378 | if ((f = fopen("lxdialog.scrltmp", "w")) != NULL) { | ||
379 | fprintf(f, "%d\n", scroll); | ||
380 | fclose(f); | ||
381 | } | ||
382 | delwin(dialog); | ||
383 | fprintf(stderr, "%s\n", items[(scroll + choice) * 2]); | ||
384 | switch (key) { | ||
385 | case 's': | ||
386 | return 3; | ||
387 | case 'y': | ||
388 | return 3; | ||
389 | case 'n': | ||
390 | return 4; | ||
391 | case 'm': | ||
392 | return 5; | ||
393 | case ' ': | ||
394 | return 6; | ||
395 | case '/': | ||
396 | return 7; | ||
397 | } | ||
398 | return 0; | ||
399 | case 'h': | ||
400 | case '?': | ||
401 | button = 2; | ||
402 | case '\n': | ||
403 | delwin(dialog); | ||
404 | if (button == 2) | ||
405 | fprintf(stderr, "%s \"%s\"\n", | ||
406 | items[(scroll + choice) * 2], | ||
407 | items[(scroll + choice) * 2 + 1] + | ||
408 | first_alpha(items [(scroll + choice) * 2 + 1], "")); | ||
409 | else | ||
410 | fprintf(stderr, "%s\n", | ||
411 | items[(scroll + choice) * 2]); | ||
412 | |||
413 | remove("lxdialog.scrltmp"); | ||
414 | return button; | ||
415 | case 'e': | ||
416 | case 'x': | ||
417 | key = ESC; | ||
418 | case ESC: | ||
419 | break; | ||
420 | } | ||
421 | } | ||
422 | |||
423 | delwin(dialog); | ||
424 | remove("lxdialog.scrltmp"); | ||
425 | return -1; /* ESC pressed */ | ||
426 | } | ||
diff --git a/scripts/kconfig/lxdialog/msgbox.c b/scripts/kconfig/lxdialog/msgbox.c new file mode 100644 index 000000000..7323f5471 --- /dev/null +++ b/scripts/kconfig/lxdialog/msgbox.c | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * msgbox.c -- implements the message box and info box | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) | ||
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 | #include "dialog.h" | ||
23 | |||
24 | /* | ||
25 | * Display a message box. Program will pause and display an "OK" button | ||
26 | * if the parameter 'pause' is non-zero. | ||
27 | */ | ||
28 | int dialog_msgbox(const char *title, const char *prompt, int height, int width, | ||
29 | int pause) | ||
30 | { | ||
31 | int i, x, y, key = 0; | ||
32 | WINDOW *dialog; | ||
33 | |||
34 | /* center dialog box on screen */ | ||
35 | x = (COLS - width) / 2; | ||
36 | y = (LINES - height) / 2; | ||
37 | |||
38 | draw_shadow(stdscr, y, x, height, width); | ||
39 | |||
40 | dialog = newwin(height, width, y, x); | ||
41 | keypad(dialog, TRUE); | ||
42 | |||
43 | draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); | ||
44 | |||
45 | print_title(dialog, title, width); | ||
46 | |||
47 | wattrset(dialog, dialog_attr); | ||
48 | print_autowrap(dialog, prompt, width - 2, 1, 2); | ||
49 | |||
50 | if (pause) { | ||
51 | wattrset(dialog, border_attr); | ||
52 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); | ||
53 | for (i = 0; i < width - 2; i++) | ||
54 | waddch(dialog, ACS_HLINE); | ||
55 | wattrset(dialog, dialog_attr); | ||
56 | waddch(dialog, ACS_RTEE); | ||
57 | |||
58 | print_button(dialog, " Ok ", height - 2, width / 2 - 4, TRUE); | ||
59 | |||
60 | wrefresh(dialog); | ||
61 | while (key != ESC && key != '\n' && key != ' ' && | ||
62 | key != 'O' && key != 'o' && key != 'X' && key != 'x') | ||
63 | key = wgetch(dialog); | ||
64 | } else { | ||
65 | key = '\n'; | ||
66 | wrefresh(dialog); | ||
67 | } | ||
68 | |||
69 | delwin(dialog); | ||
70 | return key == ESC ? -1 : 0; | ||
71 | } | ||
diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c new file mode 100644 index 000000000..77848bb8e --- /dev/null +++ b/scripts/kconfig/lxdialog/textbox.c | |||
@@ -0,0 +1,533 @@ | |||
1 | /* | ||
2 | * textbox.c -- implements the text box | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) | ||
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 | #include "dialog.h" | ||
23 | |||
24 | static void back_lines(int n); | ||
25 | static void print_page(WINDOW * win, int height, int width); | ||
26 | static void print_line(WINDOW * win, int row, int width); | ||
27 | static char *get_line(void); | ||
28 | static void print_position(WINDOW * win, int height, int width); | ||
29 | |||
30 | static int hscroll, fd, file_size, bytes_read; | ||
31 | static int begin_reached = 1, end_reached, page_length; | ||
32 | static char *buf, *page; | ||
33 | |||
34 | /* | ||
35 | * Display text from a file in a dialog box. | ||
36 | */ | ||
37 | int dialog_textbox(const char *title, const char *file, int height, int width) | ||
38 | { | ||
39 | int i, x, y, cur_x, cur_y, fpos, key = 0; | ||
40 | int passed_end; | ||
41 | char search_term[MAX_LEN + 1]; | ||
42 | WINDOW *dialog, *text; | ||
43 | |||
44 | search_term[0] = '\0'; /* no search term entered yet */ | ||
45 | |||
46 | /* Open input file for reading */ | ||
47 | if ((fd = open(file, O_RDONLY)) == -1) { | ||
48 | endwin(); | ||
49 | fprintf(stderr, "\nCan't open input file in dialog_textbox().\n"); | ||
50 | exit(-1); | ||
51 | } | ||
52 | /* Get file size. Actually, 'file_size' is the real file size - 1, | ||
53 | since it's only the last byte offset from the beginning */ | ||
54 | if ((file_size = lseek(fd, 0, SEEK_END)) == -1) { | ||
55 | endwin(); | ||
56 | fprintf(stderr, "\nError getting file size in dialog_textbox().\n"); | ||
57 | exit(-1); | ||
58 | } | ||
59 | /* Restore file pointer to beginning of file after getting file size */ | ||
60 | if (lseek(fd, 0, SEEK_SET) == -1) { | ||
61 | endwin(); | ||
62 | fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); | ||
63 | exit(-1); | ||
64 | } | ||
65 | /* Allocate space for read buffer */ | ||
66 | if ((buf = malloc(BUF_SIZE + 1)) == NULL) { | ||
67 | endwin(); | ||
68 | fprintf(stderr, "\nCan't allocate memory in dialog_textbox().\n"); | ||
69 | exit(-1); | ||
70 | } | ||
71 | if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) { | ||
72 | endwin(); | ||
73 | fprintf(stderr, "\nError reading file in dialog_textbox().\n"); | ||
74 | exit(-1); | ||
75 | } | ||
76 | buf[bytes_read] = '\0'; /* mark end of valid data */ | ||
77 | page = buf; /* page is pointer to start of page to be displayed */ | ||
78 | |||
79 | /* center dialog box on screen */ | ||
80 | x = (COLS - width) / 2; | ||
81 | y = (LINES - height) / 2; | ||
82 | |||
83 | draw_shadow(stdscr, y, x, height, width); | ||
84 | |||
85 | dialog = newwin(height, width, y, x); | ||
86 | keypad(dialog, TRUE); | ||
87 | |||
88 | /* Create window for text region, used for scrolling text */ | ||
89 | text = subwin(dialog, height - 4, width - 2, y + 1, x + 1); | ||
90 | wattrset(text, dialog_attr); | ||
91 | wbkgdset(text, dialog_attr & A_COLOR); | ||
92 | |||
93 | keypad(text, TRUE); | ||
94 | |||
95 | /* register the new window, along with its borders */ | ||
96 | draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); | ||
97 | |||
98 | wattrset(dialog, border_attr); | ||
99 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); | ||
100 | for (i = 0; i < width - 2; i++) | ||
101 | waddch(dialog, ACS_HLINE); | ||
102 | wattrset(dialog, dialog_attr); | ||
103 | wbkgdset(dialog, dialog_attr & A_COLOR); | ||
104 | waddch(dialog, ACS_RTEE); | ||
105 | |||
106 | print_title(dialog, title, width); | ||
107 | |||
108 | print_button(dialog, " Exit ", height - 2, width / 2 - 4, TRUE); | ||
109 | wnoutrefresh(dialog); | ||
110 | getyx(dialog, cur_y, cur_x); /* Save cursor position */ | ||
111 | |||
112 | /* Print first page of text */ | ||
113 | attr_clear(text, height - 4, width - 2, dialog_attr); | ||
114 | print_page(text, height - 4, width - 2); | ||
115 | print_position(dialog, height, width); | ||
116 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ | ||
117 | wrefresh(dialog); | ||
118 | |||
119 | while ((key != ESC) && (key != '\n')) { | ||
120 | key = wgetch(dialog); | ||
121 | switch (key) { | ||
122 | case 'E': /* Exit */ | ||
123 | case 'e': | ||
124 | case 'X': | ||
125 | case 'x': | ||
126 | delwin(dialog); | ||
127 | free(buf); | ||
128 | close(fd); | ||
129 | return 0; | ||
130 | case 'g': /* First page */ | ||
131 | case KEY_HOME: | ||
132 | if (!begin_reached) { | ||
133 | begin_reached = 1; | ||
134 | /* First page not in buffer? */ | ||
135 | if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { | ||
136 | endwin(); | ||
137 | fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); | ||
138 | exit(-1); | ||
139 | } | ||
140 | if (fpos > bytes_read) { /* Yes, we have to read it in */ | ||
141 | if (lseek(fd, 0, SEEK_SET) == -1) { | ||
142 | endwin(); | ||
143 | fprintf(stderr, "\nError moving file pointer in " | ||
144 | "dialog_textbox().\n"); | ||
145 | exit(-1); | ||
146 | } | ||
147 | if ((bytes_read = | ||
148 | read(fd, buf, BUF_SIZE)) == -1) { | ||
149 | endwin(); | ||
150 | fprintf(stderr, "\nError reading file in dialog_textbox().\n"); | ||
151 | exit(-1); | ||
152 | } | ||
153 | buf[bytes_read] = '\0'; | ||
154 | } | ||
155 | page = buf; | ||
156 | print_page(text, height - 4, width - 2); | ||
157 | print_position(dialog, height, width); | ||
158 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ | ||
159 | wrefresh(dialog); | ||
160 | } | ||
161 | break; | ||
162 | case 'G': /* Last page */ | ||
163 | case KEY_END: | ||
164 | |||
165 | end_reached = 1; | ||
166 | /* Last page not in buffer? */ | ||
167 | if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { | ||
168 | endwin(); | ||
169 | fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); | ||
170 | exit(-1); | ||
171 | } | ||
172 | if (fpos < file_size) { /* Yes, we have to read it in */ | ||
173 | if (lseek(fd, -BUF_SIZE, SEEK_END) == -1) { | ||
174 | endwin(); | ||
175 | fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); | ||
176 | exit(-1); | ||
177 | } | ||
178 | if ((bytes_read = | ||
179 | read(fd, buf, BUF_SIZE)) == -1) { | ||
180 | endwin(); | ||
181 | fprintf(stderr, "\nError reading file in dialog_textbox().\n"); | ||
182 | exit(-1); | ||
183 | } | ||
184 | buf[bytes_read] = '\0'; | ||
185 | } | ||
186 | page = buf + bytes_read; | ||
187 | back_lines(height - 4); | ||
188 | print_page(text, height - 4, width - 2); | ||
189 | print_position(dialog, height, width); | ||
190 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ | ||
191 | wrefresh(dialog); | ||
192 | break; | ||
193 | case 'K': /* Previous line */ | ||
194 | case 'k': | ||
195 | case KEY_UP: | ||
196 | if (!begin_reached) { | ||
197 | back_lines(page_length + 1); | ||
198 | |||
199 | /* We don't call print_page() here but use scrolling to ensure | ||
200 | faster screen update. However, 'end_reached' and | ||
201 | 'page_length' should still be updated, and 'page' should | ||
202 | point to start of next page. This is done by calling | ||
203 | get_line() in the following 'for' loop. */ | ||
204 | scrollok(text, TRUE); | ||
205 | wscrl(text, -1); /* Scroll text region down one line */ | ||
206 | scrollok(text, FALSE); | ||
207 | page_length = 0; | ||
208 | passed_end = 0; | ||
209 | for (i = 0; i < height - 4; i++) { | ||
210 | if (!i) { | ||
211 | /* print first line of page */ | ||
212 | print_line(text, 0, width - 2); | ||
213 | wnoutrefresh(text); | ||
214 | } else | ||
215 | /* Called to update 'end_reached' and 'page' */ | ||
216 | get_line(); | ||
217 | if (!passed_end) | ||
218 | page_length++; | ||
219 | if (end_reached && !passed_end) | ||
220 | passed_end = 1; | ||
221 | } | ||
222 | |||
223 | print_position(dialog, height, width); | ||
224 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ | ||
225 | wrefresh(dialog); | ||
226 | } | ||
227 | break; | ||
228 | case 'B': /* Previous page */ | ||
229 | case 'b': | ||
230 | case KEY_PPAGE: | ||
231 | if (begin_reached) | ||
232 | break; | ||
233 | back_lines(page_length + height - 4); | ||
234 | print_page(text, height - 4, width - 2); | ||
235 | print_position(dialog, height, width); | ||
236 | wmove(dialog, cur_y, cur_x); | ||
237 | wrefresh(dialog); | ||
238 | break; | ||
239 | case 'J': /* Next line */ | ||
240 | case 'j': | ||
241 | case KEY_DOWN: | ||
242 | if (!end_reached) { | ||
243 | begin_reached = 0; | ||
244 | scrollok(text, TRUE); | ||
245 | scroll(text); /* Scroll text region up one line */ | ||
246 | scrollok(text, FALSE); | ||
247 | print_line(text, height - 5, width - 2); | ||
248 | wnoutrefresh(text); | ||
249 | print_position(dialog, height, width); | ||
250 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ | ||
251 | wrefresh(dialog); | ||
252 | } | ||
253 | break; | ||
254 | case KEY_NPAGE: /* Next page */ | ||
255 | case ' ': | ||
256 | if (end_reached) | ||
257 | break; | ||
258 | |||
259 | begin_reached = 0; | ||
260 | print_page(text, height - 4, width - 2); | ||
261 | print_position(dialog, height, width); | ||
262 | wmove(dialog, cur_y, cur_x); | ||
263 | wrefresh(dialog); | ||
264 | break; | ||
265 | case '0': /* Beginning of line */ | ||
266 | case 'H': /* Scroll left */ | ||
267 | case 'h': | ||
268 | case KEY_LEFT: | ||
269 | if (hscroll <= 0) | ||
270 | break; | ||
271 | |||
272 | if (key == '0') | ||
273 | hscroll = 0; | ||
274 | else | ||
275 | hscroll--; | ||
276 | /* Reprint current page to scroll horizontally */ | ||
277 | back_lines(page_length); | ||
278 | print_page(text, height - 4, width - 2); | ||
279 | wmove(dialog, cur_y, cur_x); | ||
280 | wrefresh(dialog); | ||
281 | break; | ||
282 | case 'L': /* Scroll right */ | ||
283 | case 'l': | ||
284 | case KEY_RIGHT: | ||
285 | if (hscroll >= MAX_LEN) | ||
286 | break; | ||
287 | hscroll++; | ||
288 | /* Reprint current page to scroll horizontally */ | ||
289 | back_lines(page_length); | ||
290 | print_page(text, height - 4, width - 2); | ||
291 | wmove(dialog, cur_y, cur_x); | ||
292 | wrefresh(dialog); | ||
293 | break; | ||
294 | case ESC: | ||
295 | break; | ||
296 | } | ||
297 | } | ||
298 | |||
299 | delwin(dialog); | ||
300 | free(buf); | ||
301 | close(fd); | ||
302 | return -1; /* ESC pressed */ | ||
303 | } | ||
304 | |||
305 | /* | ||
306 | * Go back 'n' lines in text file. Called by dialog_textbox(). | ||
307 | * 'page' will be updated to point to the desired line in 'buf'. | ||
308 | */ | ||
309 | static void back_lines(int n) | ||
310 | { | ||
311 | int i, fpos; | ||
312 | |||
313 | begin_reached = 0; | ||
314 | /* We have to distinguish between end_reached and !end_reached | ||
315 | since at end of file, the line is not ended by a '\n'. | ||
316 | The code inside 'if' basically does a '--page' to move one | ||
317 | character backward so as to skip '\n' of the previous line */ | ||
318 | if (!end_reached) { | ||
319 | /* Either beginning of buffer or beginning of file reached? */ | ||
320 | if (page == buf) { | ||
321 | if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { | ||
322 | endwin(); | ||
323 | fprintf(stderr, "\nError moving file pointer in " | ||
324 | "back_lines().\n"); | ||
325 | exit(-1); | ||
326 | } | ||
327 | if (fpos > bytes_read) { /* Not beginning of file yet */ | ||
328 | /* We've reached beginning of buffer, but not beginning of | ||
329 | file yet, so read previous part of file into buffer. | ||
330 | Note that we only move backward for BUF_SIZE/2 bytes, | ||
331 | but not BUF_SIZE bytes to avoid re-reading again in | ||
332 | print_page() later */ | ||
333 | /* Really possible to move backward BUF_SIZE/2 bytes? */ | ||
334 | if (fpos < BUF_SIZE / 2 + bytes_read) { | ||
335 | /* No, move less then */ | ||
336 | if (lseek(fd, 0, SEEK_SET) == -1) { | ||
337 | endwin(); | ||
338 | fprintf(stderr, "\nError moving file pointer in " | ||
339 | "back_lines().\n"); | ||
340 | exit(-1); | ||
341 | } | ||
342 | page = buf + fpos - bytes_read; | ||
343 | } else { /* Move backward BUF_SIZE/2 bytes */ | ||
344 | if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) == -1) { | ||
345 | endwin(); | ||
346 | fprintf(stderr, "\nError moving file pointer " | ||
347 | "in back_lines().\n"); | ||
348 | exit(-1); | ||
349 | } | ||
350 | page = buf + BUF_SIZE / 2; | ||
351 | } | ||
352 | if ((bytes_read = | ||
353 | read(fd, buf, BUF_SIZE)) == -1) { | ||
354 | endwin(); | ||
355 | fprintf(stderr, "\nError reading file in back_lines().\n"); | ||
356 | exit(-1); | ||
357 | } | ||
358 | buf[bytes_read] = '\0'; | ||
359 | } else { /* Beginning of file reached */ | ||
360 | begin_reached = 1; | ||
361 | return; | ||
362 | } | ||
363 | } | ||
364 | if (*(--page) != '\n') { /* '--page' here */ | ||
365 | /* Something's wrong... */ | ||
366 | endwin(); | ||
367 | fprintf(stderr, "\nInternal error in back_lines().\n"); | ||
368 | exit(-1); | ||
369 | } | ||
370 | } | ||
371 | /* Go back 'n' lines */ | ||
372 | for (i = 0; i < n; i++) | ||
373 | do { | ||
374 | if (page == buf) { | ||
375 | if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { | ||
376 | endwin(); | ||
377 | fprintf(stderr, "\nError moving file pointer in back_lines().\n"); | ||
378 | exit(-1); | ||
379 | } | ||
380 | if (fpos > bytes_read) { | ||
381 | /* Really possible to move backward BUF_SIZE/2 bytes? */ | ||
382 | if (fpos < BUF_SIZE / 2 + bytes_read) { | ||
383 | /* No, move less then */ | ||
384 | if (lseek(fd, 0, SEEK_SET) == -1) { | ||
385 | endwin(); | ||
386 | fprintf(stderr, "\nError moving file pointer " | ||
387 | "in back_lines().\n"); | ||
388 | exit(-1); | ||
389 | } | ||
390 | page = buf + fpos - bytes_read; | ||
391 | } else { /* Move backward BUF_SIZE/2 bytes */ | ||
392 | if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) == -1) { | ||
393 | endwin(); | ||
394 | fprintf(stderr, "\nError moving file pointer" | ||
395 | " in back_lines().\n"); | ||
396 | exit(-1); | ||
397 | } | ||
398 | page = buf + BUF_SIZE / 2; | ||
399 | } | ||
400 | if ((bytes_read = | ||
401 | read(fd, buf, BUF_SIZE)) == -1) { | ||
402 | endwin(); | ||
403 | fprintf(stderr, "\nError reading file in " | ||
404 | "back_lines().\n"); | ||
405 | exit(-1); | ||
406 | } | ||
407 | buf[bytes_read] = '\0'; | ||
408 | } else { /* Beginning of file reached */ | ||
409 | begin_reached = 1; | ||
410 | return; | ||
411 | } | ||
412 | } | ||
413 | } while (*(--page) != '\n'); | ||
414 | page++; | ||
415 | } | ||
416 | |||
417 | /* | ||
418 | * Print a new page of text. Called by dialog_textbox(). | ||
419 | */ | ||
420 | static void print_page(WINDOW * win, int height, int width) | ||
421 | { | ||
422 | int i, passed_end = 0; | ||
423 | |||
424 | page_length = 0; | ||
425 | for (i = 0; i < height; i++) { | ||
426 | print_line(win, i, width); | ||
427 | if (!passed_end) | ||
428 | page_length++; | ||
429 | if (end_reached && !passed_end) | ||
430 | passed_end = 1; | ||
431 | } | ||
432 | wnoutrefresh(win); | ||
433 | } | ||
434 | |||
435 | /* | ||
436 | * Print a new line of text. Called by dialog_textbox() and print_page(). | ||
437 | */ | ||
438 | static void print_line(WINDOW * win, int row, int width) | ||
439 | { | ||
440 | int y, x; | ||
441 | char *line; | ||
442 | |||
443 | line = get_line(); | ||
444 | line += MIN(strlen(line), hscroll); /* Scroll horizontally */ | ||
445 | wmove(win, row, 0); /* move cursor to correct line */ | ||
446 | waddch(win, ' '); | ||
447 | waddnstr(win, line, MIN(strlen(line), width - 2)); | ||
448 | |||
449 | getyx(win, y, x); | ||
450 | /* Clear 'residue' of previous line */ | ||
451 | #if OLD_NCURSES | ||
452 | { | ||
453 | int i; | ||
454 | for (i = 0; i < width - x; i++) | ||
455 | waddch(win, ' '); | ||
456 | } | ||
457 | #else | ||
458 | wclrtoeol(win); | ||
459 | #endif | ||
460 | } | ||
461 | |||
462 | /* | ||
463 | * Return current line of text. Called by dialog_textbox() and print_line(). | ||
464 | * 'page' should point to start of current line before calling, and will be | ||
465 | * updated to point to start of next line. | ||
466 | */ | ||
467 | static char *get_line(void) | ||
468 | { | ||
469 | int i = 0, fpos; | ||
470 | static char line[MAX_LEN + 1]; | ||
471 | |||
472 | end_reached = 0; | ||
473 | while (*page != '\n') { | ||
474 | if (*page == '\0') { | ||
475 | /* Either end of file or end of buffer reached */ | ||
476 | if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { | ||
477 | endwin(); | ||
478 | fprintf(stderr, "\nError moving file pointer in " | ||
479 | "get_line().\n"); | ||
480 | exit(-1); | ||
481 | } | ||
482 | if (fpos < file_size) { /* Not end of file yet */ | ||
483 | /* We've reached end of buffer, but not end of file yet, | ||
484 | so read next part of file into buffer */ | ||
485 | if ((bytes_read = | ||
486 | read(fd, buf, BUF_SIZE)) == -1) { | ||
487 | endwin(); | ||
488 | fprintf(stderr, "\nError reading file in get_line().\n"); | ||
489 | exit(-1); | ||
490 | } | ||
491 | buf[bytes_read] = '\0'; | ||
492 | page = buf; | ||
493 | } else { | ||
494 | if (!end_reached) | ||
495 | end_reached = 1; | ||
496 | break; | ||
497 | } | ||
498 | } else if (i < MAX_LEN) | ||
499 | line[i++] = *(page++); | ||
500 | else { | ||
501 | /* Truncate lines longer than MAX_LEN characters */ | ||
502 | if (i == MAX_LEN) | ||
503 | line[i++] = '\0'; | ||
504 | page++; | ||
505 | } | ||
506 | } | ||
507 | if (i <= MAX_LEN) | ||
508 | line[i] = '\0'; | ||
509 | if (!end_reached) | ||
510 | page++; /* move pass '\n' */ | ||
511 | |||
512 | return line; | ||
513 | } | ||
514 | |||
515 | /* | ||
516 | * Print current position | ||
517 | */ | ||
518 | static void print_position(WINDOW * win, int height, int width) | ||
519 | { | ||
520 | int fpos, percent; | ||
521 | |||
522 | if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { | ||
523 | endwin(); | ||
524 | fprintf(stderr, "\nError moving file pointer in print_position().\n"); | ||
525 | exit(-1); | ||
526 | } | ||
527 | wattrset(win, position_indicator_attr); | ||
528 | wbkgdset(win, position_indicator_attr & A_COLOR); | ||
529 | percent = !file_size ? | ||
530 | 100 : ((fpos - bytes_read + page - buf) * 100) / file_size; | ||
531 | wmove(win, height - 3, width - 9); | ||
532 | wprintw(win, "(%3d%%)", percent); | ||
533 | } | ||
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c new file mode 100644 index 000000000..f82cebb9f --- /dev/null +++ b/scripts/kconfig/lxdialog/util.c | |||
@@ -0,0 +1,362 @@ | |||
1 | /* | ||
2 | * util.c | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) | ||
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 | #include "dialog.h" | ||
23 | |||
24 | /* use colors by default? */ | ||
25 | bool use_colors = 1; | ||
26 | |||
27 | const char *backtitle = NULL; | ||
28 | |||
29 | /* | ||
30 | * Attribute values, default is for mono display | ||
31 | */ | ||
32 | chtype attributes[] = { | ||
33 | A_NORMAL, /* screen_attr */ | ||
34 | A_NORMAL, /* shadow_attr */ | ||
35 | A_NORMAL, /* dialog_attr */ | ||
36 | A_BOLD, /* title_attr */ | ||
37 | A_NORMAL, /* border_attr */ | ||
38 | A_REVERSE, /* button_active_attr */ | ||
39 | A_DIM, /* button_inactive_attr */ | ||
40 | A_REVERSE, /* button_key_active_attr */ | ||
41 | A_BOLD, /* button_key_inactive_attr */ | ||
42 | A_REVERSE, /* button_label_active_attr */ | ||
43 | A_NORMAL, /* button_label_inactive_attr */ | ||
44 | A_NORMAL, /* inputbox_attr */ | ||
45 | A_NORMAL, /* inputbox_border_attr */ | ||
46 | A_NORMAL, /* searchbox_attr */ | ||
47 | A_BOLD, /* searchbox_title_attr */ | ||
48 | A_NORMAL, /* searchbox_border_attr */ | ||
49 | A_BOLD, /* position_indicator_attr */ | ||
50 | A_NORMAL, /* menubox_attr */ | ||
51 | A_NORMAL, /* menubox_border_attr */ | ||
52 | A_NORMAL, /* item_attr */ | ||
53 | A_REVERSE, /* item_selected_attr */ | ||
54 | A_BOLD, /* tag_attr */ | ||
55 | A_REVERSE, /* tag_selected_attr */ | ||
56 | A_BOLD, /* tag_key_attr */ | ||
57 | A_REVERSE, /* tag_key_selected_attr */ | ||
58 | A_BOLD, /* check_attr */ | ||
59 | A_REVERSE, /* check_selected_attr */ | ||
60 | A_BOLD, /* uarrow_attr */ | ||
61 | A_BOLD /* darrow_attr */ | ||
62 | }; | ||
63 | |||
64 | #include "colors.h" | ||
65 | |||
66 | /* | ||
67 | * Table of color values | ||
68 | */ | ||
69 | int color_table[][3] = { | ||
70 | {SCREEN_FG, SCREEN_BG, SCREEN_HL}, | ||
71 | {SHADOW_FG, SHADOW_BG, SHADOW_HL}, | ||
72 | {DIALOG_FG, DIALOG_BG, DIALOG_HL}, | ||
73 | {TITLE_FG, TITLE_BG, TITLE_HL}, | ||
74 | {BORDER_FG, BORDER_BG, BORDER_HL}, | ||
75 | {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL}, | ||
76 | {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL}, | ||
77 | {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL}, | ||
78 | {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, | ||
79 | BUTTON_KEY_INACTIVE_HL}, | ||
80 | {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, | ||
81 | BUTTON_LABEL_ACTIVE_HL}, | ||
82 | {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG, | ||
83 | BUTTON_LABEL_INACTIVE_HL}, | ||
84 | {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL}, | ||
85 | {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL}, | ||
86 | {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL}, | ||
87 | {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL}, | ||
88 | {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL}, | ||
89 | {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL}, | ||
90 | {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL}, | ||
91 | {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL}, | ||
92 | {ITEM_FG, ITEM_BG, ITEM_HL}, | ||
93 | {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL}, | ||
94 | {TAG_FG, TAG_BG, TAG_HL}, | ||
95 | {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL}, | ||
96 | {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL}, | ||
97 | {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL}, | ||
98 | {CHECK_FG, CHECK_BG, CHECK_HL}, | ||
99 | {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, | ||
100 | {UARROW_FG, UARROW_BG, UARROW_HL}, | ||
101 | {DARROW_FG, DARROW_BG, DARROW_HL}, | ||
102 | }; /* color_table */ | ||
103 | |||
104 | /* | ||
105 | * Set window to attribute 'attr' | ||
106 | */ | ||
107 | void attr_clear(WINDOW * win, int height, int width, chtype attr) | ||
108 | { | ||
109 | int i, j; | ||
110 | |||
111 | wattrset(win, attr); | ||
112 | for (i = 0; i < height; i++) { | ||
113 | wmove(win, i, 0); | ||
114 | for (j = 0; j < width; j++) | ||
115 | waddch(win, ' '); | ||
116 | } | ||
117 | touchwin(win); | ||
118 | } | ||
119 | |||
120 | void dialog_clear(void) | ||
121 | { | ||
122 | attr_clear(stdscr, LINES, COLS, screen_attr); | ||
123 | /* Display background title if it exists ... - SLH */ | ||
124 | if (backtitle != NULL) { | ||
125 | int i; | ||
126 | |||
127 | wattrset(stdscr, screen_attr); | ||
128 | mvwaddstr(stdscr, 0, 1, (char *)backtitle); | ||
129 | wmove(stdscr, 1, 1); | ||
130 | for (i = 1; i < COLS - 1; i++) | ||
131 | waddch(stdscr, ACS_HLINE); | ||
132 | } | ||
133 | wnoutrefresh(stdscr); | ||
134 | } | ||
135 | |||
136 | /* | ||
137 | * Do some initialization for dialog | ||
138 | */ | ||
139 | void init_dialog(void) | ||
140 | { | ||
141 | initscr(); /* Init curses */ | ||
142 | keypad(stdscr, TRUE); | ||
143 | cbreak(); | ||
144 | noecho(); | ||
145 | |||
146 | if (use_colors) /* Set up colors */ | ||
147 | color_setup(); | ||
148 | |||
149 | dialog_clear(); | ||
150 | } | ||
151 | |||
152 | /* | ||
153 | * Setup for color display | ||
154 | */ | ||
155 | void color_setup(void) | ||
156 | { | ||
157 | int i; | ||
158 | |||
159 | if (has_colors()) { /* Terminal supports color? */ | ||
160 | start_color(); | ||
161 | |||
162 | /* Initialize color pairs */ | ||
163 | for (i = 0; i < ATTRIBUTE_COUNT; i++) | ||
164 | init_pair(i + 1, color_table[i][0], color_table[i][1]); | ||
165 | |||
166 | /* Setup color attributes */ | ||
167 | for (i = 0; i < ATTRIBUTE_COUNT; i++) | ||
168 | attributes[i] = C_ATTR(color_table[i][2], i + 1); | ||
169 | } | ||
170 | } | ||
171 | |||
172 | /* | ||
173 | * End using dialog functions. | ||
174 | */ | ||
175 | void end_dialog(void) | ||
176 | { | ||
177 | endwin(); | ||
178 | } | ||
179 | |||
180 | /* Print the title of the dialog. Center the title and truncate | ||
181 | * tile if wider than dialog (- 2 chars). | ||
182 | **/ | ||
183 | void print_title(WINDOW *dialog, const char *title, int width) | ||
184 | { | ||
185 | if (title) { | ||
186 | int tlen = MIN(width - 2, strlen(title)); | ||
187 | wattrset(dialog, title_attr); | ||
188 | mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' '); | ||
189 | mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen); | ||
190 | waddch(dialog, ' '); | ||
191 | } | ||
192 | } | ||
193 | |||
194 | /* | ||
195 | * Print a string of text in a window, automatically wrap around to the | ||
196 | * next line if the string is too long to fit on one line. Newline | ||
197 | * characters '\n' are replaced by spaces. We start on a new line | ||
198 | * if there is no room for at least 4 nonblanks following a double-space. | ||
199 | */ | ||
200 | void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) | ||
201 | { | ||
202 | int newl, cur_x, cur_y; | ||
203 | int i, prompt_len, room, wlen; | ||
204 | char tempstr[MAX_LEN + 1], *word, *sp, *sp2; | ||
205 | |||
206 | strcpy(tempstr, prompt); | ||
207 | |||
208 | prompt_len = strlen(tempstr); | ||
209 | |||
210 | /* | ||
211 | * Remove newlines | ||
212 | */ | ||
213 | for (i = 0; i < prompt_len; i++) { | ||
214 | if (tempstr[i] == '\n') | ||
215 | tempstr[i] = ' '; | ||
216 | } | ||
217 | |||
218 | if (prompt_len <= width - x * 2) { /* If prompt is short */ | ||
219 | wmove(win, y, (width - prompt_len) / 2); | ||
220 | waddstr(win, tempstr); | ||
221 | } else { | ||
222 | cur_x = x; | ||
223 | cur_y = y; | ||
224 | newl = 1; | ||
225 | word = tempstr; | ||
226 | while (word && *word) { | ||
227 | sp = index(word, ' '); | ||
228 | if (sp) | ||
229 | *sp++ = 0; | ||
230 | |||
231 | /* Wrap to next line if either the word does not fit, | ||
232 | or it is the first word of a new sentence, and it is | ||
233 | short, and the next word does not fit. */ | ||
234 | room = width - cur_x; | ||
235 | wlen = strlen(word); | ||
236 | if (wlen > room || | ||
237 | (newl && wlen < 4 && sp | ||
238 | && wlen + 1 + strlen(sp) > room | ||
239 | && (!(sp2 = index(sp, ' ')) | ||
240 | || wlen + 1 + (sp2 - sp) > room))) { | ||
241 | cur_y++; | ||
242 | cur_x = x; | ||
243 | } | ||
244 | wmove(win, cur_y, cur_x); | ||
245 | waddstr(win, word); | ||
246 | getyx(win, cur_y, cur_x); | ||
247 | cur_x++; | ||
248 | if (sp && *sp == ' ') { | ||
249 | cur_x++; /* double space */ | ||
250 | while (*++sp == ' ') ; | ||
251 | newl = 1; | ||
252 | } else | ||
253 | newl = 0; | ||
254 | word = sp; | ||
255 | } | ||
256 | } | ||
257 | } | ||
258 | |||
259 | /* | ||
260 | * Print a button | ||
261 | */ | ||
262 | void print_button(WINDOW * win, const char *label, int y, int x, int selected) | ||
263 | { | ||
264 | int i, temp; | ||
265 | |||
266 | wmove(win, y, x); | ||
267 | wattrset(win, selected ? button_active_attr : button_inactive_attr); | ||
268 | waddstr(win, "<"); | ||
269 | temp = strspn(label, " "); | ||
270 | label += temp; | ||
271 | wattrset(win, selected ? button_label_active_attr | ||
272 | : button_label_inactive_attr); | ||
273 | for (i = 0; i < temp; i++) | ||
274 | waddch(win, ' '); | ||
275 | wattrset(win, selected ? button_key_active_attr | ||
276 | : button_key_inactive_attr); | ||
277 | waddch(win, label[0]); | ||
278 | wattrset(win, selected ? button_label_active_attr | ||
279 | : button_label_inactive_attr); | ||
280 | waddstr(win, (char *)label + 1); | ||
281 | wattrset(win, selected ? button_active_attr : button_inactive_attr); | ||
282 | waddstr(win, ">"); | ||
283 | wmove(win, y, x + temp + 1); | ||
284 | } | ||
285 | |||
286 | /* | ||
287 | * Draw a rectangular box with line drawing characters | ||
288 | */ | ||
289 | void | ||
290 | draw_box(WINDOW * win, int y, int x, int height, int width, | ||
291 | chtype box, chtype border) | ||
292 | { | ||
293 | int i, j; | ||
294 | |||
295 | wattrset(win, 0); | ||
296 | for (i = 0; i < height; i++) { | ||
297 | wmove(win, y + i, x); | ||
298 | for (j = 0; j < width; j++) | ||
299 | if (!i && !j) | ||
300 | waddch(win, border | ACS_ULCORNER); | ||
301 | else if (i == height - 1 && !j) | ||
302 | waddch(win, border | ACS_LLCORNER); | ||
303 | else if (!i && j == width - 1) | ||
304 | waddch(win, box | ACS_URCORNER); | ||
305 | else if (i == height - 1 && j == width - 1) | ||
306 | waddch(win, box | ACS_LRCORNER); | ||
307 | else if (!i) | ||
308 | waddch(win, border | ACS_HLINE); | ||
309 | else if (i == height - 1) | ||
310 | waddch(win, box | ACS_HLINE); | ||
311 | else if (!j) | ||
312 | waddch(win, border | ACS_VLINE); | ||
313 | else if (j == width - 1) | ||
314 | waddch(win, box | ACS_VLINE); | ||
315 | else | ||
316 | waddch(win, box | ' '); | ||
317 | } | ||
318 | } | ||
319 | |||
320 | /* | ||
321 | * Draw shadows along the right and bottom edge to give a more 3D look | ||
322 | * to the boxes | ||
323 | */ | ||
324 | void draw_shadow(WINDOW * win, int y, int x, int height, int width) | ||
325 | { | ||
326 | int i; | ||
327 | |||
328 | if (has_colors()) { /* Whether terminal supports color? */ | ||
329 | wattrset(win, shadow_attr); | ||
330 | wmove(win, y + height, x + 2); | ||
331 | for (i = 0; i < width; i++) | ||
332 | waddch(win, winch(win) & A_CHARTEXT); | ||
333 | for (i = y + 1; i < y + height + 1; i++) { | ||
334 | wmove(win, i, x + width); | ||
335 | waddch(win, winch(win) & A_CHARTEXT); | ||
336 | waddch(win, winch(win) & A_CHARTEXT); | ||
337 | } | ||
338 | wnoutrefresh(win); | ||
339 | } | ||
340 | } | ||
341 | |||
342 | /* | ||
343 | * Return the position of the first alphabetic character in a string. | ||
344 | */ | ||
345 | int first_alpha(const char *string, const char *exempt) | ||
346 | { | ||
347 | int i, in_paren = 0, c; | ||
348 | |||
349 | for (i = 0; i < strlen(string); i++) { | ||
350 | c = tolower(string[i]); | ||
351 | |||
352 | if (strchr("<[(", c)) | ||
353 | ++in_paren; | ||
354 | if (strchr(">])", c) && in_paren > 0) | ||
355 | --in_paren; | ||
356 | |||
357 | if ((!in_paren) && isalpha(c) && strchr(exempt, c) == 0) | ||
358 | return i; | ||
359 | } | ||
360 | |||
361 | return 0; | ||
362 | } | ||
diff --git a/scripts/kconfig/lxdialog/yesno.c b/scripts/kconfig/lxdialog/yesno.c new file mode 100644 index 000000000..cb2568aae --- /dev/null +++ b/scripts/kconfig/lxdialog/yesno.c | |||
@@ -0,0 +1,102 @@ | |||
1 | /* | ||
2 | * yesno.c -- implements the yes/no box | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) | ||
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 | #include "dialog.h" | ||
23 | |||
24 | /* | ||
25 | * Display termination buttons | ||
26 | */ | ||
27 | static void print_buttons(WINDOW * dialog, int height, int width, int selected) | ||
28 | { | ||
29 | int x = width / 2 - 10; | ||
30 | int y = height - 2; | ||
31 | |||
32 | print_button(dialog, " Yes ", y, x, selected == 0); | ||
33 | print_button(dialog, " No ", y, x + 13, selected == 1); | ||
34 | |||
35 | wmove(dialog, y, x + 1 + 13 * selected); | ||
36 | wrefresh(dialog); | ||
37 | } | ||
38 | |||
39 | /* | ||
40 | * Display a dialog box with two buttons - Yes and No | ||
41 | */ | ||
42 | int dialog_yesno(const char *title, const char *prompt, int height, int width) | ||
43 | { | ||
44 | int i, x, y, key = 0, button = 0; | ||
45 | WINDOW *dialog; | ||
46 | |||
47 | /* center dialog box on screen */ | ||
48 | x = (COLS - width) / 2; | ||
49 | y = (LINES - height) / 2; | ||
50 | |||
51 | draw_shadow(stdscr, y, x, height, width); | ||
52 | |||
53 | dialog = newwin(height, width, y, x); | ||
54 | keypad(dialog, TRUE); | ||
55 | |||
56 | draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); | ||
57 | wattrset(dialog, border_attr); | ||
58 | mvwaddch(dialog, height - 3, 0, ACS_LTEE); | ||
59 | for (i = 0; i < width - 2; i++) | ||
60 | waddch(dialog, ACS_HLINE); | ||
61 | wattrset(dialog, dialog_attr); | ||
62 | waddch(dialog, ACS_RTEE); | ||
63 | |||
64 | print_title(dialog, title, width); | ||
65 | |||
66 | wattrset(dialog, dialog_attr); | ||
67 | print_autowrap(dialog, prompt, width - 2, 1, 3); | ||
68 | |||
69 | print_buttons(dialog, height, width, 0); | ||
70 | |||
71 | while (key != ESC) { | ||
72 | key = wgetch(dialog); | ||
73 | switch (key) { | ||
74 | case 'Y': | ||
75 | case 'y': | ||
76 | delwin(dialog); | ||
77 | return 0; | ||
78 | case 'N': | ||
79 | case 'n': | ||
80 | delwin(dialog); | ||
81 | return 1; | ||
82 | |||
83 | case TAB: | ||
84 | case KEY_LEFT: | ||
85 | case KEY_RIGHT: | ||
86 | button = ((key == KEY_LEFT ? --button : ++button) < 0) ? 1 : (button > 1 ? 0 : button); | ||
87 | |||
88 | print_buttons(dialog, height, width, button); | ||
89 | wrefresh(dialog); | ||
90 | break; | ||
91 | case ' ': | ||
92 | case '\n': | ||
93 | delwin(dialog); | ||
94 | return button; | ||
95 | case ESC: | ||
96 | break; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | delwin(dialog); | ||
101 | return -1; /* ESC pressed */ | ||
102 | } | ||
diff --git a/scripts/config/mconf.c b/scripts/kconfig/mconf.c index b8f27e69c..7f973195e 100644 --- a/scripts/config/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -1,4 +1,3 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | 1 | /* |
3 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
4 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
@@ -6,8 +5,7 @@ | |||
6 | * Introduced single menu mode (show all sub-menus in one large tree). | 5 | * Introduced single menu mode (show all sub-menus in one large tree). |
7 | * 2002-11-06 Petr Baudis <pasky@ucw.cz> | 6 | * 2002-11-06 Petr Baudis <pasky@ucw.cz> |
8 | * | 7 | * |
9 | * Directly use liblxdialog library routines. | 8 | * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br> |
10 | * 2002-11-14 Petr Baudis <pasky@ucw.cz> | ||
11 | */ | 9 | */ |
12 | 10 | ||
13 | #include <sys/ioctl.h> | 11 | #include <sys/ioctl.h> |
@@ -22,28 +20,29 @@ | |||
22 | #include <string.h> | 20 | #include <string.h> |
23 | #include <termios.h> | 21 | #include <termios.h> |
24 | #include <unistd.h> | 22 | #include <unistd.h> |
25 | 23 | #include <locale.h> | |
26 | #include "lxdialog/dialog.h" | ||
27 | 24 | ||
28 | #define LKC_DIRECT_LINK | 25 | #define LKC_DIRECT_LINK |
29 | #include "lkc.h" | 26 | #include "lkc.h" |
30 | 27 | ||
31 | static char menu_backtitle[128]; | 28 | static char menu_backtitle[128]; |
32 | static const char mconf_readme[] = | 29 | static const char mconf_readme[] = N_( |
33 | "Overview\n" | 30 | "Overview\n" |
34 | "--------\n" | 31 | "--------\n" |
35 | "Some features may be built directly into BusyBox. Some features\n" | 32 | "Some kernel features may be built directly into the kernel.\n" |
33 | "Some may be made into loadable runtime modules. Some features\n" | ||
36 | "may be completely removed altogether. There are also certain\n" | 34 | "may be completely removed altogether. There are also certain\n" |
37 | "parameters which are not really features, but must be\n" | 35 | "kernel parameters which are not really features, but must be\n" |
38 | "entered in as decimal or hexadecimal numbers or possibly text.\n" | 36 | "entered in as decimal or hexadecimal numbers or possibly text.\n" |
39 | "\n" | 37 | "\n" |
40 | "Menu items beginning with [*] or [ ] represent features\n" | 38 | "Menu items beginning with [*], <M> or [ ] represent features\n" |
41 | "configured to be built in or removed respectively.\n" | 39 | "configured to be built in, modularized or removed respectively.\n" |
40 | "Pointed brackets <> represent module capable features.\n" | ||
42 | "\n" | 41 | "\n" |
43 | "To change any of these features, highlight it with the cursor\n" | 42 | "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" | 43 | "keys and press <Y> to build it in, <M> to make it a module or\n" |
45 | "You may also press the <Space Bar> to cycle\n" | 44 | "<N> to removed it. You may also press the <Space Bar> to cycle\n" |
46 | "through the available options (ie. Y->N->Y).\n" | 45 | "through the available options (ie. Y->N->M->Y).\n" |
47 | "\n" | 46 | "\n" |
48 | "Some additional keyboard hints:\n" | 47 | "Some additional keyboard hints:\n" |
49 | "\n" | 48 | "\n" |
@@ -116,7 +115,7 @@ static const char mconf_readme[] = | |||
116 | "-----------------------------\n" | 115 | "-----------------------------\n" |
117 | "Menuconfig supports the use of alternate configuration files for\n" | 116 | "Menuconfig supports the use of alternate configuration files for\n" |
118 | "those who, for various reasons, find it necessary to switch\n" | 117 | "those who, for various reasons, find it necessary to switch\n" |
119 | "between different configurations.\n" | 118 | "between different kernel configurations.\n" |
120 | "\n" | 119 | "\n" |
121 | "At the end of the main menu you will find two options. One is\n" | 120 | "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" | 121 | "for saving the current configuration to a file of your choosing.\n" |
@@ -149,7 +148,7 @@ static const char mconf_readme[] = | |||
149 | "\n" | 148 | "\n" |
150 | "Optional personality available\n" | 149 | "Optional personality available\n" |
151 | "------------------------------\n" | 150 | "------------------------------\n" |
152 | "If you prefer to have all of the options listed in a single\n" | 151 | "If you prefer to have all of the kernel options listed in a single\n" |
153 | "menu, rather than the default multimenu hierarchy, run the menuconfig\n" | 152 | "menu, rather than the default multimenu hierarchy, run the menuconfig\n" |
154 | "with MENUCONFIG_MODE environment variable set to single_menu. Example:\n" | 153 | "with MENUCONFIG_MODE environment variable set to single_menu. Example:\n" |
155 | "\n" | 154 | "\n" |
@@ -160,55 +159,55 @@ static const char mconf_readme[] = | |||
160 | "\n" | 159 | "\n" |
161 | "Note that this mode can eventually be a little more CPU expensive\n" | 160 | "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" | 161 | "(especially with a larger number of unrolled categories) than the\n" |
163 | "default mode.\n", | 162 | "default mode.\n"), |
164 | menu_instructions[] = | 163 | menu_instructions[] = N_( |
165 | "Arrow keys navigate the menu. " | 164 | "Arrow keys navigate the menu. " |
166 | "<Enter> selects submenus --->. " | 165 | "<Enter> selects submenus --->. " |
167 | "Highlighted letters are hotkeys. " | 166 | "Highlighted letters are hotkeys. " |
168 | "Pressing <Y> selectes a feature, while <N> will exclude a feature. " | 167 | "Pressing <Y> includes, <N> excludes, <M> modularizes features. " |
169 | "Press <Esc><Esc> to exit, <?> for Help, </> for Search. " | 168 | "Press <Esc><Esc> to exit, <?> for Help, </> for Search. " |
170 | "Legend: [*] feature is selected [ ] feature is excluded", | 169 | "Legend: [*] built-in [ ] excluded <M> module < > module capable"), |
171 | radiolist_instructions[] = | 170 | radiolist_instructions[] = N_( |
172 | "Use the arrow keys to navigate this window or " | 171 | "Use the arrow keys to navigate this window or " |
173 | "press the hotkey of the item you wish to select " | 172 | "press the hotkey of the item you wish to select " |
174 | "followed by the <SPACE BAR>. " | 173 | "followed by the <SPACE BAR>. " |
175 | "Press <?> for additional information about this option.", | 174 | "Press <?> for additional information about this option."), |
176 | inputbox_instructions_int[] = | 175 | inputbox_instructions_int[] = N_( |
177 | "Please enter a decimal value. " | 176 | "Please enter a decimal value. " |
178 | "Fractions will not be accepted. " | 177 | "Fractions will not be accepted. " |
179 | "Use the <TAB> key to move from the input field to the buttons below it.", | 178 | "Use the <TAB> key to move from the input field to the buttons below it."), |
180 | inputbox_instructions_hex[] = | 179 | inputbox_instructions_hex[] = N_( |
181 | "Please enter a hexadecimal value. " | 180 | "Please enter a hexadecimal value. " |
182 | "Use the <TAB> key to move from the input field to the buttons below it.", | 181 | "Use the <TAB> key to move from the input field to the buttons below it."), |
183 | inputbox_instructions_string[] = | 182 | inputbox_instructions_string[] = N_( |
184 | "Please enter a string value. " | 183 | "Please enter a string value. " |
185 | "Use the <TAB> key to move from the input field to the buttons below it.", | 184 | "Use the <TAB> key to move from the input field to the buttons below it."), |
186 | setmod_text[] = | 185 | setmod_text[] = N_( |
187 | "This feature depends on another which has been configured as a module.\n" | 186 | "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.", | 187 | "As a result, this feature will be built as a module."), |
189 | nohelp_text[] = | 188 | nohelp_text[] = N_( |
190 | "There is no help available for this option.\n", | 189 | "There is no help available for this kernel option.\n"), |
191 | load_config_text[] = | 190 | load_config_text[] = N_( |
192 | "Enter the name of the configuration file you wish to load. " | 191 | "Enter the name of the configuration file you wish to load. " |
193 | "Accept the name shown to restore the configuration you " | 192 | "Accept the name shown to restore the configuration you " |
194 | "last retrieved. Leave blank to abort.", | 193 | "last retrieved. Leave blank to abort."), |
195 | load_config_help[] = | 194 | load_config_help[] = N_( |
196 | "\n" | 195 | "\n" |
197 | "For various reasons, one may wish to keep several different BusyBox\n" | 196 | "For various reasons, one may wish to keep several different kernel\n" |
198 | "configurations available on a single machine.\n" | 197 | "configurations available on a single machine.\n" |
199 | "\n" | 198 | "\n" |
200 | "If you have saved a previous configuration in a file other than the\n" | 199 | "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" | 200 | "kernel's default, entering the name of the file here will allow you\n" |
202 | "to modify that configuration.\n" | 201 | "to modify that configuration.\n" |
203 | "\n" | 202 | "\n" |
204 | "If you are uncertain, then you have probably never used alternate\n" | 203 | "If you are uncertain, then you have probably never used alternate\n" |
205 | "configuration files. You should therefor leave this blank to abort.\n", | 204 | "configuration files. You should therefor leave this blank to abort.\n"), |
206 | save_config_text[] = | 205 | save_config_text[] = N_( |
207 | "Enter a filename to which this configuration should be saved " | 206 | "Enter a filename to which this configuration should be saved " |
208 | "as an alternate. Leave blank to abort.", | 207 | "as an alternate. Leave blank to abort."), |
209 | save_config_help[] = | 208 | save_config_help[] = N_( |
210 | "\n" | 209 | "\n" |
211 | "For various reasons, one may wish to keep different BusyBox\n" | 210 | "For various reasons, one may wish to keep different kernel\n" |
212 | "configurations available on a single machine.\n" | 211 | "configurations available on a single machine.\n" |
213 | "\n" | 212 | "\n" |
214 | "Entering a file name here will allow you to later retrieve, modify\n" | 213 | "Entering a file name here will allow you to later retrieve, modify\n" |
@@ -216,10 +215,11 @@ save_config_help[] = | |||
216 | "configuration options you have selected at that time.\n" | 215 | "configuration options you have selected at that time.\n" |
217 | "\n" | 216 | "\n" |
218 | "If you are uncertain what all this means then you should probably\n" | 217 | "If you are uncertain what all this means then you should probably\n" |
219 | "leave this blank.\n", | 218 | "leave this blank.\n"), |
220 | search_help[] = | 219 | search_help[] = N_( |
221 | "\n" | 220 | "\n" |
222 | "Search for CONFIG_ symbols and display their relations.\n" | 221 | "Search for CONFIG_ symbols and display their relations.\n" |
222 | "Regular expressions are allowed.\n" | ||
223 | "Example: search for \"^FOO\"\n" | 223 | "Example: search for \"^FOO\"\n" |
224 | "Result:\n" | 224 | "Result:\n" |
225 | "-----------------------------------------------------------------\n" | 225 | "-----------------------------------------------------------------\n" |
@@ -254,19 +254,20 @@ search_help[] = | |||
254 | "Examples: USB => find all CONFIG_ symbols containing USB\n" | 254 | "Examples: USB => find all CONFIG_ symbols containing USB\n" |
255 | " ^USB => find all CONFIG_ symbols starting with USB\n" | 255 | " ^USB => find all CONFIG_ symbols starting with USB\n" |
256 | " USB$ => find all CONFIG_ symbols ending with USB\n" | 256 | " USB$ => find all CONFIG_ symbols ending with USB\n" |
257 | "\n"; | 257 | "\n"); |
258 | 258 | ||
259 | static char buf[4096], *bufptr = buf; | ||
260 | static char input_buf[4096]; | ||
259 | static char filename[PATH_MAX+1] = ".config"; | 261 | static char filename[PATH_MAX+1] = ".config"; |
262 | static char *args[1024], **argptr = args; | ||
260 | static int indent; | 263 | static int indent; |
261 | static struct termios ios_org; | 264 | static struct termios ios_org; |
262 | static int rows = 0, cols = 0; | 265 | static int rows = 0, cols = 0; |
263 | static struct menu *current_menu; | 266 | static struct menu *current_menu; |
264 | static int child_count; | 267 | static int child_count; |
268 | static int do_resize; | ||
265 | static int single_menu_mode; | 269 | static int single_menu_mode; |
266 | 270 | ||
267 | static struct dialog_list_item *items[16384]; /* FIXME: This ought to be dynamic. */ | ||
268 | static int item_no; | ||
269 | |||
270 | static void conf(struct menu *menu); | 271 | static void conf(struct menu *menu); |
271 | static void conf_choice(struct menu *menu); | 272 | static void conf_choice(struct menu *menu); |
272 | static void conf_string(struct menu *menu); | 273 | static void conf_string(struct menu *menu); |
@@ -277,6 +278,11 @@ static void show_helptext(const char *title, const char *text); | |||
277 | static void show_help(struct menu *menu); | 278 | static void show_help(struct menu *menu); |
278 | static void show_file(const char *filename, const char *title, int r, int c); | 279 | static void show_file(const char *filename, const char *title, int r, int c); |
279 | 280 | ||
281 | static void cprint_init(void); | ||
282 | static int cprint1(const char *fmt, ...); | ||
283 | static void cprint_done(void); | ||
284 | static int cprint(const char *fmt, ...); | ||
285 | |||
280 | static void init_wsize(void) | 286 | static void init_wsize(void) |
281 | { | 287 | { |
282 | struct winsize ws; | 288 | struct winsize ws; |
@@ -303,8 +309,8 @@ static void init_wsize(void) | |||
303 | } | 309 | } |
304 | 310 | ||
305 | if (rows < 19 || cols < 80) { | 311 | if (rows < 19 || cols < 80) { |
306 | fprintf(stderr, "Your display is too small to run Menuconfig!\n"); | 312 | fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); |
307 | fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); | 313 | fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); |
308 | exit(1); | 314 | exit(1); |
309 | } | 315 | } |
310 | 316 | ||
@@ -312,65 +318,54 @@ static void init_wsize(void) | |||
312 | cols -= 5; | 318 | cols -= 5; |
313 | } | 319 | } |
314 | 320 | ||
315 | static void cinit(void) | 321 | static void cprint_init(void) |
316 | { | ||
317 | item_no = 0; | ||
318 | } | ||
319 | |||
320 | static void cmake(void) | ||
321 | { | 322 | { |
322 | items[item_no] = malloc(sizeof(struct dialog_list_item)); | 323 | bufptr = buf; |
323 | memset(items[item_no], 0, sizeof(struct dialog_list_item)); | 324 | argptr = args; |
324 | items[item_no]->tag = malloc(32); items[item_no]->tag[0] = 0; | 325 | memset(args, 0, sizeof(args)); |
325 | items[item_no]->name = malloc(512); items[item_no]->name[0] = 0; | 326 | indent = 0; |
326 | items[item_no]->namelen = 0; | 327 | child_count = 0; |
327 | item_no++; | 328 | cprint("./scripts/kconfig/lxdialog/lxdialog"); |
329 | cprint("--backtitle"); | ||
330 | cprint(menu_backtitle); | ||
328 | } | 331 | } |
329 | 332 | ||
330 | static int cprint_name(const char *fmt, ...) | 333 | static int cprint1(const char *fmt, ...) |
331 | { | 334 | { |
332 | va_list ap; | 335 | va_list ap; |
333 | int res; | 336 | int res; |
334 | 337 | ||
335 | if (!item_no) | 338 | if (!*argptr) |
336 | cmake(); | 339 | *argptr = bufptr; |
337 | va_start(ap, fmt); | 340 | va_start(ap, fmt); |
338 | res = vsnprintf(items[item_no - 1]->name + items[item_no - 1]->namelen, | 341 | res = vsprintf(bufptr, fmt, ap); |
339 | 512 - items[item_no - 1]->namelen, fmt, ap); | ||
340 | if (res > 0) | ||
341 | items[item_no - 1]->namelen += res; | ||
342 | va_end(ap); | 342 | va_end(ap); |
343 | bufptr += res; | ||
343 | 344 | ||
344 | return res; | 345 | return res; |
345 | } | 346 | } |
346 | 347 | ||
347 | static int cprint_tag(const char *fmt, ...) | 348 | static void cprint_done(void) |
349 | { | ||
350 | *bufptr++ = 0; | ||
351 | argptr++; | ||
352 | } | ||
353 | |||
354 | static int cprint(const char *fmt, ...) | ||
348 | { | 355 | { |
349 | va_list ap; | 356 | va_list ap; |
350 | int res; | 357 | int res; |
351 | 358 | ||
352 | if (!item_no) | 359 | *argptr++ = bufptr; |
353 | cmake(); | ||
354 | va_start(ap, fmt); | 360 | va_start(ap, fmt); |
355 | res = vsnprintf(items[item_no - 1]->tag, 32, fmt, ap); | 361 | res = vsprintf(bufptr, fmt, ap); |
356 | va_end(ap); | 362 | va_end(ap); |
363 | bufptr += res; | ||
364 | *bufptr++ = 0; | ||
357 | 365 | ||
358 | return res; | 366 | return res; |
359 | } | 367 | } |
360 | 368 | ||
361 | static 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 | |||
374 | static void get_prompt_str(struct gstr *r, struct property *prop) | 369 | static void get_prompt_str(struct gstr *r, struct property *prop) |
375 | { | 370 | { |
376 | int i, j; | 371 | int i, j; |
@@ -408,7 +403,7 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym) | |||
408 | struct property *prop; | 403 | struct property *prop; |
409 | 404 | ||
410 | str_printf(r, "Symbol: %s [=%s]\n", sym->name, | 405 | str_printf(r, "Symbol: %s [=%s]\n", sym->name, |
411 | sym_get_string_value(sym)); | 406 | sym_get_string_value(sym)); |
412 | for_all_prompts(sym, prop) | 407 | for_all_prompts(sym, prop) |
413 | get_prompt_str(r, prop); | 408 | get_prompt_str(r, prop); |
414 | hit = false; | 409 | hit = false; |
@@ -443,28 +438,121 @@ static struct gstr get_relations_str(struct symbol **sym_arr) | |||
443 | return res; | 438 | return res; |
444 | } | 439 | } |
445 | 440 | ||
441 | pid_t pid; | ||
442 | |||
443 | static void winch_handler(int sig) | ||
444 | { | ||
445 | if (!do_resize) { | ||
446 | kill(pid, SIGINT); | ||
447 | do_resize = 1; | ||
448 | } | ||
449 | } | ||
450 | |||
451 | static int exec_conf(void) | ||
452 | { | ||
453 | int pipefd[2], stat, size; | ||
454 | struct sigaction sa; | ||
455 | sigset_t sset, osset; | ||
456 | |||
457 | sigemptyset(&sset); | ||
458 | sigaddset(&sset, SIGINT); | ||
459 | sigprocmask(SIG_BLOCK, &sset, &osset); | ||
460 | |||
461 | signal(SIGINT, SIG_DFL); | ||
462 | |||
463 | sa.sa_handler = winch_handler; | ||
464 | sigemptyset(&sa.sa_mask); | ||
465 | sa.sa_flags = SA_RESTART; | ||
466 | sigaction(SIGWINCH, &sa, NULL); | ||
467 | |||
468 | *argptr++ = NULL; | ||
469 | |||
470 | pipe(pipefd); | ||
471 | pid = fork(); | ||
472 | if (pid == 0) { | ||
473 | sigprocmask(SIG_SETMASK, &osset, NULL); | ||
474 | dup2(pipefd[1], 2); | ||
475 | close(pipefd[0]); | ||
476 | close(pipefd[1]); | ||
477 | execv(args[0], args); | ||
478 | _exit(EXIT_FAILURE); | ||
479 | } | ||
480 | |||
481 | close(pipefd[1]); | ||
482 | bufptr = input_buf; | ||
483 | while (1) { | ||
484 | size = input_buf + sizeof(input_buf) - bufptr; | ||
485 | size = read(pipefd[0], bufptr, size); | ||
486 | if (size <= 0) { | ||
487 | if (size < 0) { | ||
488 | if (errno == EINTR || errno == EAGAIN) | ||
489 | continue; | ||
490 | perror("read"); | ||
491 | } | ||
492 | break; | ||
493 | } | ||
494 | bufptr += size; | ||
495 | } | ||
496 | *bufptr++ = 0; | ||
497 | close(pipefd[0]); | ||
498 | waitpid(pid, &stat, 0); | ||
499 | |||
500 | if (do_resize) { | ||
501 | init_wsize(); | ||
502 | do_resize = 0; | ||
503 | sigprocmask(SIG_SETMASK, &osset, NULL); | ||
504 | return -1; | ||
505 | } | ||
506 | if (WIFSIGNALED(stat)) { | ||
507 | printf("\finterrupted(%d)\n", WTERMSIG(stat)); | ||
508 | exit(1); | ||
509 | } | ||
510 | #if 0 | ||
511 | printf("\fexit state: %d\nexit data: '%s'\n", WEXITSTATUS(stat), input_buf); | ||
512 | sleep(1); | ||
513 | #endif | ||
514 | sigpending(&sset); | ||
515 | if (sigismember(&sset, SIGINT)) { | ||
516 | printf("\finterrupted\n"); | ||
517 | exit(1); | ||
518 | } | ||
519 | sigprocmask(SIG_SETMASK, &osset, NULL); | ||
520 | |||
521 | return WEXITSTATUS(stat); | ||
522 | } | ||
523 | |||
446 | static void search_conf(void) | 524 | static void search_conf(void) |
447 | { | 525 | { |
448 | struct symbol **sym_arr; | 526 | struct symbol **sym_arr; |
527 | int stat; | ||
449 | struct gstr res; | 528 | struct gstr res; |
450 | 529 | ||
451 | again: | 530 | again: |
452 | switch (dialog_inputbox("Search Configuration Parameter", | 531 | cprint_init(); |
453 | "Enter Keyword", 10, 75, | 532 | cprint("--title"); |
454 | NULL)) { | 533 | cprint(_("Search Configuration Parameter")); |
534 | cprint("--inputbox"); | ||
535 | cprint(_("Enter CONFIG_ (sub)string to search for (omit CONFIG_)")); | ||
536 | cprint("10"); | ||
537 | cprint("75"); | ||
538 | cprint(""); | ||
539 | stat = exec_conf(); | ||
540 | if (stat < 0) | ||
541 | goto again; | ||
542 | switch (stat) { | ||
455 | case 0: | 543 | case 0: |
456 | break; | 544 | break; |
457 | case 1: | 545 | case 1: |
458 | show_helptext("Search Configuration", search_help); | 546 | show_helptext(_("Search Configuration"), search_help); |
459 | goto again; | 547 | goto again; |
460 | default: | 548 | default: |
461 | return; | 549 | return; |
462 | } | 550 | } |
463 | 551 | ||
464 | sym_arr = sym_re_search(dialog_input_result); | 552 | sym_arr = sym_re_search(input_buf); |
465 | res = get_relations_str(sym_arr); | 553 | res = get_relations_str(sym_arr); |
466 | free(sym_arr); | 554 | free(sym_arr); |
467 | show_textbox("Search Results", str_get(&res), 0, 0); | 555 | show_textbox(_("Search Results"), str_get(&res), 0, 0); |
468 | str_free(&res); | 556 | str_free(&res); |
469 | } | 557 | } |
470 | 558 | ||
@@ -488,26 +576,24 @@ static void build_conf(struct menu *menu) | |||
488 | switch (prop->type) { | 576 | switch (prop->type) { |
489 | case P_MENU: | 577 | case P_MENU: |
490 | child_count++; | 578 | child_count++; |
491 | cmake(); | 579 | cprint("m%p", menu); |
492 | cprint_tag("m%p", menu); | ||
493 | 580 | ||
494 | if (single_menu_mode) { | 581 | if (single_menu_mode) { |
495 | cprint_name("%s%*c%s", | 582 | cprint1("%s%*c%s", |
496 | menu->data ? "-->" : "++>", | 583 | menu->data ? "-->" : "++>", |
497 | indent + 1, ' ', prompt); | 584 | indent + 1, ' ', prompt); |
498 | } else { | 585 | } else |
499 | cprint_name(" %*c%s --->", indent + 1, ' ', prompt); | 586 | cprint1(" %*c%s --->", indent + 1, ' ', prompt); |
500 | } | ||
501 | 587 | ||
588 | cprint_done(); | ||
502 | if (single_menu_mode && menu->data) | 589 | if (single_menu_mode && menu->data) |
503 | goto conf_childs; | 590 | goto conf_childs; |
504 | return; | 591 | return; |
505 | default: | 592 | default: |
506 | if (prompt) { | 593 | if (prompt) { |
507 | child_count++; | 594 | child_count++; |
508 | cmake(); | 595 | cprint(":%p", menu); |
509 | cprint_tag(":%p", menu); | 596 | cprint("---%*c%s", indent + 1, ' ', prompt); |
510 | cprint_name("---%*c%s", indent + 1, ' ', prompt); | ||
511 | } | 597 | } |
512 | } | 598 | } |
513 | } else | 599 | } else |
@@ -515,7 +601,6 @@ static void build_conf(struct menu *menu) | |||
515 | goto conf_childs; | 601 | goto conf_childs; |
516 | } | 602 | } |
517 | 603 | ||
518 | cmake(); | ||
519 | type = sym_get_type(sym); | 604 | type = sym_get_type(sym); |
520 | if (sym_is_choice(sym)) { | 605 | if (sym_is_choice(sym)) { |
521 | struct symbol *def_sym = sym_get_choice_value(sym); | 606 | struct symbol *def_sym = sym_get_choice_value(sym); |
@@ -529,10 +614,10 @@ static void build_conf(struct menu *menu) | |||
529 | 614 | ||
530 | val = sym_get_tristate_value(sym); | 615 | val = sym_get_tristate_value(sym); |
531 | if (sym_is_changable(sym)) { | 616 | if (sym_is_changable(sym)) { |
532 | cprint_tag("t%p", menu); | 617 | cprint("t%p", menu); |
533 | switch (type) { | 618 | switch (type) { |
534 | case S_BOOLEAN: | 619 | case S_BOOLEAN: |
535 | cprint_name("[%c]", val == no ? ' ' : '*'); | 620 | cprint1("[%c]", val == no ? ' ' : '*'); |
536 | break; | 621 | break; |
537 | case S_TRISTATE: | 622 | case S_TRISTATE: |
538 | switch (val) { | 623 | switch (val) { |
@@ -540,78 +625,84 @@ static void build_conf(struct menu *menu) | |||
540 | case mod: ch = 'M'; break; | 625 | case mod: ch = 'M'; break; |
541 | default: ch = ' '; break; | 626 | default: ch = ' '; break; |
542 | } | 627 | } |
543 | cprint_name("<%c>", ch); | 628 | cprint1("<%c>", ch); |
544 | break; | 629 | break; |
545 | } | 630 | } |
546 | } else { | 631 | } else { |
547 | cprint_tag("%c%p", def_menu ? 't' : ':', menu); | 632 | cprint("%c%p", def_menu ? 't' : ':', menu); |
548 | cprint_name(" "); | 633 | cprint1(" "); |
549 | } | 634 | } |
550 | 635 | ||
551 | cprint_name("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); | 636 | cprint1("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); |
552 | if (val == yes) { | 637 | if (val == yes) { |
553 | if (def_menu) { | 638 | if (def_menu) { |
554 | cprint_name(" (%s)", menu_get_prompt(def_menu)); | 639 | cprint1(" (%s)", menu_get_prompt(def_menu)); |
555 | cprint_name(" --->"); | 640 | cprint1(" --->"); |
641 | cprint_done(); | ||
556 | if (def_menu->list) { | 642 | if (def_menu->list) { |
557 | indent += 2; | 643 | indent += 2; |
558 | build_conf(def_menu); | 644 | build_conf(def_menu); |
559 | indent -= 2; | 645 | indent -= 2; |
560 | } | 646 | } |
561 | } | 647 | } else |
648 | cprint_done(); | ||
562 | return; | 649 | return; |
563 | } | 650 | } |
651 | cprint_done(); | ||
564 | } else { | 652 | } else { |
565 | if (menu == current_menu) { | 653 | if (menu == current_menu) { |
566 | cprint_tag(":%p", menu); | 654 | cprint(":%p", menu); |
567 | cprint_name("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); | 655 | cprint("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); |
568 | goto conf_childs; | 656 | goto conf_childs; |
569 | } | 657 | } |
570 | child_count++; | 658 | child_count++; |
571 | val = sym_get_tristate_value(sym); | 659 | val = sym_get_tristate_value(sym); |
572 | if (sym_is_choice_value(sym) && val == yes) { | 660 | if (sym_is_choice_value(sym) && val == yes) { |
573 | cprint_tag(":%p", menu); | 661 | cprint(":%p", menu); |
574 | cprint_name(" "); | 662 | cprint1(" "); |
575 | } else { | 663 | } else { |
576 | switch (type) { | 664 | switch (type) { |
577 | case S_BOOLEAN: | 665 | case S_BOOLEAN: |
578 | cprint_tag("t%p", menu); | 666 | cprint("t%p", menu); |
579 | if (sym_is_changable(sym)) | 667 | if (sym_is_changable(sym)) |
580 | cprint_name("[%c]", val == no ? ' ' : '*'); | 668 | cprint1("[%c]", val == no ? ' ' : '*'); |
581 | else | 669 | else |
582 | cprint_name("---"); | 670 | cprint1("---"); |
583 | break; | 671 | break; |
584 | case S_TRISTATE: | 672 | case S_TRISTATE: |
585 | cprint_tag("t%p", menu); | 673 | cprint("t%p", menu); |
586 | switch (val) { | 674 | switch (val) { |
587 | case yes: ch = '*'; break; | 675 | case yes: ch = '*'; break; |
588 | case mod: ch = 'M'; break; | 676 | case mod: ch = 'M'; break; |
589 | default: ch = ' '; break; | 677 | default: ch = ' '; break; |
590 | } | 678 | } |
591 | if (sym_is_changable(sym)) | 679 | if (sym_is_changable(sym)) |
592 | cprint_name("<%c>", ch); | 680 | cprint1("<%c>", ch); |
593 | else | 681 | else |
594 | cprint_name("---"); | 682 | cprint1("---"); |
595 | break; | 683 | break; |
596 | default: | 684 | default: |
597 | cprint_tag("s%p", menu); | 685 | cprint("s%p", menu); |
598 | tmp = cprint_name("(%s)", sym_get_string_value(sym)); | 686 | tmp = cprint1("(%s)", sym_get_string_value(sym)); |
599 | tmp = indent - tmp + 4; | 687 | tmp = indent - tmp + 4; |
600 | if (tmp < 0) | 688 | if (tmp < 0) |
601 | tmp = 0; | 689 | tmp = 0; |
602 | cprint_name("%*c%s%s", tmp, ' ', menu_get_prompt(menu), | 690 | cprint1("%*c%s%s", tmp, ' ', menu_get_prompt(menu), |
603 | (sym_has_value(sym) || !sym_is_changable(sym)) ? | 691 | (sym_has_value(sym) || !sym_is_changable(sym)) ? |
604 | "" : " (NEW)"); | 692 | "" : " (NEW)"); |
693 | cprint_done(); | ||
605 | goto conf_childs; | 694 | goto conf_childs; |
606 | } | 695 | } |
607 | } | 696 | } |
608 | cprint_name("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), | 697 | cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), |
609 | (sym_has_value(sym) || !sym_is_changable(sym)) ? | 698 | (sym_has_value(sym) || !sym_is_changable(sym)) ? |
610 | "" : " (NEW)"); | 699 | "" : " (NEW)"); |
611 | if (menu->prompt->type == P_MENU) { | 700 | if (menu->prompt->type == P_MENU) { |
612 | cprint_name(" --->"); | 701 | cprint1(" --->"); |
702 | cprint_done(); | ||
613 | return; | 703 | return; |
614 | } | 704 | } |
705 | cprint_done(); | ||
615 | } | 706 | } |
616 | 707 | ||
617 | conf_childs: | 708 | conf_childs: |
@@ -623,51 +714,57 @@ conf_childs: | |||
623 | 714 | ||
624 | static void conf(struct menu *menu) | 715 | static void conf(struct menu *menu) |
625 | { | 716 | { |
626 | struct dialog_list_item *active_item = NULL; | ||
627 | struct menu *submenu; | 717 | struct menu *submenu; |
628 | const char *prompt = menu_get_prompt(menu); | 718 | const char *prompt = menu_get_prompt(menu); |
629 | struct symbol *sym; | 719 | struct symbol *sym; |
630 | char active_entry[40]; | 720 | char active_entry[40]; |
631 | int stat, type; | 721 | int stat, type, i; |
632 | 722 | ||
633 | unlink("lxdialog.scrltmp"); | 723 | unlink("lxdialog.scrltmp"); |
634 | active_entry[0] = 0; | 724 | active_entry[0] = 0; |
635 | while (1) { | 725 | while (1) { |
636 | indent = 0; | 726 | cprint_init(); |
637 | child_count = 0; | 727 | cprint("--title"); |
728 | cprint("%s", prompt ? prompt : _("Main Menu")); | ||
729 | cprint("--menu"); | ||
730 | cprint(_(menu_instructions)); | ||
731 | cprint("%d", rows); | ||
732 | cprint("%d", cols); | ||
733 | cprint("%d", rows - 10); | ||
734 | cprint("%s", active_entry); | ||
638 | current_menu = menu; | 735 | current_menu = menu; |
639 | cdone(); cinit(); | ||
640 | build_conf(menu); | 736 | build_conf(menu); |
641 | if (!child_count) | 737 | if (!child_count) |
642 | break; | 738 | break; |
643 | if (menu == &rootmenu) { | 739 | if (menu == &rootmenu) { |
644 | cmake(); cprint_tag(":"); cprint_name("--- "); | 740 | cprint(":"); |
645 | cmake(); cprint_tag("L"); cprint_name("Load an Alternate Configuration File"); | 741 | cprint("--- "); |
646 | cmake(); cprint_tag("S"); cprint_name("Save Configuration to an Alternate File"); | 742 | cprint("L"); |
743 | cprint(_(" Load an Alternate Configuration File")); | ||
744 | cprint("S"); | ||
745 | cprint(_(" Save Configuration to an Alternate File")); | ||
647 | } | 746 | } |
648 | dialog_clear(); | 747 | stat = exec_conf(); |
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) | 748 | if (stat < 0) |
653 | return; | 749 | continue; |
654 | 750 | ||
655 | if (stat == 1 || stat == 255) | 751 | if (stat == 1 || stat == 255) |
656 | break; | 752 | break; |
657 | 753 | ||
658 | active_item = first_sel_item(item_no, items); | 754 | type = input_buf[0]; |
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) | 755 | if (!type) |
666 | continue; | 756 | continue; |
667 | 757 | ||
758 | for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++) | ||
759 | ; | ||
760 | if (i >= sizeof(active_entry)) | ||
761 | i = sizeof(active_entry) - 1; | ||
762 | input_buf[i] = 0; | ||
763 | strcpy(active_entry, input_buf); | ||
764 | |||
668 | sym = NULL; | 765 | sym = NULL; |
669 | submenu = NULL; | 766 | submenu = NULL; |
670 | if (sscanf(active_entry + 1, "%p", &submenu) == 1) | 767 | if (sscanf(input_buf + 1, "%p", &submenu) == 1) |
671 | sym = submenu->sym; | 768 | sym = submenu->sym; |
672 | 769 | ||
673 | switch (stat) { | 770 | switch (stat) { |
@@ -700,7 +797,7 @@ static void conf(struct menu *menu) | |||
700 | if (sym) | 797 | if (sym) |
701 | show_help(submenu); | 798 | show_help(submenu); |
702 | else | 799 | else |
703 | show_helptext("README", mconf_readme); | 800 | show_helptext("README", _(mconf_readme)); |
704 | break; | 801 | break; |
705 | case 3: | 802 | case 3: |
706 | if (type == 't') { | 803 | if (type == 't') { |
@@ -755,8 +852,8 @@ static void show_help(struct menu *menu) | |||
755 | if (sym->help) | 852 | if (sym->help) |
756 | { | 853 | { |
757 | if (sym->name) { | 854 | if (sym->name) { |
758 | str_printf(&help, "%s:\n\n", sym->name); | 855 | str_printf(&help, "CONFIG_%s:\n\n", sym->name); |
759 | str_append(&help, sym->help); | 856 | str_append(&help, _(sym->help)); |
760 | str_append(&help, "\n"); | 857 | str_append(&help, "\n"); |
761 | } | 858 | } |
762 | } else { | 859 | } else { |
@@ -769,8 +866,17 @@ static void show_help(struct menu *menu) | |||
769 | 866 | ||
770 | static void show_file(const char *filename, const char *title, int r, int c) | 867 | static void show_file(const char *filename, const char *title, int r, int c) |
771 | { | 868 | { |
772 | while (dialog_textbox(title, filename, r ? r : rows, c ? c : cols) < 0) | 869 | do { |
773 | ; | 870 | cprint_init(); |
871 | if (title) { | ||
872 | cprint("--title"); | ||
873 | cprint("%s", title); | ||
874 | } | ||
875 | cprint("--textbox"); | ||
876 | cprint("%s", filename); | ||
877 | cprint("%d", r ? r : rows); | ||
878 | cprint("%d", c ? c : cols); | ||
879 | } while (exec_conf() < 0); | ||
774 | } | 880 | } |
775 | 881 | ||
776 | static void conf_choice(struct menu *menu) | 882 | static void conf_choice(struct menu *menu) |
@@ -778,35 +884,42 @@ static void conf_choice(struct menu *menu) | |||
778 | const char *prompt = menu_get_prompt(menu); | 884 | const char *prompt = menu_get_prompt(menu); |
779 | struct menu *child; | 885 | struct menu *child; |
780 | struct symbol *active; | 886 | struct symbol *active; |
887 | int stat; | ||
781 | 888 | ||
782 | active = sym_get_choice_value(menu->sym); | 889 | active = sym_get_choice_value(menu->sym); |
783 | while (1) { | 890 | while (1) { |
891 | cprint_init(); | ||
892 | cprint("--title"); | ||
893 | cprint("%s", prompt ? prompt : _("Main Menu")); | ||
894 | cprint("--radiolist"); | ||
895 | cprint(_(radiolist_instructions)); | ||
896 | cprint("15"); | ||
897 | cprint("70"); | ||
898 | cprint("6"); | ||
899 | |||
784 | current_menu = menu; | 900 | current_menu = menu; |
785 | cdone(); cinit(); | ||
786 | for (child = menu->list; child; child = child->next) { | 901 | for (child = menu->list; child; child = child->next) { |
787 | if (!menu_is_visible(child)) | 902 | if (!menu_is_visible(child)) |
788 | continue; | 903 | continue; |
789 | cmake(); | 904 | cprint("%p", child); |
790 | cprint_tag("%p", child); | 905 | cprint("%s", menu_get_prompt(child)); |
791 | cprint_name("%s", menu_get_prompt(child)); | ||
792 | if (child->sym == sym_get_choice_value(menu->sym)) | 906 | if (child->sym == sym_get_choice_value(menu->sym)) |
793 | items[item_no - 1]->selected = 1; /* ON */ | 907 | cprint("ON"); |
794 | else if (child->sym == active) | 908 | else if (child->sym == active) |
795 | items[item_no - 1]->selected = 2; /* SELECTED */ | 909 | cprint("SELECTED"); |
796 | else | 910 | else |
797 | items[item_no - 1]->selected = 0; /* OFF */ | 911 | cprint("OFF"); |
798 | } | 912 | } |
799 | 913 | ||
800 | switch (dialog_checklist(prompt ? prompt : "Main Menu", | 914 | stat = exec_conf(); |
801 | radiolist_instructions, 15, 70, 6, | 915 | switch (stat) { |
802 | item_no, items, FLAG_RADIO)) { | ||
803 | case 0: | 916 | case 0: |
804 | if (sscanf(first_sel_item(item_no, items)->tag, "%p", &child) != 1) | 917 | if (sscanf(input_buf, "%p", &child) != 1) |
805 | break; | 918 | break; |
806 | sym_set_tristate_value(child->sym, yes); | 919 | sym_set_tristate_value(child->sym, yes); |
807 | return; | 920 | return; |
808 | case 1: | 921 | case 1: |
809 | if (sscanf(first_sel_item(item_no, items)->tag, "%p", &child) == 1) { | 922 | if (sscanf(input_buf, "%p", &child) == 1) { |
810 | show_help(child); | 923 | show_help(child); |
811 | active = child->sym; | 924 | active = child->sym; |
812 | } else | 925 | } else |
@@ -821,32 +934,35 @@ static void conf_choice(struct menu *menu) | |||
821 | static void conf_string(struct menu *menu) | 934 | static void conf_string(struct menu *menu) |
822 | { | 935 | { |
823 | const char *prompt = menu_get_prompt(menu); | 936 | const char *prompt = menu_get_prompt(menu); |
937 | int stat; | ||
824 | 938 | ||
825 | while (1) { | 939 | while (1) { |
826 | char *heading; | 940 | cprint_init(); |
827 | 941 | cprint("--title"); | |
942 | cprint("%s", prompt ? prompt : _("Main Menu")); | ||
943 | cprint("--inputbox"); | ||
828 | switch (sym_get_type(menu->sym)) { | 944 | switch (sym_get_type(menu->sym)) { |
829 | case S_INT: | 945 | case S_INT: |
830 | heading = (char *) inputbox_instructions_int; | 946 | cprint(_(inputbox_instructions_int)); |
831 | break; | 947 | break; |
832 | case S_HEX: | 948 | case S_HEX: |
833 | heading = (char *) inputbox_instructions_hex; | 949 | cprint(_(inputbox_instructions_hex)); |
834 | break; | 950 | break; |
835 | case S_STRING: | 951 | case S_STRING: |
836 | heading = (char *) inputbox_instructions_string; | 952 | cprint(_(inputbox_instructions_string)); |
837 | break; | 953 | break; |
838 | default: | 954 | default: |
839 | heading = "Internal mconf error!"; | ||
840 | /* panic? */; | 955 | /* panic? */; |
841 | } | 956 | } |
842 | 957 | cprint("10"); | |
843 | switch (dialog_inputbox(prompt ? prompt : "Main Menu", | 958 | cprint("75"); |
844 | heading, 10, 75, | 959 | cprint("%s", sym_get_string_value(menu->sym)); |
845 | sym_get_string_value(menu->sym))) { | 960 | stat = exec_conf(); |
961 | switch (stat) { | ||
846 | case 0: | 962 | case 0: |
847 | if (sym_set_string_value(menu->sym, dialog_input_result)) | 963 | if (sym_set_string_value(menu->sym, input_buf)) |
848 | return; | 964 | return; |
849 | show_textbox(NULL, "You have made an invalid entry.", 5, 43); | 965 | show_textbox(NULL, _("You have made an invalid entry."), 5, 43); |
850 | break; | 966 | break; |
851 | case 1: | 967 | case 1: |
852 | show_help(menu); | 968 | show_help(menu); |
@@ -859,18 +975,26 @@ static void conf_string(struct menu *menu) | |||
859 | 975 | ||
860 | static void conf_load(void) | 976 | static void conf_load(void) |
861 | { | 977 | { |
978 | int stat; | ||
979 | |||
862 | while (1) { | 980 | while (1) { |
863 | switch (dialog_inputbox(NULL, load_config_text, 11, 55, | 981 | cprint_init(); |
864 | filename)) { | 982 | cprint("--inputbox"); |
983 | cprint(load_config_text); | ||
984 | cprint("11"); | ||
985 | cprint("55"); | ||
986 | cprint("%s", filename); | ||
987 | stat = exec_conf(); | ||
988 | switch(stat) { | ||
865 | case 0: | 989 | case 0: |
866 | if (!dialog_input_result[0]) | 990 | if (!input_buf[0]) |
867 | return; | 991 | return; |
868 | if (!conf_read(dialog_input_result)) | 992 | if (!conf_read(input_buf)) |
869 | return; | 993 | return; |
870 | show_textbox(NULL, "File does not exist!", 5, 38); | 994 | show_textbox(NULL, _("File does not exist!"), 5, 38); |
871 | break; | 995 | break; |
872 | case 1: | 996 | case 1: |
873 | show_helptext("Load Alternate Configuration", load_config_help); | 997 | show_helptext(_("Load Alternate Configuration"), load_config_help); |
874 | break; | 998 | break; |
875 | case 255: | 999 | case 255: |
876 | return; | 1000 | return; |
@@ -880,18 +1004,26 @@ static void conf_load(void) | |||
880 | 1004 | ||
881 | static void conf_save(void) | 1005 | static void conf_save(void) |
882 | { | 1006 | { |
1007 | int stat; | ||
1008 | |||
883 | while (1) { | 1009 | while (1) { |
884 | switch (dialog_inputbox(NULL, save_config_text, 11, 55, | 1010 | cprint_init(); |
885 | filename)) { | 1011 | cprint("--inputbox"); |
1012 | cprint(save_config_text); | ||
1013 | cprint("11"); | ||
1014 | cprint("55"); | ||
1015 | cprint("%s", filename); | ||
1016 | stat = exec_conf(); | ||
1017 | switch(stat) { | ||
886 | case 0: | 1018 | case 0: |
887 | if (!dialog_input_result[0]) | 1019 | if (!input_buf[0]) |
888 | return; | 1020 | return; |
889 | if (!conf_write(dialog_input_result)) | 1021 | if (!conf_write(input_buf)) |
890 | return; | 1022 | return; |
891 | show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); | 1023 | show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); |
892 | break; | 1024 | break; |
893 | case 1: | 1025 | case 1: |
894 | show_helptext("Save Alternate Configuration", save_config_help); | 1026 | show_helptext(_("Save Alternate Configuration"), save_config_help); |
895 | break; | 1027 | break; |
896 | case 255: | 1028 | case 255: |
897 | return; | 1029 | return; |
@@ -903,30 +1035,7 @@ static void conf_cleanup(void) | |||
903 | { | 1035 | { |
904 | tcsetattr(1, TCSAFLUSH, &ios_org); | 1036 | tcsetattr(1, TCSAFLUSH, &ios_org); |
905 | unlink(".help.tmp"); | 1037 | unlink(".help.tmp"); |
906 | } | 1038 | unlink("lxdialog.scrltmp"); |
907 | |||
908 | static 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 | } | 1039 | } |
931 | 1040 | ||
932 | int main(int ac, char **av) | 1041 | int main(int ac, char **av) |
@@ -935,12 +1044,16 @@ int main(int ac, char **av) | |||
935 | char *mode; | 1044 | char *mode; |
936 | int stat; | 1045 | int stat; |
937 | 1046 | ||
1047 | setlocale(LC_ALL, ""); | ||
1048 | bindtextdomain(PACKAGE, LOCALEDIR); | ||
1049 | textdomain(PACKAGE); | ||
1050 | |||
938 | conf_parse(av[1]); | 1051 | conf_parse(av[1]); |
939 | conf_read(NULL); | 1052 | conf_read(NULL); |
940 | 1053 | ||
941 | sym = sym_lookup("VERSION", 0); | 1054 | sym = sym_lookup("KERNELVERSION", 0); |
942 | sym_calc_value(sym); | 1055 | sym_calc_value(sym); |
943 | snprintf(menu_backtitle, 128, "BusyBox v%s Configuration", | 1056 | sprintf(menu_backtitle, _("Linux Kernel v%s Configuration"), |
944 | sym_get_string_value(sym)); | 1057 | sym_get_string_value(sym)); |
945 | 1058 | ||
946 | mode = getenv("MENUCONFIG_MODE"); | 1059 | mode = getenv("MENUCONFIG_MODE"); |
@@ -952,25 +1065,34 @@ int main(int ac, char **av) | |||
952 | tcgetattr(1, &ios_org); | 1065 | tcgetattr(1, &ios_org); |
953 | atexit(conf_cleanup); | 1066 | atexit(conf_cleanup); |
954 | init_wsize(); | 1067 | init_wsize(); |
955 | init_dialog(); | ||
956 | signal(SIGWINCH, winch_handler); | ||
957 | conf(&rootmenu); | 1068 | conf(&rootmenu); |
958 | end_dialog(); | ||
959 | 1069 | ||
960 | /* Restart dialog to act more like when lxdialog was still separate */ | ||
961 | init_dialog(); | ||
962 | do { | 1070 | do { |
963 | stat = dialog_yesno(NULL, | 1071 | cprint_init(); |
964 | "Do you wish to save your new BusyBox configuration?", 5, 60); | 1072 | cprint("--yesno"); |
1073 | cprint(_("Do you wish to save your new kernel configuration?")); | ||
1074 | cprint("5"); | ||
1075 | cprint("60"); | ||
1076 | stat = exec_conf(); | ||
965 | } while (stat < 0); | 1077 | } while (stat < 0); |
966 | end_dialog(); | ||
967 | 1078 | ||
968 | if (stat == 0) { | 1079 | if (stat == 0) { |
969 | conf_write(NULL); | 1080 | if (conf_write(NULL)) { |
970 | printf("\n" | 1081 | fprintf(stderr, _("\n\n" |
971 | "*** End of BusyBox configuration.\n"); | 1082 | "Error during writing of the kernel configuration.\n" |
972 | } else | 1083 | "Your kernel configuration changes were NOT saved." |
973 | printf("\n\nYour BusyBox configuration changes were NOT saved.\n\n"); | 1084 | "\n\n")); |
1085 | return 1; | ||
1086 | } | ||
1087 | printf(_("\n\n" | ||
1088 | "*** End of Linux kernel configuration.\n" | ||
1089 | "*** Execute 'make' to build the kernel or try 'make help'." | ||
1090 | "\n\n")); | ||
1091 | } else { | ||
1092 | fprintf(stderr, _("\n\n" | ||
1093 | "Your kernel configuration changes were NOT saved." | ||
1094 | "\n\n")); | ||
1095 | } | ||
974 | 1096 | ||
975 | return 0; | 1097 | return 0; |
976 | } | 1098 | } |
diff --git a/scripts/config/menu.c b/scripts/kconfig/menu.c index 7e97e8330..0fce20cb7 100644 --- a/scripts/config/menu.c +++ b/scripts/kconfig/menu.c | |||
@@ -1,4 +1,3 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | 1 | /* |
3 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
4 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
@@ -62,10 +61,11 @@ void menu_end_entry(void) | |||
62 | { | 61 | { |
63 | } | 62 | } |
64 | 63 | ||
65 | void menu_add_menu(void) | 64 | struct menu *menu_add_menu(void) |
66 | { | 65 | { |
67 | current_menu = current_entry; | 66 | menu_end_entry(); |
68 | last_entry_ptr = ¤t_entry->list; | 67 | last_entry_ptr = ¤t_entry->list; |
68 | return current_menu = current_entry; | ||
69 | } | 69 | } |
70 | 70 | ||
71 | void menu_end_menu(void) | 71 | void menu_end_menu(void) |
@@ -137,9 +137,9 @@ struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *e | |||
137 | return prop; | 137 | return prop; |
138 | } | 138 | } |
139 | 139 | ||
140 | void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep) | 140 | struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep) |
141 | { | 141 | { |
142 | menu_add_prop(type, prompt, NULL, dep); | 142 | return menu_add_prop(type, prompt, NULL, dep); |
143 | } | 143 | } |
144 | 144 | ||
145 | void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) | 145 | void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep) |
@@ -152,6 +152,12 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep) | |||
152 | menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep); | 152 | menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep); |
153 | } | 153 | } |
154 | 154 | ||
155 | static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2) | ||
156 | { | ||
157 | return sym2->type == S_INT || sym2->type == S_HEX || | ||
158 | (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name)); | ||
159 | } | ||
160 | |||
155 | void sym_check_prop(struct symbol *sym) | 161 | void sym_check_prop(struct symbol *sym) |
156 | { | 162 | { |
157 | struct property *prop; | 163 | struct property *prop; |
@@ -185,9 +191,9 @@ void sym_check_prop(struct symbol *sym) | |||
185 | case P_RANGE: | 191 | case P_RANGE: |
186 | if (sym->type != S_INT && sym->type != S_HEX) | 192 | if (sym->type != S_INT && sym->type != S_HEX) |
187 | prop_warn(prop, "range is only allowed " | 193 | prop_warn(prop, "range is only allowed " |
188 | "for int or hex symbols"); | 194 | "for int or hex symbols"); |
189 | if (!sym_string_valid(sym, prop->expr->left.sym->name) || | 195 | if (!menu_range_valid_sym(sym, prop->expr->left.sym) || |
190 | !sym_string_valid(sym, prop->expr->right.sym->name)) | 196 | !menu_range_valid_sym(sym, prop->expr->right.sym)) |
191 | prop_warn(prop, "range is invalid"); | 197 | prop_warn(prop, "range is invalid"); |
192 | break; | 198 | break; |
193 | default: | 199 | default: |
@@ -366,9 +372,9 @@ bool menu_is_visible(struct menu *menu) | |||
366 | const char *menu_get_prompt(struct menu *menu) | 372 | const char *menu_get_prompt(struct menu *menu) |
367 | { | 373 | { |
368 | if (menu->prompt) | 374 | if (menu->prompt) |
369 | return menu->prompt->text; | 375 | return _(menu->prompt->text); |
370 | else if (menu->sym) | 376 | else if (menu->sym) |
371 | return menu->sym->name; | 377 | return _(menu->sym->name); |
372 | return NULL; | 378 | return NULL; |
373 | } | 379 | } |
374 | 380 | ||
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc new file mode 100644 index 000000000..4590cd316 --- /dev/null +++ b/scripts/kconfig/qconf.cc | |||
@@ -0,0 +1,1426 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
3 | * Released under the terms of the GNU GPL v2.0. | ||
4 | */ | ||
5 | |||
6 | #include <qapplication.h> | ||
7 | #include <qmainwindow.h> | ||
8 | #include <qtoolbar.h> | ||
9 | #include <qvbox.h> | ||
10 | #include <qsplitter.h> | ||
11 | #include <qlistview.h> | ||
12 | #include <qtextview.h> | ||
13 | #include <qlineedit.h> | ||
14 | #include <qmenubar.h> | ||
15 | #include <qmessagebox.h> | ||
16 | #include <qaction.h> | ||
17 | #include <qheader.h> | ||
18 | #include <qfiledialog.h> | ||
19 | #include <qregexp.h> | ||
20 | |||
21 | #include <stdlib.h> | ||
22 | |||
23 | #include "lkc.h" | ||
24 | #include "qconf.h" | ||
25 | |||
26 | #include "qconf.moc" | ||
27 | #include "images.c" | ||
28 | |||
29 | #ifdef _ | ||
30 | # undef _ | ||
31 | # define _ qgettext | ||
32 | #endif | ||
33 | |||
34 | static QApplication *configApp; | ||
35 | |||
36 | static inline QString qgettext(const char* str) | ||
37 | { | ||
38 | return QString::fromLocal8Bit(gettext(str)); | ||
39 | } | ||
40 | |||
41 | static inline QString qgettext(const QString& str) | ||
42 | { | ||
43 | return QString::fromLocal8Bit(gettext(str.latin1())); | ||
44 | } | ||
45 | |||
46 | ConfigSettings::ConfigSettings() | ||
47 | : showAll(false), showName(false), showRange(false), showData(false) | ||
48 | { | ||
49 | } | ||
50 | |||
51 | #if QT_VERSION >= 300 | ||
52 | /** | ||
53 | * Reads the list column settings from the application settings. | ||
54 | */ | ||
55 | void ConfigSettings::readListSettings() | ||
56 | { | ||
57 | showAll = readBoolEntry("/kconfig/qconf/showAll", false); | ||
58 | showName = readBoolEntry("/kconfig/qconf/showName", false); | ||
59 | showRange = readBoolEntry("/kconfig/qconf/showRange", false); | ||
60 | showData = readBoolEntry("/kconfig/qconf/showData", false); | ||
61 | } | ||
62 | |||
63 | /** | ||
64 | * Reads a list of integer values from the application settings. | ||
65 | */ | ||
66 | QValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok) | ||
67 | { | ||
68 | QValueList<int> result; | ||
69 | QStringList entryList = readListEntry(key, ok); | ||
70 | if (ok) { | ||
71 | QStringList::Iterator it; | ||
72 | for (it = entryList.begin(); it != entryList.end(); ++it) | ||
73 | result.push_back((*it).toInt()); | ||
74 | } | ||
75 | |||
76 | return result; | ||
77 | } | ||
78 | |||
79 | /** | ||
80 | * Writes a list of integer values to the application settings. | ||
81 | */ | ||
82 | bool ConfigSettings::writeSizes(const QString& key, const QValueList<int>& value) | ||
83 | { | ||
84 | QStringList stringList; | ||
85 | QValueList<int>::ConstIterator it; | ||
86 | |||
87 | for (it = value.begin(); it != value.end(); ++it) | ||
88 | stringList.push_back(QString::number(*it)); | ||
89 | return writeEntry(key, stringList); | ||
90 | } | ||
91 | #endif | ||
92 | |||
93 | |||
94 | /* | ||
95 | * update all the children of a menu entry | ||
96 | * removes/adds the entries from the parent widget as necessary | ||
97 | * | ||
98 | * parent: either the menu list widget or a menu entry widget | ||
99 | * menu: entry to be updated | ||
100 | */ | ||
101 | template <class P> | ||
102 | void ConfigList::updateMenuList(P* parent, struct menu* menu) | ||
103 | { | ||
104 | struct menu* child; | ||
105 | ConfigItem* item; | ||
106 | ConfigItem* last; | ||
107 | bool visible; | ||
108 | enum prop_type type; | ||
109 | |||
110 | if (!menu) { | ||
111 | while ((item = parent->firstChild())) | ||
112 | delete item; | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | last = parent->firstChild(); | ||
117 | if (last && !last->goParent) | ||
118 | last = 0; | ||
119 | for (child = menu->list; child; child = child->next) { | ||
120 | item = last ? last->nextSibling() : parent->firstChild(); | ||
121 | type = child->prompt ? child->prompt->type : P_UNKNOWN; | ||
122 | |||
123 | switch (mode) { | ||
124 | case menuMode: | ||
125 | if (!(child->flags & MENU_ROOT)) | ||
126 | goto hide; | ||
127 | break; | ||
128 | case symbolMode: | ||
129 | if (child->flags & MENU_ROOT) | ||
130 | goto hide; | ||
131 | break; | ||
132 | default: | ||
133 | break; | ||
134 | } | ||
135 | |||
136 | visible = menu_is_visible(child); | ||
137 | if (showAll || visible) { | ||
138 | if (!item || item->menu != child) | ||
139 | item = new ConfigItem(parent, last, child, visible); | ||
140 | else | ||
141 | item->testUpdateMenu(visible); | ||
142 | |||
143 | if (mode == fullMode || mode == menuMode || type != P_MENU) | ||
144 | updateMenuList(item, child); | ||
145 | else | ||
146 | updateMenuList(item, 0); | ||
147 | last = item; | ||
148 | continue; | ||
149 | } | ||
150 | hide: | ||
151 | if (item && item->menu == child) { | ||
152 | last = parent->firstChild(); | ||
153 | if (last == item) | ||
154 | last = 0; | ||
155 | else while (last->nextSibling() != item) | ||
156 | last = last->nextSibling(); | ||
157 | delete item; | ||
158 | } | ||
159 | } | ||
160 | } | ||
161 | |||
162 | #if QT_VERSION >= 300 | ||
163 | /* | ||
164 | * set the new data | ||
165 | * TODO check the value | ||
166 | */ | ||
167 | void ConfigItem::okRename(int col) | ||
168 | { | ||
169 | Parent::okRename(col); | ||
170 | sym_set_string_value(menu->sym, text(dataColIdx).latin1()); | ||
171 | } | ||
172 | #endif | ||
173 | |||
174 | /* | ||
175 | * update the displayed of a menu entry | ||
176 | */ | ||
177 | void ConfigItem::updateMenu(void) | ||
178 | { | ||
179 | ConfigList* list; | ||
180 | struct symbol* sym; | ||
181 | struct property *prop; | ||
182 | QString prompt; | ||
183 | int type; | ||
184 | tristate expr; | ||
185 | |||
186 | list = listView(); | ||
187 | if (goParent) { | ||
188 | setPixmap(promptColIdx, list->menuBackPix); | ||
189 | prompt = ".."; | ||
190 | goto set_prompt; | ||
191 | } | ||
192 | |||
193 | sym = menu->sym; | ||
194 | prop = menu->prompt; | ||
195 | prompt = QString::fromLocal8Bit(menu_get_prompt(menu)); | ||
196 | |||
197 | if (prop) switch (prop->type) { | ||
198 | case P_MENU: | ||
199 | if (list->mode == singleMode || list->mode == symbolMode) { | ||
200 | /* a menuconfig entry is displayed differently | ||
201 | * depending whether it's at the view root or a child. | ||
202 | */ | ||
203 | if (sym && list->rootEntry == menu) | ||
204 | break; | ||
205 | setPixmap(promptColIdx, list->menuPix); | ||
206 | } else { | ||
207 | if (sym) | ||
208 | break; | ||
209 | setPixmap(promptColIdx, 0); | ||
210 | } | ||
211 | goto set_prompt; | ||
212 | case P_COMMENT: | ||
213 | setPixmap(promptColIdx, 0); | ||
214 | goto set_prompt; | ||
215 | default: | ||
216 | ; | ||
217 | } | ||
218 | if (!sym) | ||
219 | goto set_prompt; | ||
220 | |||
221 | setText(nameColIdx, QString::fromLocal8Bit(sym->name)); | ||
222 | |||
223 | type = sym_get_type(sym); | ||
224 | switch (type) { | ||
225 | case S_BOOLEAN: | ||
226 | case S_TRISTATE: | ||
227 | char ch; | ||
228 | |||
229 | if (!sym_is_changable(sym) && !list->showAll) { | ||
230 | setPixmap(promptColIdx, 0); | ||
231 | setText(noColIdx, QString::null); | ||
232 | setText(modColIdx, QString::null); | ||
233 | setText(yesColIdx, QString::null); | ||
234 | break; | ||
235 | } | ||
236 | expr = sym_get_tristate_value(sym); | ||
237 | switch (expr) { | ||
238 | case yes: | ||
239 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) | ||
240 | setPixmap(promptColIdx, list->choiceYesPix); | ||
241 | else | ||
242 | setPixmap(promptColIdx, list->symbolYesPix); | ||
243 | setText(yesColIdx, "Y"); | ||
244 | ch = 'Y'; | ||
245 | break; | ||
246 | case mod: | ||
247 | setPixmap(promptColIdx, list->symbolModPix); | ||
248 | setText(modColIdx, "M"); | ||
249 | ch = 'M'; | ||
250 | break; | ||
251 | default: | ||
252 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) | ||
253 | setPixmap(promptColIdx, list->choiceNoPix); | ||
254 | else | ||
255 | setPixmap(promptColIdx, list->symbolNoPix); | ||
256 | setText(noColIdx, "N"); | ||
257 | ch = 'N'; | ||
258 | break; | ||
259 | } | ||
260 | if (expr != no) | ||
261 | setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0); | ||
262 | if (expr != mod) | ||
263 | setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0); | ||
264 | if (expr != yes) | ||
265 | setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0); | ||
266 | |||
267 | setText(dataColIdx, QChar(ch)); | ||
268 | break; | ||
269 | case S_INT: | ||
270 | case S_HEX: | ||
271 | case S_STRING: | ||
272 | const char* data; | ||
273 | |||
274 | data = sym_get_string_value(sym); | ||
275 | |||
276 | #if QT_VERSION >= 300 | ||
277 | int i = list->mapIdx(dataColIdx); | ||
278 | if (i >= 0) | ||
279 | setRenameEnabled(i, TRUE); | ||
280 | #endif | ||
281 | setText(dataColIdx, data); | ||
282 | if (type == S_STRING) | ||
283 | prompt = QString("%1: %2").arg(prompt).arg(data); | ||
284 | else | ||
285 | prompt = QString("(%2) %1").arg(prompt).arg(data); | ||
286 | break; | ||
287 | } | ||
288 | if (!sym_has_value(sym) && visible) | ||
289 | prompt += " (NEW)"; | ||
290 | set_prompt: | ||
291 | setText(promptColIdx, prompt); | ||
292 | } | ||
293 | |||
294 | void ConfigItem::testUpdateMenu(bool v) | ||
295 | { | ||
296 | ConfigItem* i; | ||
297 | |||
298 | visible = v; | ||
299 | if (!menu) | ||
300 | return; | ||
301 | |||
302 | sym_calc_value(menu->sym); | ||
303 | if (menu->flags & MENU_CHANGED) { | ||
304 | /* the menu entry changed, so update all list items */ | ||
305 | menu->flags &= ~MENU_CHANGED; | ||
306 | for (i = (ConfigItem*)menu->data; i; i = i->nextItem) | ||
307 | i->updateMenu(); | ||
308 | } else if (listView()->updateAll) | ||
309 | updateMenu(); | ||
310 | } | ||
311 | |||
312 | void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) | ||
313 | { | ||
314 | ConfigList* list = listView(); | ||
315 | |||
316 | if (visible) { | ||
317 | if (isSelected() && !list->hasFocus() && list->mode == menuMode) | ||
318 | Parent::paintCell(p, list->inactivedColorGroup, column, width, align); | ||
319 | else | ||
320 | Parent::paintCell(p, cg, column, width, align); | ||
321 | } else | ||
322 | Parent::paintCell(p, list->disabledColorGroup, column, width, align); | ||
323 | } | ||
324 | |||
325 | /* | ||
326 | * construct a menu entry | ||
327 | */ | ||
328 | void ConfigItem::init(void) | ||
329 | { | ||
330 | if (menu) { | ||
331 | ConfigList* list = listView(); | ||
332 | nextItem = (ConfigItem*)menu->data; | ||
333 | menu->data = this; | ||
334 | |||
335 | if (list->mode != fullMode) | ||
336 | setOpen(TRUE); | ||
337 | sym_calc_value(menu->sym); | ||
338 | } | ||
339 | updateMenu(); | ||
340 | } | ||
341 | |||
342 | /* | ||
343 | * destruct a menu entry | ||
344 | */ | ||
345 | ConfigItem::~ConfigItem(void) | ||
346 | { | ||
347 | if (menu) { | ||
348 | ConfigItem** ip = (ConfigItem**)&menu->data; | ||
349 | for (; *ip; ip = &(*ip)->nextItem) { | ||
350 | if (*ip == this) { | ||
351 | *ip = nextItem; | ||
352 | break; | ||
353 | } | ||
354 | } | ||
355 | } | ||
356 | } | ||
357 | |||
358 | void ConfigLineEdit::show(ConfigItem* i) | ||
359 | { | ||
360 | item = i; | ||
361 | if (sym_get_string_value(item->menu->sym)) | ||
362 | setText(QString::fromLocal8Bit(sym_get_string_value(item->menu->sym))); | ||
363 | else | ||
364 | setText(QString::null); | ||
365 | Parent::show(); | ||
366 | setFocus(); | ||
367 | } | ||
368 | |||
369 | void ConfigLineEdit::keyPressEvent(QKeyEvent* e) | ||
370 | { | ||
371 | switch (e->key()) { | ||
372 | case Key_Escape: | ||
373 | break; | ||
374 | case Key_Return: | ||
375 | case Key_Enter: | ||
376 | sym_set_string_value(item->menu->sym, text().latin1()); | ||
377 | parent()->updateList(item); | ||
378 | break; | ||
379 | default: | ||
380 | Parent::keyPressEvent(e); | ||
381 | return; | ||
382 | } | ||
383 | e->accept(); | ||
384 | parent()->list->setFocus(); | ||
385 | hide(); | ||
386 | } | ||
387 | |||
388 | ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv, ConfigSettings* configSettings) | ||
389 | : Parent(p), cview(cv), | ||
390 | updateAll(false), | ||
391 | symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), | ||
392 | choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), | ||
393 | menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), | ||
394 | showAll(false), showName(false), showRange(false), showData(false), | ||
395 | rootEntry(0) | ||
396 | { | ||
397 | int i; | ||
398 | |||
399 | setSorting(-1); | ||
400 | setRootIsDecorated(TRUE); | ||
401 | disabledColorGroup = palette().active(); | ||
402 | disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text()); | ||
403 | inactivedColorGroup = palette().active(); | ||
404 | inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight()); | ||
405 | |||
406 | connect(this, SIGNAL(selectionChanged(void)), | ||
407 | SLOT(updateSelection(void))); | ||
408 | |||
409 | if (configSettings) { | ||
410 | showAll = configSettings->showAll; | ||
411 | showName = configSettings->showName; | ||
412 | showRange = configSettings->showRange; | ||
413 | showData = configSettings->showData; | ||
414 | } | ||
415 | |||
416 | for (i = 0; i < colNr; i++) | ||
417 | colMap[i] = colRevMap[i] = -1; | ||
418 | addColumn(promptColIdx, "Option"); | ||
419 | |||
420 | reinit(); | ||
421 | } | ||
422 | |||
423 | void ConfigList::reinit(void) | ||
424 | { | ||
425 | removeColumn(dataColIdx); | ||
426 | removeColumn(yesColIdx); | ||
427 | removeColumn(modColIdx); | ||
428 | removeColumn(noColIdx); | ||
429 | removeColumn(nameColIdx); | ||
430 | |||
431 | if (showName) | ||
432 | addColumn(nameColIdx, "Name"); | ||
433 | if (showRange) { | ||
434 | addColumn(noColIdx, "N"); | ||
435 | addColumn(modColIdx, "M"); | ||
436 | addColumn(yesColIdx, "Y"); | ||
437 | } | ||
438 | if (showData) | ||
439 | addColumn(dataColIdx, "Value"); | ||
440 | |||
441 | updateListAll(); | ||
442 | } | ||
443 | |||
444 | void ConfigList::updateSelection(void) | ||
445 | { | ||
446 | struct menu *menu; | ||
447 | enum prop_type type; | ||
448 | |||
449 | ConfigItem* item = (ConfigItem*)selectedItem(); | ||
450 | if (!item) | ||
451 | return; | ||
452 | |||
453 | cview->setHelp(item); | ||
454 | |||
455 | menu = item->menu; | ||
456 | if (!menu) | ||
457 | return; | ||
458 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; | ||
459 | if (mode == menuMode && type == P_MENU) | ||
460 | emit menuSelected(menu); | ||
461 | } | ||
462 | |||
463 | void ConfigList::updateList(ConfigItem* item) | ||
464 | { | ||
465 | ConfigItem* last = 0; | ||
466 | |||
467 | if (!rootEntry) | ||
468 | goto update; | ||
469 | |||
470 | if (rootEntry != &rootmenu && (mode == singleMode || | ||
471 | (mode == symbolMode && rootEntry->parent != &rootmenu))) { | ||
472 | item = firstChild(); | ||
473 | if (!item) | ||
474 | item = new ConfigItem(this, 0, true); | ||
475 | last = item; | ||
476 | } | ||
477 | if ((mode == singleMode || (mode == symbolMode && !(rootEntry->flags & MENU_ROOT))) && | ||
478 | rootEntry->sym && rootEntry->prompt) { | ||
479 | item = last ? last->nextSibling() : firstChild(); | ||
480 | if (!item) | ||
481 | item = new ConfigItem(this, last, rootEntry, true); | ||
482 | else | ||
483 | item->testUpdateMenu(true); | ||
484 | |||
485 | updateMenuList(item, rootEntry); | ||
486 | triggerUpdate(); | ||
487 | return; | ||
488 | } | ||
489 | update: | ||
490 | updateMenuList(this, rootEntry); | ||
491 | triggerUpdate(); | ||
492 | } | ||
493 | |||
494 | void ConfigList::setAllOpen(bool open) | ||
495 | { | ||
496 | QListViewItemIterator it(this); | ||
497 | |||
498 | for (; it.current(); it++) | ||
499 | it.current()->setOpen(open); | ||
500 | } | ||
501 | |||
502 | void ConfigList::setValue(ConfigItem* item, tristate val) | ||
503 | { | ||
504 | struct symbol* sym; | ||
505 | int type; | ||
506 | tristate oldval; | ||
507 | |||
508 | sym = item->menu ? item->menu->sym : 0; | ||
509 | if (!sym) | ||
510 | return; | ||
511 | |||
512 | type = sym_get_type(sym); | ||
513 | switch (type) { | ||
514 | case S_BOOLEAN: | ||
515 | case S_TRISTATE: | ||
516 | oldval = sym_get_tristate_value(sym); | ||
517 | |||
518 | if (!sym_set_tristate_value(sym, val)) | ||
519 | return; | ||
520 | if (oldval == no && item->menu->list) | ||
521 | item->setOpen(TRUE); | ||
522 | parent()->updateList(item); | ||
523 | break; | ||
524 | } | ||
525 | } | ||
526 | |||
527 | void ConfigList::changeValue(ConfigItem* item) | ||
528 | { | ||
529 | struct symbol* sym; | ||
530 | struct menu* menu; | ||
531 | int type, oldexpr, newexpr; | ||
532 | |||
533 | menu = item->menu; | ||
534 | if (!menu) | ||
535 | return; | ||
536 | sym = menu->sym; | ||
537 | if (!sym) { | ||
538 | if (item->menu->list) | ||
539 | item->setOpen(!item->isOpen()); | ||
540 | return; | ||
541 | } | ||
542 | |||
543 | type = sym_get_type(sym); | ||
544 | switch (type) { | ||
545 | case S_BOOLEAN: | ||
546 | case S_TRISTATE: | ||
547 | oldexpr = sym_get_tristate_value(sym); | ||
548 | newexpr = sym_toggle_tristate_value(sym); | ||
549 | if (item->menu->list) { | ||
550 | if (oldexpr == newexpr) | ||
551 | item->setOpen(!item->isOpen()); | ||
552 | else if (oldexpr == no) | ||
553 | item->setOpen(TRUE); | ||
554 | } | ||
555 | if (oldexpr != newexpr) | ||
556 | parent()->updateList(item); | ||
557 | break; | ||
558 | case S_INT: | ||
559 | case S_HEX: | ||
560 | case S_STRING: | ||
561 | #if QT_VERSION >= 300 | ||
562 | if (colMap[dataColIdx] >= 0) | ||
563 | item->startRename(colMap[dataColIdx]); | ||
564 | else | ||
565 | #endif | ||
566 | parent()->lineEdit->show(item); | ||
567 | break; | ||
568 | } | ||
569 | } | ||
570 | |||
571 | void ConfigList::setRootMenu(struct menu *menu) | ||
572 | { | ||
573 | enum prop_type type; | ||
574 | |||
575 | if (rootEntry == menu) | ||
576 | return; | ||
577 | type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; | ||
578 | if (type != P_MENU) | ||
579 | return; | ||
580 | updateMenuList(this, 0); | ||
581 | rootEntry = menu; | ||
582 | updateListAll(); | ||
583 | setSelected(currentItem(), hasFocus()); | ||
584 | } | ||
585 | |||
586 | void ConfigList::setParentMenu(void) | ||
587 | { | ||
588 | ConfigItem* item; | ||
589 | struct menu *oldroot; | ||
590 | |||
591 | oldroot = rootEntry; | ||
592 | if (rootEntry == &rootmenu) | ||
593 | return; | ||
594 | setRootMenu(menu_get_parent_menu(rootEntry->parent)); | ||
595 | |||
596 | QListViewItemIterator it(this); | ||
597 | for (; (item = (ConfigItem*)it.current()); it++) { | ||
598 | if (item->menu == oldroot) { | ||
599 | setCurrentItem(item); | ||
600 | ensureItemVisible(item); | ||
601 | break; | ||
602 | } | ||
603 | } | ||
604 | } | ||
605 | |||
606 | void ConfigList::keyPressEvent(QKeyEvent* ev) | ||
607 | { | ||
608 | QListViewItem* i = currentItem(); | ||
609 | ConfigItem* item; | ||
610 | struct menu *menu; | ||
611 | enum prop_type type; | ||
612 | |||
613 | if (ev->key() == Key_Escape && mode != fullMode) { | ||
614 | emit parentSelected(); | ||
615 | ev->accept(); | ||
616 | return; | ||
617 | } | ||
618 | |||
619 | if (!i) { | ||
620 | Parent::keyPressEvent(ev); | ||
621 | return; | ||
622 | } | ||
623 | item = (ConfigItem*)i; | ||
624 | |||
625 | switch (ev->key()) { | ||
626 | case Key_Return: | ||
627 | case Key_Enter: | ||
628 | if (item->goParent) { | ||
629 | emit parentSelected(); | ||
630 | break; | ||
631 | } | ||
632 | menu = item->menu; | ||
633 | if (!menu) | ||
634 | break; | ||
635 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; | ||
636 | if (type == P_MENU && rootEntry != menu && | ||
637 | mode != fullMode && mode != menuMode) { | ||
638 | emit menuSelected(menu); | ||
639 | break; | ||
640 | } | ||
641 | case Key_Space: | ||
642 | changeValue(item); | ||
643 | break; | ||
644 | case Key_N: | ||
645 | setValue(item, no); | ||
646 | break; | ||
647 | case Key_M: | ||
648 | setValue(item, mod); | ||
649 | break; | ||
650 | case Key_Y: | ||
651 | setValue(item, yes); | ||
652 | break; | ||
653 | default: | ||
654 | Parent::keyPressEvent(ev); | ||
655 | return; | ||
656 | } | ||
657 | ev->accept(); | ||
658 | } | ||
659 | |||
660 | void ConfigList::contentsMousePressEvent(QMouseEvent* e) | ||
661 | { | ||
662 | //QPoint p(contentsToViewport(e->pos())); | ||
663 | //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y()); | ||
664 | Parent::contentsMousePressEvent(e); | ||
665 | } | ||
666 | |||
667 | void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) | ||
668 | { | ||
669 | QPoint p(contentsToViewport(e->pos())); | ||
670 | ConfigItem* item = (ConfigItem*)itemAt(p); | ||
671 | struct menu *menu; | ||
672 | enum prop_type ptype; | ||
673 | const QPixmap* pm; | ||
674 | int idx, x; | ||
675 | |||
676 | if (!item) | ||
677 | goto skip; | ||
678 | |||
679 | menu = item->menu; | ||
680 | x = header()->offset() + p.x(); | ||
681 | idx = colRevMap[header()->sectionAt(x)]; | ||
682 | switch (idx) { | ||
683 | case promptColIdx: | ||
684 | pm = item->pixmap(promptColIdx); | ||
685 | if (pm) { | ||
686 | int off = header()->sectionPos(0) + itemMargin() + | ||
687 | treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)); | ||
688 | if (x >= off && x < off + pm->width()) { | ||
689 | if (item->goParent) { | ||
690 | emit parentSelected(); | ||
691 | break; | ||
692 | } else if (!menu) | ||
693 | break; | ||
694 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | ||
695 | if (ptype == P_MENU && rootEntry != menu && | ||
696 | mode != fullMode && mode != menuMode) | ||
697 | emit menuSelected(menu); | ||
698 | else | ||
699 | changeValue(item); | ||
700 | } | ||
701 | } | ||
702 | break; | ||
703 | case noColIdx: | ||
704 | setValue(item, no); | ||
705 | break; | ||
706 | case modColIdx: | ||
707 | setValue(item, mod); | ||
708 | break; | ||
709 | case yesColIdx: | ||
710 | setValue(item, yes); | ||
711 | break; | ||
712 | case dataColIdx: | ||
713 | changeValue(item); | ||
714 | break; | ||
715 | } | ||
716 | |||
717 | skip: | ||
718 | //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y()); | ||
719 | Parent::contentsMouseReleaseEvent(e); | ||
720 | } | ||
721 | |||
722 | void ConfigList::contentsMouseMoveEvent(QMouseEvent* e) | ||
723 | { | ||
724 | //QPoint p(contentsToViewport(e->pos())); | ||
725 | //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y()); | ||
726 | Parent::contentsMouseMoveEvent(e); | ||
727 | } | ||
728 | |||
729 | void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) | ||
730 | { | ||
731 | QPoint p(contentsToViewport(e->pos())); | ||
732 | ConfigItem* item = (ConfigItem*)itemAt(p); | ||
733 | struct menu *menu; | ||
734 | enum prop_type ptype; | ||
735 | |||
736 | if (!item) | ||
737 | goto skip; | ||
738 | if (item->goParent) { | ||
739 | emit parentSelected(); | ||
740 | goto skip; | ||
741 | } | ||
742 | menu = item->menu; | ||
743 | if (!menu) | ||
744 | goto skip; | ||
745 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | ||
746 | if (ptype == P_MENU && (mode == singleMode || mode == symbolMode)) | ||
747 | emit menuSelected(menu); | ||
748 | else if (menu->sym) | ||
749 | changeValue(item); | ||
750 | |||
751 | skip: | ||
752 | //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); | ||
753 | Parent::contentsMouseDoubleClickEvent(e); | ||
754 | } | ||
755 | |||
756 | void ConfigList::focusInEvent(QFocusEvent *e) | ||
757 | { | ||
758 | Parent::focusInEvent(e); | ||
759 | |||
760 | QListViewItem* item = currentItem(); | ||
761 | if (!item) | ||
762 | return; | ||
763 | |||
764 | setSelected(item, TRUE); | ||
765 | emit gotFocus(); | ||
766 | } | ||
767 | |||
768 | ConfigView* ConfigView::viewList; | ||
769 | |||
770 | ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview, | ||
771 | ConfigSettings *configSettings) | ||
772 | : Parent(parent) | ||
773 | { | ||
774 | list = new ConfigList(this, cview, configSettings); | ||
775 | lineEdit = new ConfigLineEdit(this); | ||
776 | lineEdit->hide(); | ||
777 | |||
778 | this->nextView = viewList; | ||
779 | viewList = this; | ||
780 | } | ||
781 | |||
782 | ConfigView::~ConfigView(void) | ||
783 | { | ||
784 | ConfigView** vp; | ||
785 | |||
786 | for (vp = &viewList; *vp; vp = &(*vp)->nextView) { | ||
787 | if (*vp == this) { | ||
788 | *vp = nextView; | ||
789 | break; | ||
790 | } | ||
791 | } | ||
792 | } | ||
793 | |||
794 | void ConfigView::updateList(ConfigItem* item) | ||
795 | { | ||
796 | ConfigView* v; | ||
797 | |||
798 | for (v = viewList; v; v = v->nextView) | ||
799 | v->list->updateList(item); | ||
800 | } | ||
801 | |||
802 | void ConfigView::updateListAll(void) | ||
803 | { | ||
804 | ConfigView* v; | ||
805 | |||
806 | for (v = viewList; v; v = v->nextView) | ||
807 | v->list->updateListAll(); | ||
808 | } | ||
809 | |||
810 | /* | ||
811 | * Construct the complete config widget | ||
812 | */ | ||
813 | ConfigMainWindow::ConfigMainWindow(void) | ||
814 | { | ||
815 | QMenuBar* menu; | ||
816 | bool ok; | ||
817 | int x, y, width, height; | ||
818 | |||
819 | QWidget *d = configApp->desktop(); | ||
820 | |||
821 | ConfigSettings* configSettings = new ConfigSettings(); | ||
822 | #if QT_VERSION >= 300 | ||
823 | width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64); | ||
824 | height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64); | ||
825 | resize(width, height); | ||
826 | x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok); | ||
827 | if (ok) | ||
828 | y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok); | ||
829 | if (ok) | ||
830 | move(x, y); | ||
831 | showDebug = configSettings->readBoolEntry("/kconfig/qconf/showDebug", false); | ||
832 | |||
833 | // read list settings into configSettings, will be used later for ConfigList setup | ||
834 | configSettings->readListSettings(); | ||
835 | #else | ||
836 | width = d->width() - 64; | ||
837 | height = d->height() - 64; | ||
838 | resize(width, height); | ||
839 | showDebug = false; | ||
840 | #endif | ||
841 | |||
842 | split1 = new QSplitter(this); | ||
843 | split1->setOrientation(QSplitter::Horizontal); | ||
844 | setCentralWidget(split1); | ||
845 | |||
846 | menuView = new ConfigView(split1, this, configSettings); | ||
847 | menuList = menuView->list; | ||
848 | |||
849 | split2 = new QSplitter(split1); | ||
850 | split2->setOrientation(QSplitter::Vertical); | ||
851 | |||
852 | // create config tree | ||
853 | configView = new ConfigView(split2, this, configSettings); | ||
854 | configList = configView->list; | ||
855 | |||
856 | helpText = new QTextView(split2); | ||
857 | helpText->setTextFormat(Qt::RichText); | ||
858 | |||
859 | setTabOrder(configList, helpText); | ||
860 | configList->setFocus(); | ||
861 | |||
862 | menu = menuBar(); | ||
863 | toolBar = new QToolBar("Tools", this); | ||
864 | |||
865 | backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this); | ||
866 | connect(backAction, SIGNAL(activated()), SLOT(goBack())); | ||
867 | backAction->setEnabled(FALSE); | ||
868 | QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this); | ||
869 | connect(quitAction, SIGNAL(activated()), SLOT(close())); | ||
870 | QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this); | ||
871 | connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); | ||
872 | QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this); | ||
873 | connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); | ||
874 | QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this); | ||
875 | connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); | ||
876 | QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this); | ||
877 | connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); | ||
878 | QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this); | ||
879 | connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView())); | ||
880 | QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this); | ||
881 | connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); | ||
882 | |||
883 | QAction *showNameAction = new QAction(NULL, "Show Name", 0, this); | ||
884 | showNameAction->setToggleAction(TRUE); | ||
885 | showNameAction->setOn(configList->showName); | ||
886 | connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool))); | ||
887 | QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this); | ||
888 | showRangeAction->setToggleAction(TRUE); | ||
889 | showRangeAction->setOn(configList->showRange); | ||
890 | connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool))); | ||
891 | QAction *showDataAction = new QAction(NULL, "Show Data", 0, this); | ||
892 | showDataAction->setToggleAction(TRUE); | ||
893 | showDataAction->setOn(configList->showData); | ||
894 | connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool))); | ||
895 | QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this); | ||
896 | showAllAction->setToggleAction(TRUE); | ||
897 | showAllAction->setOn(configList->showAll); | ||
898 | connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool))); | ||
899 | QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this); | ||
900 | showDebugAction->setToggleAction(TRUE); | ||
901 | showDebugAction->setOn(showDebug); | ||
902 | connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); | ||
903 | |||
904 | QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this); | ||
905 | connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro())); | ||
906 | QAction *showAboutAction = new QAction(NULL, "About", 0, this); | ||
907 | connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout())); | ||
908 | |||
909 | // init tool bar | ||
910 | backAction->addTo(toolBar); | ||
911 | toolBar->addSeparator(); | ||
912 | loadAction->addTo(toolBar); | ||
913 | saveAction->addTo(toolBar); | ||
914 | toolBar->addSeparator(); | ||
915 | singleViewAction->addTo(toolBar); | ||
916 | splitViewAction->addTo(toolBar); | ||
917 | fullViewAction->addTo(toolBar); | ||
918 | |||
919 | // create config menu | ||
920 | QPopupMenu* config = new QPopupMenu(this); | ||
921 | menu->insertItem("&File", config); | ||
922 | loadAction->addTo(config); | ||
923 | saveAction->addTo(config); | ||
924 | saveAsAction->addTo(config); | ||
925 | config->insertSeparator(); | ||
926 | quitAction->addTo(config); | ||
927 | |||
928 | // create options menu | ||
929 | QPopupMenu* optionMenu = new QPopupMenu(this); | ||
930 | menu->insertItem("&Option", optionMenu); | ||
931 | showNameAction->addTo(optionMenu); | ||
932 | showRangeAction->addTo(optionMenu); | ||
933 | showDataAction->addTo(optionMenu); | ||
934 | optionMenu->insertSeparator(); | ||
935 | showAllAction->addTo(optionMenu); | ||
936 | showDebugAction->addTo(optionMenu); | ||
937 | |||
938 | // create help menu | ||
939 | QPopupMenu* helpMenu = new QPopupMenu(this); | ||
940 | menu->insertSeparator(); | ||
941 | menu->insertItem("&Help", helpMenu); | ||
942 | showIntroAction->addTo(helpMenu); | ||
943 | showAboutAction->addTo(helpMenu); | ||
944 | |||
945 | connect(configList, SIGNAL(menuSelected(struct menu *)), | ||
946 | SLOT(changeMenu(struct menu *))); | ||
947 | connect(configList, SIGNAL(parentSelected()), | ||
948 | SLOT(goBack())); | ||
949 | connect(menuList, SIGNAL(menuSelected(struct menu *)), | ||
950 | SLOT(changeMenu(struct menu *))); | ||
951 | |||
952 | connect(configList, SIGNAL(gotFocus(void)), | ||
953 | SLOT(listFocusChanged(void))); | ||
954 | connect(menuList, SIGNAL(gotFocus(void)), | ||
955 | SLOT(listFocusChanged(void))); | ||
956 | |||
957 | #if QT_VERSION >= 300 | ||
958 | QString listMode = configSettings->readEntry("/kconfig/qconf/listMode", "symbol"); | ||
959 | if (listMode == "single") | ||
960 | showSingleView(); | ||
961 | else if (listMode == "full") | ||
962 | showFullView(); | ||
963 | else /*if (listMode == "split")*/ | ||
964 | showSplitView(); | ||
965 | |||
966 | // UI setup done, restore splitter positions | ||
967 | QValueList<int> sizes = configSettings->readSizes("/kconfig/qconf/split1", &ok); | ||
968 | if (ok) | ||
969 | split1->setSizes(sizes); | ||
970 | |||
971 | sizes = configSettings->readSizes("/kconfig/qconf/split2", &ok); | ||
972 | if (ok) | ||
973 | split2->setSizes(sizes); | ||
974 | #else | ||
975 | showSplitView(); | ||
976 | #endif | ||
977 | delete configSettings; | ||
978 | } | ||
979 | |||
980 | static QString print_filter(const QString &str) | ||
981 | { | ||
982 | QRegExp re("[<>&\"\\n]"); | ||
983 | QString res = str; | ||
984 | for (int i = 0; (i = res.find(re, i)) >= 0;) { | ||
985 | switch (res[i].latin1()) { | ||
986 | case '<': | ||
987 | res.replace(i, 1, "<"); | ||
988 | i += 4; | ||
989 | break; | ||
990 | case '>': | ||
991 | res.replace(i, 1, ">"); | ||
992 | i += 4; | ||
993 | break; | ||
994 | case '&': | ||
995 | res.replace(i, 1, "&"); | ||
996 | i += 5; | ||
997 | break; | ||
998 | case '"': | ||
999 | res.replace(i, 1, """); | ||
1000 | i += 6; | ||
1001 | break; | ||
1002 | case '\n': | ||
1003 | res.replace(i, 1, "<br>"); | ||
1004 | i += 4; | ||
1005 | break; | ||
1006 | } | ||
1007 | } | ||
1008 | return res; | ||
1009 | } | ||
1010 | |||
1011 | static void expr_print_help(void *data, const char *str) | ||
1012 | { | ||
1013 | reinterpret_cast<QString*>(data)->append(print_filter(str)); | ||
1014 | } | ||
1015 | |||
1016 | /* | ||
1017 | * display a new help entry as soon as a new menu entry is selected | ||
1018 | */ | ||
1019 | void ConfigMainWindow::setHelp(QListViewItem* item) | ||
1020 | { | ||
1021 | struct symbol* sym; | ||
1022 | struct menu* menu = 0; | ||
1023 | |||
1024 | configList->parent()->lineEdit->hide(); | ||
1025 | if (item) | ||
1026 | menu = ((ConfigItem*)item)->menu; | ||
1027 | if (!menu) { | ||
1028 | helpText->setText(QString::null); | ||
1029 | return; | ||
1030 | } | ||
1031 | |||
1032 | QString head, debug, help; | ||
1033 | menu = ((ConfigItem*)item)->menu; | ||
1034 | sym = menu->sym; | ||
1035 | if (sym) { | ||
1036 | if (menu->prompt) { | ||
1037 | head += "<big><b>"; | ||
1038 | head += print_filter(_(menu->prompt->text)); | ||
1039 | head += "</b></big>"; | ||
1040 | if (sym->name) { | ||
1041 | head += " ("; | ||
1042 | head += print_filter(_(sym->name)); | ||
1043 | head += ")"; | ||
1044 | } | ||
1045 | } else if (sym->name) { | ||
1046 | head += "<big><b>"; | ||
1047 | head += print_filter(_(sym->name)); | ||
1048 | head += "</b></big>"; | ||
1049 | } | ||
1050 | head += "<br><br>"; | ||
1051 | |||
1052 | if (showDebug) { | ||
1053 | debug += "type: "; | ||
1054 | debug += print_filter(sym_type_name(sym->type)); | ||
1055 | if (sym_is_choice(sym)) | ||
1056 | debug += " (choice)"; | ||
1057 | debug += "<br>"; | ||
1058 | if (sym->rev_dep.expr) { | ||
1059 | debug += "reverse dep: "; | ||
1060 | expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE); | ||
1061 | debug += "<br>"; | ||
1062 | } | ||
1063 | for (struct property *prop = sym->prop; prop; prop = prop->next) { | ||
1064 | switch (prop->type) { | ||
1065 | case P_PROMPT: | ||
1066 | case P_MENU: | ||
1067 | debug += "prompt: "; | ||
1068 | debug += print_filter(_(prop->text)); | ||
1069 | debug += "<br>"; | ||
1070 | break; | ||
1071 | case P_DEFAULT: | ||
1072 | debug += "default: "; | ||
1073 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
1074 | debug += "<br>"; | ||
1075 | break; | ||
1076 | case P_CHOICE: | ||
1077 | if (sym_is_choice(sym)) { | ||
1078 | debug += "choice: "; | ||
1079 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
1080 | debug += "<br>"; | ||
1081 | } | ||
1082 | break; | ||
1083 | case P_SELECT: | ||
1084 | debug += "select: "; | ||
1085 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
1086 | debug += "<br>"; | ||
1087 | break; | ||
1088 | case P_RANGE: | ||
1089 | debug += "range: "; | ||
1090 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
1091 | debug += "<br>"; | ||
1092 | break; | ||
1093 | default: | ||
1094 | debug += "unknown property: "; | ||
1095 | debug += prop_get_type_name(prop->type); | ||
1096 | debug += "<br>"; | ||
1097 | } | ||
1098 | if (prop->visible.expr) { | ||
1099 | debug += " dep: "; | ||
1100 | expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); | ||
1101 | debug += "<br>"; | ||
1102 | } | ||
1103 | } | ||
1104 | debug += "<br>"; | ||
1105 | } | ||
1106 | |||
1107 | help = print_filter(_(sym->help)); | ||
1108 | } else if (menu->prompt) { | ||
1109 | head += "<big><b>"; | ||
1110 | head += print_filter(_(menu->prompt->text)); | ||
1111 | head += "</b></big><br><br>"; | ||
1112 | if (showDebug) { | ||
1113 | if (menu->prompt->visible.expr) { | ||
1114 | debug += " dep: "; | ||
1115 | expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); | ||
1116 | debug += "<br><br>"; | ||
1117 | } | ||
1118 | } | ||
1119 | } | ||
1120 | if (showDebug) | ||
1121 | debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno); | ||
1122 | helpText->setText(head + debug + help); | ||
1123 | } | ||
1124 | |||
1125 | void ConfigMainWindow::loadConfig(void) | ||
1126 | { | ||
1127 | QString s = QFileDialog::getOpenFileName(".config", NULL, this); | ||
1128 | if (s.isNull()) | ||
1129 | return; | ||
1130 | if (conf_read(QFile::encodeName(s))) | ||
1131 | QMessageBox::information(this, "qconf", "Unable to load configuration!"); | ||
1132 | ConfigView::updateListAll(); | ||
1133 | } | ||
1134 | |||
1135 | void ConfigMainWindow::saveConfig(void) | ||
1136 | { | ||
1137 | if (conf_write(NULL)) | ||
1138 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); | ||
1139 | } | ||
1140 | |||
1141 | void ConfigMainWindow::saveConfigAs(void) | ||
1142 | { | ||
1143 | QString s = QFileDialog::getSaveFileName(".config", NULL, this); | ||
1144 | if (s.isNull()) | ||
1145 | return; | ||
1146 | if (conf_write(QFile::encodeName(s))) | ||
1147 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); | ||
1148 | } | ||
1149 | |||
1150 | void ConfigMainWindow::changeMenu(struct menu *menu) | ||
1151 | { | ||
1152 | configList->setRootMenu(menu); | ||
1153 | backAction->setEnabled(TRUE); | ||
1154 | } | ||
1155 | |||
1156 | void ConfigMainWindow::listFocusChanged(void) | ||
1157 | { | ||
1158 | if (menuList->hasFocus()) { | ||
1159 | if (menuList->mode == menuMode) | ||
1160 | configList->clearSelection(); | ||
1161 | setHelp(menuList->selectedItem()); | ||
1162 | } else if (configList->hasFocus()) { | ||
1163 | setHelp(configList->selectedItem()); | ||
1164 | } | ||
1165 | } | ||
1166 | |||
1167 | void ConfigMainWindow::goBack(void) | ||
1168 | { | ||
1169 | ConfigItem* item; | ||
1170 | |||
1171 | configList->setParentMenu(); | ||
1172 | if (configList->rootEntry == &rootmenu) | ||
1173 | backAction->setEnabled(FALSE); | ||
1174 | item = (ConfigItem*)menuList->selectedItem(); | ||
1175 | while (item) { | ||
1176 | if (item->menu == configList->rootEntry) { | ||
1177 | menuList->setSelected(item, TRUE); | ||
1178 | break; | ||
1179 | } | ||
1180 | item = (ConfigItem*)item->parent(); | ||
1181 | } | ||
1182 | } | ||
1183 | |||
1184 | void ConfigMainWindow::showSingleView(void) | ||
1185 | { | ||
1186 | menuView->hide(); | ||
1187 | menuList->setRootMenu(0); | ||
1188 | configList->mode = singleMode; | ||
1189 | if (configList->rootEntry == &rootmenu) | ||
1190 | configList->updateListAll(); | ||
1191 | else | ||
1192 | configList->setRootMenu(&rootmenu); | ||
1193 | configList->setAllOpen(TRUE); | ||
1194 | configList->setFocus(); | ||
1195 | } | ||
1196 | |||
1197 | void ConfigMainWindow::showSplitView(void) | ||
1198 | { | ||
1199 | configList->mode = symbolMode; | ||
1200 | if (configList->rootEntry == &rootmenu) | ||
1201 | configList->updateListAll(); | ||
1202 | else | ||
1203 | configList->setRootMenu(&rootmenu); | ||
1204 | configList->setAllOpen(TRUE); | ||
1205 | configApp->processEvents(); | ||
1206 | menuList->mode = menuMode; | ||
1207 | menuList->setRootMenu(&rootmenu); | ||
1208 | menuList->setAllOpen(TRUE); | ||
1209 | menuView->show(); | ||
1210 | menuList->setFocus(); | ||
1211 | } | ||
1212 | |||
1213 | void ConfigMainWindow::showFullView(void) | ||
1214 | { | ||
1215 | menuView->hide(); | ||
1216 | menuList->setRootMenu(0); | ||
1217 | configList->mode = fullMode; | ||
1218 | if (configList->rootEntry == &rootmenu) | ||
1219 | configList->updateListAll(); | ||
1220 | else | ||
1221 | configList->setRootMenu(&rootmenu); | ||
1222 | configList->setAllOpen(FALSE); | ||
1223 | configList->setFocus(); | ||
1224 | } | ||
1225 | |||
1226 | void ConfigMainWindow::setShowAll(bool b) | ||
1227 | { | ||
1228 | if (configList->showAll == b) | ||
1229 | return; | ||
1230 | configList->showAll = b; | ||
1231 | configList->updateListAll(); | ||
1232 | menuList->showAll = b; | ||
1233 | menuList->updateListAll(); | ||
1234 | } | ||
1235 | |||
1236 | void ConfigMainWindow::setShowDebug(bool b) | ||
1237 | { | ||
1238 | if (showDebug == b) | ||
1239 | return; | ||
1240 | showDebug = b; | ||
1241 | } | ||
1242 | |||
1243 | void ConfigMainWindow::setShowName(bool b) | ||
1244 | { | ||
1245 | if (configList->showName == b) | ||
1246 | return; | ||
1247 | configList->showName = b; | ||
1248 | configList->reinit(); | ||
1249 | menuList->showName = b; | ||
1250 | menuList->reinit(); | ||
1251 | } | ||
1252 | |||
1253 | void ConfigMainWindow::setShowRange(bool b) | ||
1254 | { | ||
1255 | if (configList->showRange == b) | ||
1256 | return; | ||
1257 | configList->showRange = b; | ||
1258 | configList->reinit(); | ||
1259 | menuList->showRange = b; | ||
1260 | menuList->reinit(); | ||
1261 | } | ||
1262 | |||
1263 | void ConfigMainWindow::setShowData(bool b) | ||
1264 | { | ||
1265 | if (configList->showData == b) | ||
1266 | return; | ||
1267 | configList->showData = b; | ||
1268 | configList->reinit(); | ||
1269 | menuList->showData = b; | ||
1270 | menuList->reinit(); | ||
1271 | } | ||
1272 | |||
1273 | /* | ||
1274 | * ask for saving configuration before quitting | ||
1275 | * TODO ask only when something changed | ||
1276 | */ | ||
1277 | void ConfigMainWindow::closeEvent(QCloseEvent* e) | ||
1278 | { | ||
1279 | if (!sym_change_count) { | ||
1280 | e->accept(); | ||
1281 | return; | ||
1282 | } | ||
1283 | QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning, | ||
1284 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); | ||
1285 | mb.setButtonText(QMessageBox::Yes, "&Save Changes"); | ||
1286 | mb.setButtonText(QMessageBox::No, "&Discard Changes"); | ||
1287 | mb.setButtonText(QMessageBox::Cancel, "Cancel Exit"); | ||
1288 | switch (mb.exec()) { | ||
1289 | case QMessageBox::Yes: | ||
1290 | conf_write(NULL); | ||
1291 | case QMessageBox::No: | ||
1292 | e->accept(); | ||
1293 | break; | ||
1294 | case QMessageBox::Cancel: | ||
1295 | e->ignore(); | ||
1296 | break; | ||
1297 | } | ||
1298 | } | ||
1299 | |||
1300 | void ConfigMainWindow::showIntro(void) | ||
1301 | { | ||
1302 | static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n" | ||
1303 | "For each option, a blank box indicates the feature is disabled, a check\n" | ||
1304 | "indicates it is enabled, and a dot indicates that it is to be compiled\n" | ||
1305 | "as a module. Clicking on the box will cycle through the three states.\n\n" | ||
1306 | "If you do not see an option (e.g., a device driver) that you believe\n" | ||
1307 | "should be present, try turning on Show All Options under the Options menu.\n" | ||
1308 | "Although there is no cross reference yet to help you figure out what other\n" | ||
1309 | "options must be enabled to support the option you are interested in, you can\n" | ||
1310 | "still view the help of a grayed-out option.\n\n" | ||
1311 | "Toggling Show Debug Info under the Options menu will show the dependencies,\n" | ||
1312 | "which you can then match by examining other options.\n\n"; | ||
1313 | |||
1314 | QMessageBox::information(this, "qconf", str); | ||
1315 | } | ||
1316 | |||
1317 | void ConfigMainWindow::showAbout(void) | ||
1318 | { | ||
1319 | static char str[] = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n" | ||
1320 | "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; | ||
1321 | |||
1322 | QMessageBox::information(this, "qconf", str); | ||
1323 | } | ||
1324 | |||
1325 | void ConfigMainWindow::saveSettings(void) | ||
1326 | { | ||
1327 | #if QT_VERSION >= 300 | ||
1328 | ConfigSettings *configSettings = new ConfigSettings; | ||
1329 | configSettings->writeEntry("/kconfig/qconf/window x", pos().x()); | ||
1330 | configSettings->writeEntry("/kconfig/qconf/window y", pos().y()); | ||
1331 | configSettings->writeEntry("/kconfig/qconf/window width", size().width()); | ||
1332 | configSettings->writeEntry("/kconfig/qconf/window height", size().height()); | ||
1333 | configSettings->writeEntry("/kconfig/qconf/showName", configList->showName); | ||
1334 | configSettings->writeEntry("/kconfig/qconf/showRange", configList->showRange); | ||
1335 | configSettings->writeEntry("/kconfig/qconf/showData", configList->showData); | ||
1336 | configSettings->writeEntry("/kconfig/qconf/showAll", configList->showAll); | ||
1337 | configSettings->writeEntry("/kconfig/qconf/showDebug", showDebug); | ||
1338 | |||
1339 | QString entry; | ||
1340 | switch(configList->mode) { | ||
1341 | case singleMode : | ||
1342 | entry = "single"; | ||
1343 | break; | ||
1344 | |||
1345 | case symbolMode : | ||
1346 | entry = "split"; | ||
1347 | break; | ||
1348 | |||
1349 | case fullMode : | ||
1350 | entry = "full"; | ||
1351 | break; | ||
1352 | } | ||
1353 | configSettings->writeEntry("/kconfig/qconf/listMode", entry); | ||
1354 | |||
1355 | configSettings->writeSizes("/kconfig/qconf/split1", split1->sizes()); | ||
1356 | configSettings->writeSizes("/kconfig/qconf/split2", split2->sizes()); | ||
1357 | |||
1358 | delete configSettings; | ||
1359 | #endif | ||
1360 | } | ||
1361 | |||
1362 | void fixup_rootmenu(struct menu *menu) | ||
1363 | { | ||
1364 | struct menu *child; | ||
1365 | static int menu_cnt = 0; | ||
1366 | |||
1367 | menu->flags |= MENU_ROOT; | ||
1368 | for (child = menu->list; child; child = child->next) { | ||
1369 | if (child->prompt && child->prompt->type == P_MENU) { | ||
1370 | menu_cnt++; | ||
1371 | fixup_rootmenu(child); | ||
1372 | menu_cnt--; | ||
1373 | } else if (!menu_cnt) | ||
1374 | fixup_rootmenu(child); | ||
1375 | } | ||
1376 | } | ||
1377 | |||
1378 | static const char *progname; | ||
1379 | |||
1380 | static void usage(void) | ||
1381 | { | ||
1382 | printf("%s <config>\n", progname); | ||
1383 | exit(0); | ||
1384 | } | ||
1385 | |||
1386 | int main(int ac, char** av) | ||
1387 | { | ||
1388 | ConfigMainWindow* v; | ||
1389 | const char *name; | ||
1390 | |||
1391 | bindtextdomain(PACKAGE, LOCALEDIR); | ||
1392 | textdomain(PACKAGE); | ||
1393 | |||
1394 | #ifndef LKC_DIRECT_LINK | ||
1395 | kconfig_load(); | ||
1396 | #endif | ||
1397 | |||
1398 | progname = av[0]; | ||
1399 | configApp = new QApplication(ac, av); | ||
1400 | if (ac > 1 && av[1][0] == '-') { | ||
1401 | switch (av[1][1]) { | ||
1402 | case 'h': | ||
1403 | case '?': | ||
1404 | usage(); | ||
1405 | } | ||
1406 | name = av[2]; | ||
1407 | } else | ||
1408 | name = av[1]; | ||
1409 | if (!name) | ||
1410 | usage(); | ||
1411 | |||
1412 | conf_parse(name); | ||
1413 | fixup_rootmenu(&rootmenu); | ||
1414 | conf_read(NULL); | ||
1415 | //zconfdump(stdout); | ||
1416 | |||
1417 | v = new ConfigMainWindow(); | ||
1418 | |||
1419 | //zconfdump(stdout); | ||
1420 | v->show(); | ||
1421 | configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); | ||
1422 | configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings())); | ||
1423 | configApp->exec(); | ||
1424 | |||
1425 | return 0; | ||
1426 | } | ||
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h new file mode 100644 index 000000000..e52f3e90b --- /dev/null +++ b/scripts/kconfig/qconf.h | |||
@@ -0,0 +1,263 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | ||
3 | * Released under the terms of the GNU GPL v2.0. | ||
4 | */ | ||
5 | |||
6 | #include <qlistview.h> | ||
7 | #if QT_VERSION >= 300 | ||
8 | #include <qsettings.h> | ||
9 | #else | ||
10 | class QSettings { }; | ||
11 | #endif | ||
12 | |||
13 | class ConfigList; | ||
14 | class ConfigItem; | ||
15 | class ConfigLineEdit; | ||
16 | class ConfigMainWindow; | ||
17 | |||
18 | |||
19 | class ConfigSettings : public QSettings { | ||
20 | public: | ||
21 | ConfigSettings(); | ||
22 | |||
23 | #if QT_VERSION >= 300 | ||
24 | void readListSettings(); | ||
25 | QValueList<int> readSizes(const QString& key, bool *ok); | ||
26 | bool writeSizes(const QString& key, const QValueList<int>& value); | ||
27 | #endif | ||
28 | |||
29 | bool showAll; | ||
30 | bool showName; | ||
31 | bool showRange; | ||
32 | bool showData; | ||
33 | }; | ||
34 | |||
35 | class ConfigView : public QVBox { | ||
36 | Q_OBJECT | ||
37 | typedef class QVBox Parent; | ||
38 | public: | ||
39 | ConfigView(QWidget* parent, ConfigMainWindow* cview, ConfigSettings* configSettings); | ||
40 | ~ConfigView(void); | ||
41 | static void updateList(ConfigItem* item); | ||
42 | static void updateListAll(void); | ||
43 | |||
44 | public: | ||
45 | ConfigList* list; | ||
46 | ConfigLineEdit* lineEdit; | ||
47 | |||
48 | static ConfigView* viewList; | ||
49 | ConfigView* nextView; | ||
50 | }; | ||
51 | |||
52 | enum colIdx { | ||
53 | promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr | ||
54 | }; | ||
55 | enum listMode { | ||
56 | singleMode, menuMode, symbolMode, fullMode | ||
57 | }; | ||
58 | |||
59 | class ConfigList : public QListView { | ||
60 | Q_OBJECT | ||
61 | typedef class QListView Parent; | ||
62 | public: | ||
63 | ConfigList(ConfigView* p, ConfigMainWindow* cview, ConfigSettings *configSettings); | ||
64 | void reinit(void); | ||
65 | ConfigView* parent(void) const | ||
66 | { | ||
67 | return (ConfigView*)Parent::parent(); | ||
68 | } | ||
69 | |||
70 | protected: | ||
71 | ConfigMainWindow* cview; | ||
72 | |||
73 | void keyPressEvent(QKeyEvent *e); | ||
74 | void contentsMousePressEvent(QMouseEvent *e); | ||
75 | void contentsMouseReleaseEvent(QMouseEvent *e); | ||
76 | void contentsMouseMoveEvent(QMouseEvent *e); | ||
77 | void contentsMouseDoubleClickEvent(QMouseEvent *e); | ||
78 | void focusInEvent(QFocusEvent *e); | ||
79 | public slots: | ||
80 | void setRootMenu(struct menu *menu); | ||
81 | |||
82 | void updateList(ConfigItem *item); | ||
83 | void setValue(ConfigItem* item, tristate val); | ||
84 | void changeValue(ConfigItem* item); | ||
85 | void updateSelection(void); | ||
86 | signals: | ||
87 | void menuSelected(struct menu *menu); | ||
88 | void parentSelected(void); | ||
89 | void gotFocus(void); | ||
90 | |||
91 | public: | ||
92 | void updateListAll(void) | ||
93 | { | ||
94 | updateAll = true; | ||
95 | updateList(NULL); | ||
96 | updateAll = false; | ||
97 | } | ||
98 | ConfigList* listView() | ||
99 | { | ||
100 | return this; | ||
101 | } | ||
102 | ConfigItem* firstChild() const | ||
103 | { | ||
104 | return (ConfigItem *)Parent::firstChild(); | ||
105 | } | ||
106 | int mapIdx(colIdx idx) | ||
107 | { | ||
108 | return colMap[idx]; | ||
109 | } | ||
110 | void addColumn(colIdx idx, const QString& label) | ||
111 | { | ||
112 | colMap[idx] = Parent::addColumn(label); | ||
113 | colRevMap[colMap[idx]] = idx; | ||
114 | } | ||
115 | void removeColumn(colIdx idx) | ||
116 | { | ||
117 | int col = colMap[idx]; | ||
118 | if (col >= 0) { | ||
119 | Parent::removeColumn(col); | ||
120 | colRevMap[col] = colMap[idx] = -1; | ||
121 | } | ||
122 | } | ||
123 | void setAllOpen(bool open); | ||
124 | void setParentMenu(void); | ||
125 | |||
126 | template <class P> | ||
127 | void updateMenuList(P*, struct menu*); | ||
128 | |||
129 | bool updateAll; | ||
130 | |||
131 | QPixmap symbolYesPix, symbolModPix, symbolNoPix; | ||
132 | QPixmap choiceYesPix, choiceNoPix; | ||
133 | QPixmap menuPix, menuInvPix, menuBackPix, voidPix; | ||
134 | |||
135 | bool showAll, showName, showRange, showData; | ||
136 | enum listMode mode; | ||
137 | struct menu *rootEntry; | ||
138 | QColorGroup disabledColorGroup; | ||
139 | QColorGroup inactivedColorGroup; | ||
140 | |||
141 | private: | ||
142 | int colMap[colNr]; | ||
143 | int colRevMap[colNr]; | ||
144 | }; | ||
145 | |||
146 | class ConfigItem : public QListViewItem { | ||
147 | typedef class QListViewItem Parent; | ||
148 | public: | ||
149 | ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v) | ||
150 | : Parent(parent, after), menu(m), visible(v), goParent(false) | ||
151 | { | ||
152 | init(); | ||
153 | } | ||
154 | ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v) | ||
155 | : Parent(parent, after), menu(m), visible(v), goParent(false) | ||
156 | { | ||
157 | init(); | ||
158 | } | ||
159 | ConfigItem(QListView *parent, ConfigItem *after, bool v) | ||
160 | : Parent(parent, after), menu(0), visible(v), goParent(true) | ||
161 | { | ||
162 | init(); | ||
163 | } | ||
164 | ~ConfigItem(void); | ||
165 | void init(void); | ||
166 | #if QT_VERSION >= 300 | ||
167 | void okRename(int col); | ||
168 | #endif | ||
169 | void updateMenu(void); | ||
170 | void testUpdateMenu(bool v); | ||
171 | ConfigList* listView() const | ||
172 | { | ||
173 | return (ConfigList*)Parent::listView(); | ||
174 | } | ||
175 | ConfigItem* firstChild() const | ||
176 | { | ||
177 | return (ConfigItem *)Parent::firstChild(); | ||
178 | } | ||
179 | ConfigItem* nextSibling() const | ||
180 | { | ||
181 | return (ConfigItem *)Parent::nextSibling(); | ||
182 | } | ||
183 | void setText(colIdx idx, const QString& text) | ||
184 | { | ||
185 | Parent::setText(listView()->mapIdx(idx), text); | ||
186 | } | ||
187 | QString text(colIdx idx) const | ||
188 | { | ||
189 | return Parent::text(listView()->mapIdx(idx)); | ||
190 | } | ||
191 | void setPixmap(colIdx idx, const QPixmap& pm) | ||
192 | { | ||
193 | Parent::setPixmap(listView()->mapIdx(idx), pm); | ||
194 | } | ||
195 | const QPixmap* pixmap(colIdx idx) const | ||
196 | { | ||
197 | return Parent::pixmap(listView()->mapIdx(idx)); | ||
198 | } | ||
199 | void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align); | ||
200 | |||
201 | ConfigItem* nextItem; | ||
202 | struct menu *menu; | ||
203 | bool visible; | ||
204 | bool goParent; | ||
205 | }; | ||
206 | |||
207 | class ConfigLineEdit : public QLineEdit { | ||
208 | Q_OBJECT | ||
209 | typedef class QLineEdit Parent; | ||
210 | public: | ||
211 | ConfigLineEdit(ConfigView* parent) | ||
212 | : Parent(parent) | ||
213 | { } | ||
214 | ConfigView* parent(void) const | ||
215 | { | ||
216 | return (ConfigView*)Parent::parent(); | ||
217 | } | ||
218 | void show(ConfigItem *i); | ||
219 | void keyPressEvent(QKeyEvent *e); | ||
220 | |||
221 | public: | ||
222 | ConfigItem *item; | ||
223 | }; | ||
224 | |||
225 | class ConfigMainWindow : public QMainWindow { | ||
226 | Q_OBJECT | ||
227 | public: | ||
228 | ConfigMainWindow(void); | ||
229 | public slots: | ||
230 | void setHelp(QListViewItem* item); | ||
231 | void changeMenu(struct menu *); | ||
232 | void listFocusChanged(void); | ||
233 | void goBack(void); | ||
234 | void loadConfig(void); | ||
235 | void saveConfig(void); | ||
236 | void saveConfigAs(void); | ||
237 | void showSingleView(void); | ||
238 | void showSplitView(void); | ||
239 | void showFullView(void); | ||
240 | void setShowAll(bool); | ||
241 | void setShowDebug(bool); | ||
242 | void setShowRange(bool); | ||
243 | void setShowName(bool); | ||
244 | void setShowData(bool); | ||
245 | void showIntro(void); | ||
246 | void showAbout(void); | ||
247 | void saveSettings(void); | ||
248 | |||
249 | protected: | ||
250 | void closeEvent(QCloseEvent *e); | ||
251 | |||
252 | ConfigView *menuView; | ||
253 | ConfigList *menuList; | ||
254 | ConfigView *configView; | ||
255 | ConfigList *configList; | ||
256 | QTextView *helpText; | ||
257 | QToolBar *toolBar; | ||
258 | QAction *backAction; | ||
259 | QSplitter* split1; | ||
260 | QSplitter* split2; | ||
261 | |||
262 | bool showDebug; | ||
263 | }; | ||
diff --git a/scripts/config/symbol.c b/scripts/kconfig/symbol.c index aeea4cc9f..3d7877afc 100644 --- a/scripts/config/symbol.c +++ b/scripts/kconfig/symbol.c | |||
@@ -1,4 +1,3 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | 1 | /* |
3 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
4 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
@@ -45,6 +44,7 @@ void sym_add_default(struct symbol *sym, const char *def) | |||
45 | void sym_init(void) | 44 | void sym_init(void) |
46 | { | 45 | { |
47 | struct symbol *sym; | 46 | struct symbol *sym; |
47 | struct utsname uts; | ||
48 | char *p; | 48 | char *p; |
49 | static bool inited = false; | 49 | static bool inited = false; |
50 | 50 | ||
@@ -52,20 +52,26 @@ void sym_init(void) | |||
52 | return; | 52 | return; |
53 | inited = true; | 53 | inited = true; |
54 | 54 | ||
55 | sym = sym_lookup("VERSION", 0); | 55 | uname(&uts); |
56 | |||
57 | sym = sym_lookup("ARCH", 0); | ||
56 | sym->type = S_STRING; | 58 | sym->type = S_STRING; |
57 | sym->flags |= SYMBOL_AUTO; | 59 | sym->flags |= SYMBOL_AUTO; |
58 | p = getenv("VERSION"); | 60 | p = getenv("ARCH"); |
59 | if (p) | 61 | if (p) |
60 | sym_add_default(sym, p); | 62 | sym_add_default(sym, p); |
61 | 63 | ||
62 | sym = sym_lookup("TARGET_ARCH", 0); | 64 | sym = sym_lookup("KERNELVERSION", 0); |
63 | sym->type = S_STRING; | 65 | sym->type = S_STRING; |
64 | sym->flags |= SYMBOL_AUTO; | 66 | sym->flags |= SYMBOL_AUTO; |
65 | p = getenv("TARGET_ARCH"); | 67 | p = getenv("KERNELVERSION"); |
66 | if (p) | 68 | if (p) |
67 | sym_add_default(sym, p); | 69 | sym_add_default(sym, p); |
68 | 70 | ||
71 | sym = sym_lookup("UNAME_RELEASE", 0); | ||
72 | sym->type = S_STRING; | ||
73 | sym->flags |= SYMBOL_AUTO; | ||
74 | sym_add_default(sym, uts.release); | ||
69 | } | 75 | } |
70 | 76 | ||
71 | enum symbol_type sym_get_type(struct symbol *sym) | 77 | enum symbol_type sym_get_type(struct symbol *sym) |
@@ -135,6 +141,55 @@ struct property *sym_get_range_prop(struct symbol *sym) | |||
135 | return NULL; | 141 | return NULL; |
136 | } | 142 | } |
137 | 143 | ||
144 | static int sym_get_range_val(struct symbol *sym, int base) | ||
145 | { | ||
146 | sym_calc_value(sym); | ||
147 | switch (sym->type) { | ||
148 | case S_INT: | ||
149 | base = 10; | ||
150 | break; | ||
151 | case S_HEX: | ||
152 | base = 16; | ||
153 | break; | ||
154 | default: | ||
155 | break; | ||
156 | } | ||
157 | return strtol(sym->curr.val, NULL, base); | ||
158 | } | ||
159 | |||
160 | static void sym_validate_range(struct symbol *sym) | ||
161 | { | ||
162 | struct property *prop; | ||
163 | int base, val, val2; | ||
164 | char str[64]; | ||
165 | |||
166 | switch (sym->type) { | ||
167 | case S_INT: | ||
168 | base = 10; | ||
169 | break; | ||
170 | case S_HEX: | ||
171 | base = 16; | ||
172 | break; | ||
173 | default: | ||
174 | return; | ||
175 | } | ||
176 | prop = sym_get_range_prop(sym); | ||
177 | if (!prop) | ||
178 | return; | ||
179 | val = strtol(sym->curr.val, NULL, base); | ||
180 | val2 = sym_get_range_val(prop->expr->left.sym, base); | ||
181 | if (val >= val2) { | ||
182 | val2 = sym_get_range_val(prop->expr->right.sym, base); | ||
183 | if (val <= val2) | ||
184 | return; | ||
185 | } | ||
186 | if (sym->type == S_INT) | ||
187 | sprintf(str, "%d", val2); | ||
188 | else | ||
189 | sprintf(str, "0x%x", val2); | ||
190 | sym->curr.val = strdup(str); | ||
191 | } | ||
192 | |||
138 | static void sym_calc_visibility(struct symbol *sym) | 193 | static void sym_calc_visibility(struct symbol *sym) |
139 | { | 194 | { |
140 | struct property *prop; | 195 | struct property *prop; |
@@ -295,6 +350,7 @@ void sym_calc_value(struct symbol *sym) | |||
295 | sym->curr = newval; | 350 | sym->curr = newval; |
296 | if (sym_is_choice(sym) && newval.tri == yes) | 351 | if (sym_is_choice(sym) && newval.tri == yes) |
297 | sym->curr.val = sym_calc_choice(sym); | 352 | sym->curr.val = sym_calc_choice(sym); |
353 | sym_validate_range(sym); | ||
298 | 354 | ||
299 | if (memcmp(&oldval, &sym->curr, sizeof(oldval))) | 355 | if (memcmp(&oldval, &sym->curr, sizeof(oldval))) |
300 | sym_set_changed(sym); | 356 | sym_set_changed(sym); |
@@ -374,11 +430,22 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val) | |||
374 | sym->flags &= ~SYMBOL_NEW; | 430 | sym->flags &= ~SYMBOL_NEW; |
375 | sym_set_changed(sym); | 431 | sym_set_changed(sym); |
376 | } | 432 | } |
433 | /* | ||
434 | * setting a choice value also resets the new flag of the choice | ||
435 | * symbol and all other choice values. | ||
436 | */ | ||
377 | if (sym_is_choice_value(sym) && val == yes) { | 437 | if (sym_is_choice_value(sym) && val == yes) { |
378 | struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); | 438 | struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); |
439 | struct property *prop; | ||
440 | struct expr *e; | ||
379 | 441 | ||
380 | cs->user.val = sym; | 442 | cs->user.val = sym; |
381 | cs->flags &= ~SYMBOL_NEW; | 443 | cs->flags &= ~SYMBOL_NEW; |
444 | prop = sym_get_choice_prop(cs); | ||
445 | for (e = prop->expr; e; e = e->left.expr) { | ||
446 | if (e->right.sym->visible != no) | ||
447 | e->right.sym->flags &= ~SYMBOL_NEW; | ||
448 | } | ||
382 | } | 449 | } |
383 | 450 | ||
384 | sym->user.tri = val; | 451 | sym->user.tri = val; |
@@ -472,8 +539,8 @@ bool sym_string_within_range(struct symbol *sym, const char *str) | |||
472 | if (!prop) | 539 | if (!prop) |
473 | return true; | 540 | return true; |
474 | val = strtol(str, NULL, 10); | 541 | val = strtol(str, NULL, 10); |
475 | return val >= strtol(prop->expr->left.sym->name, NULL, 10) && | 542 | return val >= sym_get_range_val(prop->expr->left.sym, 10) && |
476 | val <= strtol(prop->expr->right.sym->name, NULL, 10); | 543 | val <= sym_get_range_val(prop->expr->right.sym, 10); |
477 | case S_HEX: | 544 | case S_HEX: |
478 | if (!sym_string_valid(sym, str)) | 545 | if (!sym_string_valid(sym, str)) |
479 | return false; | 546 | return false; |
@@ -481,8 +548,8 @@ bool sym_string_within_range(struct symbol *sym, const char *str) | |||
481 | if (!prop) | 548 | if (!prop) |
482 | return true; | 549 | return true; |
483 | val = strtol(str, NULL, 16); | 550 | val = strtol(str, NULL, 16); |
484 | return val >= strtol(prop->expr->left.sym->name, NULL, 16) && | 551 | return val >= sym_get_range_val(prop->expr->left.sym, 16) && |
485 | val <= strtol(prop->expr->right.sym->name, NULL, 16); | 552 | val <= sym_get_range_val(prop->expr->right.sym, 16); |
486 | case S_BOOLEAN: | 553 | case S_BOOLEAN: |
487 | case S_TRISTATE: | 554 | case S_TRISTATE: |
488 | switch (str[0]) { | 555 | switch (str[0]) { |
@@ -725,12 +792,12 @@ struct symbol *sym_check_deps(struct symbol *sym) | |||
725 | struct symbol *sym2; | 792 | struct symbol *sym2; |
726 | struct property *prop; | 793 | struct property *prop; |
727 | 794 | ||
728 | if (sym->flags & SYMBOL_CHECK_DONE) | ||
729 | return NULL; | ||
730 | if (sym->flags & SYMBOL_CHECK) { | 795 | if (sym->flags & SYMBOL_CHECK) { |
731 | printf("Warning! Found recursive dependency: %s", sym->name); | 796 | printf("Warning! Found recursive dependency: %s", sym->name); |
732 | return sym; | 797 | return sym; |
733 | } | 798 | } |
799 | if (sym->flags & SYMBOL_CHECKED) | ||
800 | return NULL; | ||
734 | 801 | ||
735 | sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); | 802 | sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); |
736 | sym2 = sym_check_expr_deps(sym->rev_dep.expr); | 803 | sym2 = sym_check_expr_deps(sym->rev_dep.expr); |
@@ -750,8 +817,13 @@ struct symbol *sym_check_deps(struct symbol *sym) | |||
750 | goto out; | 817 | goto out; |
751 | } | 818 | } |
752 | out: | 819 | out: |
753 | if (sym2) | 820 | if (sym2) { |
754 | printf(" %s", sym->name); | 821 | printf(" %s", sym->name); |
822 | if (sym2 == sym) { | ||
823 | printf("\n"); | ||
824 | sym2 = NULL; | ||
825 | } | ||
826 | } | ||
755 | sym->flags &= ~SYMBOL_CHECK; | 827 | sym->flags &= ~SYMBOL_CHECK; |
756 | return sym2; | 828 | return sym2; |
757 | } | 829 | } |
diff --git a/scripts/config/util.c b/scripts/kconfig/util.c index dbf23edef..aea8d56ce 100644 --- a/scripts/config/util.c +++ b/scripts/kconfig/util.c | |||
@@ -1,4 +1,3 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | 1 | /* |
3 | * Copyright (C) 2002-2005 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002-2005 Roman Zippel <zippel@linux-m68k.org> |
4 | * Copyright (C) 2002-2005 Sam Ravnborg <sam@ravnborg.org> | 3 | * Copyright (C) 2002-2005 Sam Ravnborg <sam@ravnborg.org> |
@@ -34,8 +33,8 @@ int file_write_dep(const char *name) | |||
34 | FILE *out; | 33 | FILE *out; |
35 | 34 | ||
36 | if (!name) | 35 | if (!name) |
37 | name = ".config.cmd"; | 36 | name = ".kconfig.d"; |
38 | out = fopen(".config.tmp", "w"); | 37 | out = fopen("..config.tmp", "w"); |
39 | if (!out) | 38 | if (!out) |
40 | return 1; | 39 | return 1; |
41 | fprintf(out, "deps_config := \\\n"); | 40 | fprintf(out, "deps_config := \\\n"); |
@@ -45,9 +44,9 @@ int file_write_dep(const char *name) | |||
45 | else | 44 | else |
46 | fprintf(out, "\t%s\n", file->name); | 45 | fprintf(out, "\t%s\n", file->name); |
47 | } | 46 | } |
48 | fprintf(out, "\n.config include/config.h: $(deps_config)\n\n$(deps_config):\n"); | 47 | fprintf(out, "\n.config include/autoconf.h: $(deps_config)\n\n$(deps_config):\n"); |
49 | fclose(out); | 48 | fclose(out); |
50 | rename(".config.tmp", name); | 49 | rename("..config.tmp", name); |
51 | return 0; | 50 | return 0; |
52 | } | 51 | } |
53 | 52 | ||
@@ -102,7 +101,7 @@ void str_printf(struct gstr *gs, const char *fmt, ...) | |||
102 | va_end(ap); | 101 | va_end(ap); |
103 | } | 102 | } |
104 | 103 | ||
105 | /* Retreive value of growable string */ | 104 | /* Retrieve value of growable string */ |
106 | const char *str_get(struct gstr *gs) | 105 | const char *str_get(struct gstr *gs) |
107 | { | 106 | { |
108 | return gs->s; | 107 | return gs->s; |
diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf new file mode 100644 index 000000000..b03220600 --- /dev/null +++ b/scripts/kconfig/zconf.gperf | |||
@@ -0,0 +1,43 @@ | |||
1 | %language=ANSI-C | ||
2 | %define hash-function-name kconf_id_hash | ||
3 | %define lookup-function-name kconf_id_lookup | ||
4 | %define string-pool-name kconf_id_strings | ||
5 | %compare-strncmp | ||
6 | %enum | ||
7 | %pic | ||
8 | %struct-type | ||
9 | |||
10 | struct kconf_id; | ||
11 | |||
12 | %% | ||
13 | mainmenu, T_MAINMENU, TF_COMMAND | ||
14 | menu, T_MENU, TF_COMMAND | ||
15 | endmenu, T_ENDMENU, TF_COMMAND | ||
16 | source, T_SOURCE, TF_COMMAND | ||
17 | choice, T_CHOICE, TF_COMMAND | ||
18 | endchoice, T_ENDCHOICE, TF_COMMAND | ||
19 | comment, T_COMMENT, TF_COMMAND | ||
20 | config, T_CONFIG, TF_COMMAND | ||
21 | menuconfig, T_MENUCONFIG, TF_COMMAND | ||
22 | help, T_HELP, TF_COMMAND | ||
23 | if, T_IF, TF_COMMAND|TF_PARAM | ||
24 | endif, T_ENDIF, TF_COMMAND | ||
25 | depends, T_DEPENDS, TF_COMMAND | ||
26 | requires, T_REQUIRES, TF_COMMAND | ||
27 | optional, T_OPTIONAL, TF_COMMAND | ||
28 | default, T_DEFAULT, TF_COMMAND, S_UNKNOWN | ||
29 | prompt, T_PROMPT, TF_COMMAND | ||
30 | tristate, T_TYPE, TF_COMMAND, S_TRISTATE | ||
31 | def_tristate, T_DEFAULT, TF_COMMAND, S_TRISTATE | ||
32 | bool, T_TYPE, TF_COMMAND, S_BOOLEAN | ||
33 | boolean, T_TYPE, TF_COMMAND, S_BOOLEAN | ||
34 | def_bool, T_DEFAULT, TF_COMMAND, S_BOOLEAN | ||
35 | def_boolean, T_DEFAULT, TF_COMMAND, S_BOOLEAN | ||
36 | int, T_TYPE, TF_COMMAND, S_INT | ||
37 | hex, T_TYPE, TF_COMMAND, S_HEX | ||
38 | string, T_TYPE, TF_COMMAND, S_STRING | ||
39 | select, T_SELECT, TF_COMMAND | ||
40 | enable, T_SELECT, TF_COMMAND | ||
41 | range, T_RANGE, TF_COMMAND | ||
42 | on, T_ON, TF_PARAM | ||
43 | %% | ||
diff --git a/scripts/kconfig/zconf.hash.c_shipped b/scripts/kconfig/zconf.hash.c_shipped new file mode 100644 index 000000000..345f0fc07 --- /dev/null +++ b/scripts/kconfig/zconf.hash.c_shipped | |||
@@ -0,0 +1,231 @@ | |||
1 | /* ANSI-C code produced by gperf version 3.0.1 */ | ||
2 | /* Command-line: gperf */ | ||
3 | /* Computed positions: -k'1,3' */ | ||
4 | |||
5 | #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ | ||
6 | && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ | ||
7 | && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ | ||
8 | && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ | ||
9 | && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ | ||
10 | && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ | ||
11 | && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ | ||
12 | && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ | ||
13 | && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ | ||
14 | && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ | ||
15 | && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ | ||
16 | && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ | ||
17 | && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ | ||
18 | && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ | ||
19 | && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ | ||
20 | && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ | ||
21 | && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ | ||
22 | && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ | ||
23 | && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ | ||
24 | && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ | ||
25 | && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ | ||
26 | && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ | ||
27 | && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) | ||
28 | /* The character set is not based on ISO-646. */ | ||
29 | #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>." | ||
30 | #endif | ||
31 | |||
32 | struct kconf_id; | ||
33 | /* maximum key range = 45, duplicates = 0 */ | ||
34 | |||
35 | #ifdef __GNUC__ | ||
36 | __inline | ||
37 | #else | ||
38 | #ifdef __cplusplus | ||
39 | inline | ||
40 | #endif | ||
41 | #endif | ||
42 | static unsigned int | ||
43 | kconf_id_hash (register const char *str, register unsigned int len) | ||
44 | { | ||
45 | static unsigned char asso_values[] = | ||
46 | { | ||
47 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
48 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
49 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
50 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
51 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
52 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
53 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
54 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
55 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
56 | 47, 47, 47, 47, 47, 47, 47, 25, 10, 15, | ||
57 | 0, 0, 5, 47, 0, 0, 47, 47, 0, 10, | ||
58 | 0, 20, 20, 20, 5, 0, 0, 20, 47, 47, | ||
59 | 20, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
60 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
61 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
62 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
63 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
64 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
65 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
66 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
67 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
68 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
69 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
70 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
71 | 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | ||
72 | 47, 47, 47, 47, 47, 47 | ||
73 | }; | ||
74 | register int hval = len; | ||
75 | |||
76 | switch (hval) | ||
77 | { | ||
78 | default: | ||
79 | hval += asso_values[(unsigned char)str[2]]; | ||
80 | /*FALLTHROUGH*/ | ||
81 | case 2: | ||
82 | case 1: | ||
83 | hval += asso_values[(unsigned char)str[0]]; | ||
84 | break; | ||
85 | } | ||
86 | return hval; | ||
87 | } | ||
88 | |||
89 | struct kconf_id_strings_t | ||
90 | { | ||
91 | char kconf_id_strings_str2[sizeof("if")]; | ||
92 | char kconf_id_strings_str3[sizeof("int")]; | ||
93 | char kconf_id_strings_str4[sizeof("help")]; | ||
94 | char kconf_id_strings_str5[sizeof("endif")]; | ||
95 | char kconf_id_strings_str6[sizeof("select")]; | ||
96 | char kconf_id_strings_str7[sizeof("endmenu")]; | ||
97 | char kconf_id_strings_str8[sizeof("tristate")]; | ||
98 | char kconf_id_strings_str9[sizeof("endchoice")]; | ||
99 | char kconf_id_strings_str10[sizeof("range")]; | ||
100 | char kconf_id_strings_str11[sizeof("string")]; | ||
101 | char kconf_id_strings_str12[sizeof("default")]; | ||
102 | char kconf_id_strings_str13[sizeof("def_bool")]; | ||
103 | char kconf_id_strings_str14[sizeof("menu")]; | ||
104 | char kconf_id_strings_str16[sizeof("def_boolean")]; | ||
105 | char kconf_id_strings_str17[sizeof("def_tristate")]; | ||
106 | char kconf_id_strings_str18[sizeof("mainmenu")]; | ||
107 | char kconf_id_strings_str20[sizeof("menuconfig")]; | ||
108 | char kconf_id_strings_str21[sizeof("config")]; | ||
109 | char kconf_id_strings_str22[sizeof("on")]; | ||
110 | char kconf_id_strings_str23[sizeof("hex")]; | ||
111 | char kconf_id_strings_str26[sizeof("source")]; | ||
112 | char kconf_id_strings_str27[sizeof("depends")]; | ||
113 | char kconf_id_strings_str28[sizeof("optional")]; | ||
114 | char kconf_id_strings_str31[sizeof("enable")]; | ||
115 | char kconf_id_strings_str32[sizeof("comment")]; | ||
116 | char kconf_id_strings_str33[sizeof("requires")]; | ||
117 | char kconf_id_strings_str34[sizeof("bool")]; | ||
118 | char kconf_id_strings_str37[sizeof("boolean")]; | ||
119 | char kconf_id_strings_str41[sizeof("choice")]; | ||
120 | char kconf_id_strings_str46[sizeof("prompt")]; | ||
121 | }; | ||
122 | static struct kconf_id_strings_t kconf_id_strings_contents = | ||
123 | { | ||
124 | "if", | ||
125 | "int", | ||
126 | "help", | ||
127 | "endif", | ||
128 | "select", | ||
129 | "endmenu", | ||
130 | "tristate", | ||
131 | "endchoice", | ||
132 | "range", | ||
133 | "string", | ||
134 | "default", | ||
135 | "def_bool", | ||
136 | "menu", | ||
137 | "def_boolean", | ||
138 | "def_tristate", | ||
139 | "mainmenu", | ||
140 | "menuconfig", | ||
141 | "config", | ||
142 | "on", | ||
143 | "hex", | ||
144 | "source", | ||
145 | "depends", | ||
146 | "optional", | ||
147 | "enable", | ||
148 | "comment", | ||
149 | "requires", | ||
150 | "bool", | ||
151 | "boolean", | ||
152 | "choice", | ||
153 | "prompt" | ||
154 | }; | ||
155 | #define kconf_id_strings ((const char *) &kconf_id_strings_contents) | ||
156 | #ifdef __GNUC__ | ||
157 | __inline | ||
158 | #endif | ||
159 | struct kconf_id * | ||
160 | kconf_id_lookup (register const char *str, register unsigned int len) | ||
161 | { | ||
162 | enum | ||
163 | { | ||
164 | TOTAL_KEYWORDS = 30, | ||
165 | MIN_WORD_LENGTH = 2, | ||
166 | MAX_WORD_LENGTH = 12, | ||
167 | MIN_HASH_VALUE = 2, | ||
168 | MAX_HASH_VALUE = 46 | ||
169 | }; | ||
170 | |||
171 | static struct kconf_id wordlist[] = | ||
172 | { | ||
173 | {-1}, {-1}, | ||
174 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_IF, TF_COMMAND|TF_PARAM}, | ||
175 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_TYPE, TF_COMMAND, S_INT}, | ||
176 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str4, T_HELP, TF_COMMAND}, | ||
177 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5, T_ENDIF, TF_COMMAND}, | ||
178 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str6, T_SELECT, TF_COMMAND}, | ||
179 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_ENDMENU, TF_COMMAND}, | ||
180 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_TYPE, TF_COMMAND, S_TRISTATE}, | ||
181 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9, T_ENDCHOICE, TF_COMMAND}, | ||
182 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10, T_RANGE, TF_COMMAND}, | ||
183 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str11, T_TYPE, TF_COMMAND, S_STRING}, | ||
184 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN}, | ||
185 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN}, | ||
186 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_MENU, TF_COMMAND}, | ||
187 | {-1}, | ||
188 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_DEFAULT, TF_COMMAND, S_BOOLEAN}, | ||
189 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE}, | ||
190 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_MAINMENU, TF_COMMAND}, | ||
191 | {-1}, | ||
192 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str20, T_MENUCONFIG, TF_COMMAND}, | ||
193 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_CONFIG, TF_COMMAND}, | ||
194 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_ON, TF_PARAM}, | ||
195 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_HEX}, | ||
196 | {-1}, {-1}, | ||
197 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26, T_SOURCE, TF_COMMAND}, | ||
198 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_DEPENDS, TF_COMMAND}, | ||
199 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_OPTIONAL, TF_COMMAND}, | ||
200 | {-1}, {-1}, | ||
201 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SELECT, TF_COMMAND}, | ||
202 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND}, | ||
203 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_REQUIRES, TF_COMMAND}, | ||
204 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str34, T_TYPE, TF_COMMAND, S_BOOLEAN}, | ||
205 | {-1}, {-1}, | ||
206 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_TYPE, TF_COMMAND, S_BOOLEAN}, | ||
207 | {-1}, {-1}, {-1}, | ||
208 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_CHOICE, TF_COMMAND}, | ||
209 | {-1}, {-1}, {-1}, {-1}, | ||
210 | {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_PROMPT, TF_COMMAND} | ||
211 | }; | ||
212 | |||
213 | if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) | ||
214 | { | ||
215 | register int key = kconf_id_hash (str, len); | ||
216 | |||
217 | if (key <= MAX_HASH_VALUE && key >= 0) | ||
218 | { | ||
219 | register int o = wordlist[key].name; | ||
220 | if (o >= 0) | ||
221 | { | ||
222 | register const char *s = o + kconf_id_strings; | ||
223 | |||
224 | if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') | ||
225 | return &wordlist[key]; | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | return 0; | ||
230 | } | ||
231 | |||
diff --git a/scripts/config/zconf.l b/scripts/kconfig/zconf.l index 55517b287..cfa46077c 100644 --- a/scripts/config/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -18,8 +18,12 @@ | |||
18 | 18 | ||
19 | #define START_STRSIZE 16 | 19 | #define START_STRSIZE 16 |
20 | 20 | ||
21 | char *text; | 21 | static struct { |
22 | static char *text_ptr; | 22 | struct file *file; |
23 | int lineno; | ||
24 | } current_pos; | ||
25 | |||
26 | static char *text; | ||
23 | static int text_size, text_asize; | 27 | static int text_size, text_asize; |
24 | 28 | ||
25 | struct buffer { | 29 | struct buffer { |
@@ -32,29 +36,28 @@ struct buffer *current_buf; | |||
32 | static int last_ts, first_ts; | 36 | static int last_ts, first_ts; |
33 | 37 | ||
34 | static void zconf_endhelp(void); | 38 | static void zconf_endhelp(void); |
35 | static struct buffer *zconf_endfile(void); | 39 | static void zconf_endfile(void); |
36 | 40 | ||
37 | void new_string(void) | 41 | void new_string(void) |
38 | { | 42 | { |
39 | text = malloc(START_STRSIZE); | 43 | text = malloc(START_STRSIZE); |
40 | text_asize = START_STRSIZE; | 44 | text_asize = START_STRSIZE; |
41 | text_ptr = text; | ||
42 | text_size = 0; | 45 | text_size = 0; |
43 | *text_ptr = 0; | 46 | *text = 0; |
44 | } | 47 | } |
45 | 48 | ||
46 | void append_string(const char *str, int size) | 49 | void append_string(const char *str, int size) |
47 | { | 50 | { |
48 | int new_size = text_size + size + 1; | 51 | int new_size = text_size + size + 1; |
49 | if (new_size > text_asize) { | 52 | if (new_size > text_asize) { |
53 | new_size += START_STRSIZE - 1; | ||
54 | new_size &= -START_STRSIZE; | ||
50 | text = realloc(text, new_size); | 55 | text = realloc(text, new_size); |
51 | text_asize = new_size; | 56 | text_asize = new_size; |
52 | text_ptr = text + text_size; | ||
53 | } | 57 | } |
54 | memcpy(text_ptr, str, size); | 58 | memcpy(text + text_size, str, size); |
55 | text_ptr += size; | ||
56 | text_size += size; | 59 | text_size += size; |
57 | *text_ptr = 0; | 60 | text[text_size] = 0; |
58 | } | 61 | } |
59 | 62 | ||
60 | void alloc_string(const char *str, int size) | 63 | void alloc_string(const char *str, int size) |
@@ -72,10 +75,13 @@ n [A-Za-z0-9_] | |||
72 | int str = 0; | 75 | int str = 0; |
73 | int ts, i; | 76 | int ts, i; |
74 | 77 | ||
75 | [ \t]*#.*\n current_file->lineno++; | 78 | [ \t]*#.*\n | |
79 | [ \t]*\n { | ||
80 | current_file->lineno++; | ||
81 | return T_EOL; | ||
82 | } | ||
76 | [ \t]*#.* | 83 | [ \t]*#.* |
77 | 84 | ||
78 | [ \t]*\n current_file->lineno++; return T_EOL; | ||
79 | 85 | ||
80 | [ \t]+ { | 86 | [ \t]+ { |
81 | BEGIN(COMMAND); | 87 | BEGIN(COMMAND); |
@@ -88,42 +94,25 @@ n [A-Za-z0-9_] | |||
88 | 94 | ||
89 | 95 | ||
90 | <COMMAND>{ | 96 | <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}+ { | 97 | {n}+ { |
98 | struct kconf_id *id = kconf_id_lookup(yytext, yyleng); | ||
99 | BEGIN(PARAM); | ||
100 | current_pos.file = current_file; | ||
101 | current_pos.lineno = current_file->lineno; | ||
102 | if (id && id->flags & TF_COMMAND) { | ||
103 | zconflval.id = id; | ||
104 | return id->token; | ||
105 | } | ||
121 | alloc_string(yytext, yyleng); | 106 | alloc_string(yytext, yyleng); |
122 | zconflval.string = text; | 107 | zconflval.string = text; |
123 | return T_WORD; | 108 | return T_WORD; |
124 | } | 109 | } |
125 | . | 110 | . |
126 | \n current_file->lineno++; BEGIN(INITIAL); | 111 | \n { |
112 | BEGIN(INITIAL); | ||
113 | current_file->lineno++; | ||
114 | return T_EOL; | ||
115 | } | ||
127 | } | 116 | } |
128 | 117 | ||
129 | <PARAM>{ | 118 | <PARAM>{ |
@@ -134,8 +123,6 @@ n [A-Za-z0-9_] | |||
134 | "!" return T_NOT; | 123 | "!" return T_NOT; |
135 | "=" return T_EQUAL; | 124 | "=" return T_EQUAL; |
136 | "!=" return T_UNEQUAL; | 125 | "!=" return T_UNEQUAL; |
137 | "if" return T_IF; | ||
138 | "on" return T_ON; | ||
139 | \"|\' { | 126 | \"|\' { |
140 | str = yytext[0]; | 127 | str = yytext[0]; |
141 | new_string(); | 128 | new_string(); |
@@ -144,6 +131,11 @@ n [A-Za-z0-9_] | |||
144 | \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; | 131 | \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; |
145 | --- /* ignore */ | 132 | --- /* ignore */ |
146 | ({n}|[-/.])+ { | 133 | ({n}|[-/.])+ { |
134 | struct kconf_id *id = kconf_id_lookup(yytext, yyleng); | ||
135 | if (id && id->flags & TF_PARAM) { | ||
136 | zconflval.id = id; | ||
137 | return id->token; | ||
138 | } | ||
147 | alloc_string(yytext, yyleng); | 139 | alloc_string(yytext, yyleng); |
148 | zconflval.string = text; | 140 | zconflval.string = text; |
149 | return T_WORD; | 141 | return T_WORD; |
@@ -236,9 +228,9 @@ n [A-Za-z0-9_] | |||
236 | } | 228 | } |
237 | 229 | ||
238 | <<EOF>> { | 230 | <<EOF>> { |
239 | if (current_buf) { | 231 | if (current_file) { |
240 | zconf_endfile(); | 232 | zconf_endfile(); |
241 | return T_EOF; | 233 | return T_EOL; |
242 | } | 234 | } |
243 | fclose(yyin); | 235 | fclose(yyin); |
244 | yyterminate(); | 236 | yyterminate(); |
@@ -329,7 +321,7 @@ void zconf_nextfile(const char *name) | |||
329 | current_file = file; | 321 | current_file = file; |
330 | } | 322 | } |
331 | 323 | ||
332 | static struct buffer *zconf_endfile(void) | 324 | static void zconf_endfile(void) |
333 | { | 325 | { |
334 | struct buffer *parent; | 326 | struct buffer *parent; |
335 | 327 | ||
@@ -345,22 +337,14 @@ static struct buffer *zconf_endfile(void) | |||
345 | } | 337 | } |
346 | free(current_buf); | 338 | free(current_buf); |
347 | current_buf = parent; | 339 | current_buf = parent; |
348 | |||
349 | return parent; | ||
350 | } | 340 | } |
351 | 341 | ||
352 | int zconf_lineno(void) | 342 | int zconf_lineno(void) |
353 | { | 343 | { |
354 | if (current_buf) | 344 | return current_pos.lineno; |
355 | return current_file->lineno - 1; | ||
356 | else | ||
357 | return 0; | ||
358 | } | 345 | } |
359 | 346 | ||
360 | char *zconf_curname(void) | 347 | char *zconf_curname(void) |
361 | { | 348 | { |
362 | if (current_buf) | 349 | return current_pos.file ? current_pos.file->name : "<none>"; |
363 | return current_file->name; | ||
364 | else | ||
365 | return "<none>"; | ||
366 | } | 350 | } |
diff --git a/scripts/config/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped index 0bf511e30..ea7755da8 100644 --- a/scripts/config/zconf.tab.c_shipped +++ b/scripts/kconfig/zconf.tab.c_shipped | |||
@@ -1,7 +1,7 @@ | |||
1 | /* A Bison parser, made by GNU Bison 1.875a. */ | 1 | /* A Bison parser, made by GNU Bison 2.0. */ |
2 | 2 | ||
3 | /* Skeleton parser for Yacc-like parsing with Bison, | 3 | /* Skeleton parser for Yacc-like parsing with Bison, |
4 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | 4 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 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 | 7 | it under the terms of the GNU General Public License as published by |
@@ -45,8 +45,7 @@ | |||
45 | /* Using locations. */ | 45 | /* Using locations. */ |
46 | #define YYLSP_NEEDED 0 | 46 | #define YYLSP_NEEDED 0 |
47 | 47 | ||
48 | /* If NAME_PREFIX is specified substitute the variables and functions | 48 | /* Substitute the variable and function names. */ |
49 | names. */ | ||
50 | #define yyparse zconfparse | 49 | #define yyparse zconfparse |
51 | #define yylex zconflex | 50 | #define yylex zconflex |
52 | #define yyerror zconferror | 51 | #define yyerror zconferror |
@@ -79,28 +78,21 @@ | |||
79 | T_REQUIRES = 272, | 78 | T_REQUIRES = 272, |
80 | T_OPTIONAL = 273, | 79 | T_OPTIONAL = 273, |
81 | T_PROMPT = 274, | 80 | T_PROMPT = 274, |
82 | T_DEFAULT = 275, | 81 | T_TYPE = 275, |
83 | T_TRISTATE = 276, | 82 | T_DEFAULT = 276, |
84 | T_DEF_TRISTATE = 277, | 83 | T_SELECT = 277, |
85 | T_BOOLEAN = 278, | 84 | T_RANGE = 278, |
86 | T_DEF_BOOLEAN = 279, | 85 | T_ON = 279, |
87 | T_STRING = 280, | 86 | T_WORD = 280, |
88 | T_INT = 281, | 87 | T_WORD_QUOTE = 281, |
89 | T_HEX = 282, | 88 | T_UNEQUAL = 282, |
90 | T_WORD = 283, | 89 | T_CLOSE_PAREN = 283, |
91 | T_WORD_QUOTE = 284, | 90 | T_OPEN_PAREN = 284, |
92 | T_UNEQUAL = 285, | 91 | T_EOL = 285, |
93 | T_EOF = 286, | 92 | T_OR = 286, |
94 | T_EOL = 287, | 93 | T_AND = 287, |
95 | T_CLOSE_PAREN = 288, | 94 | T_EQUAL = 288, |
96 | T_OPEN_PAREN = 289, | 95 | T_NOT = 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 | }; | 96 | }; |
105 | #endif | 97 | #endif |
106 | #define T_MAINMENU 258 | 98 | #define T_MAINMENU 258 |
@@ -120,28 +112,21 @@ | |||
120 | #define T_REQUIRES 272 | 112 | #define T_REQUIRES 272 |
121 | #define T_OPTIONAL 273 | 113 | #define T_OPTIONAL 273 |
122 | #define T_PROMPT 274 | 114 | #define T_PROMPT 274 |
123 | #define T_DEFAULT 275 | 115 | #define T_TYPE 275 |
124 | #define T_TRISTATE 276 | 116 | #define T_DEFAULT 276 |
125 | #define T_DEF_TRISTATE 277 | 117 | #define T_SELECT 277 |
126 | #define T_BOOLEAN 278 | 118 | #define T_RANGE 278 |
127 | #define T_DEF_BOOLEAN 279 | 119 | #define T_ON 279 |
128 | #define T_STRING 280 | 120 | #define T_WORD 280 |
129 | #define T_INT 281 | 121 | #define T_WORD_QUOTE 281 |
130 | #define T_HEX 282 | 122 | #define T_UNEQUAL 282 |
131 | #define T_WORD 283 | 123 | #define T_CLOSE_PAREN 283 |
132 | #define T_WORD_QUOTE 284 | 124 | #define T_OPEN_PAREN 284 |
133 | #define T_UNEQUAL 285 | 125 | #define T_EOL 285 |
134 | #define T_EOF 286 | 126 | #define T_OR 286 |
135 | #define T_EOL 287 | 127 | #define T_AND 287 |
136 | #define T_CLOSE_PAREN 288 | 128 | #define T_EQUAL 288 |
137 | #define T_OPEN_PAREN 289 | 129 | #define T_NOT 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 | 130 | ||
146 | 131 | ||
147 | 132 | ||
@@ -161,6 +146,11 @@ | |||
161 | #include <string.h> | 146 | #include <string.h> |
162 | #include <stdbool.h> | 147 | #include <stdbool.h> |
163 | 148 | ||
149 | #define LKC_DIRECT_LINK | ||
150 | #include "lkc.h" | ||
151 | |||
152 | #include "zconf.hash.c" | ||
153 | |||
164 | #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) | 154 | #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) |
165 | 155 | ||
166 | #define PRINTD 0x0001 | 156 | #define PRINTD 0x0001 |
@@ -170,14 +160,18 @@ int cdebug = PRINTD; | |||
170 | 160 | ||
171 | extern int zconflex(void); | 161 | extern int zconflex(void); |
172 | static void zconfprint(const char *err, ...); | 162 | static void zconfprint(const char *err, ...); |
163 | static void zconf_error(const char *err, ...); | ||
173 | static void zconferror(const char *err); | 164 | static void zconferror(const char *err); |
174 | static bool zconf_endtoken(int token, int starttoken, int endtoken); | 165 | static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken); |
175 | 166 | ||
176 | struct symbol *symbol_hash[257]; | 167 | struct symbol *symbol_hash[257]; |
177 | 168 | ||
178 | static struct menu *current_menu, *current_entry; | 169 | static struct menu *current_menu, *current_entry; |
179 | 170 | ||
171 | #define YYDEBUG 0 | ||
172 | #if YYDEBUG | ||
180 | #define YYERROR_VERBOSE | 173 | #define YYERROR_VERBOSE |
174 | #endif | ||
181 | 175 | ||
182 | 176 | ||
183 | /* Enabling traces. */ | 177 | /* Enabling traces. */ |
@@ -196,13 +190,14 @@ static struct menu *current_menu, *current_entry; | |||
196 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) | 190 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) |
197 | 191 | ||
198 | typedef union YYSTYPE { | 192 | typedef union YYSTYPE { |
199 | int token; | ||
200 | char *string; | 193 | char *string; |
194 | struct file *file; | ||
201 | struct symbol *symbol; | 195 | struct symbol *symbol; |
202 | struct expr *expr; | 196 | struct expr *expr; |
203 | struct menu *menu; | 197 | struct menu *menu; |
198 | struct kconf_id *id; | ||
204 | } YYSTYPE; | 199 | } YYSTYPE; |
205 | /* Line 191 of yacc.c. */ | 200 | /* Line 190 of yacc.c. */ |
206 | 201 | ||
207 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ | 202 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
208 | # define YYSTYPE_IS_DECLARED 1 | 203 | # define YYSTYPE_IS_DECLARED 1 |
@@ -214,27 +209,26 @@ typedef union YYSTYPE { | |||
214 | /* Copy the second part of user declarations. */ | 209 | /* Copy the second part of user declarations. */ |
215 | 210 | ||
216 | 211 | ||
217 | #define LKC_DIRECT_LINK | 212 | /* Line 213 of yacc.c. */ |
218 | #include "lkc.h" | ||
219 | |||
220 | |||
221 | /* Line 214 of yacc.c. */ | ||
222 | 213 | ||
223 | 214 | ||
224 | #if ! defined (yyoverflow) || YYERROR_VERBOSE | 215 | #if ! defined (yyoverflow) || YYERROR_VERBOSE |
225 | 216 | ||
217 | # ifndef YYFREE | ||
218 | # define YYFREE free | ||
219 | # endif | ||
220 | # ifndef YYMALLOC | ||
221 | # define YYMALLOC malloc | ||
222 | # endif | ||
223 | |||
226 | /* The parser invokes alloca or malloc; define the necessary symbols. */ | 224 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
227 | 225 | ||
228 | # if YYSTACK_USE_ALLOCA | 226 | # ifdef YYSTACK_USE_ALLOCA |
229 | # define YYSTACK_ALLOC alloca | 227 | # if YYSTACK_USE_ALLOCA |
230 | # else | 228 | # ifdef __GNUC__ |
231 | # ifndef YYSTACK_USE_ALLOCA | 229 | # define YYSTACK_ALLOC __builtin_alloca |
232 | # if defined (alloca) || (defined (_ALLOCA_H) && defined (__GNUC__)) | ||
233 | # define YYSTACK_ALLOC alloca | ||
234 | # else | 230 | # else |
235 | # ifdef __GNUC__ | 231 | # define YYSTACK_ALLOC alloca |
236 | # define YYSTACK_ALLOC __builtin_alloca | ||
237 | # endif | ||
238 | # endif | 232 | # endif |
239 | # endif | 233 | # endif |
240 | # endif | 234 | # endif |
@@ -247,20 +241,20 @@ typedef union YYSTYPE { | |||
247 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | 241 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
248 | # define YYSIZE_T size_t | 242 | # define YYSIZE_T size_t |
249 | # endif | 243 | # endif |
250 | # define YYSTACK_ALLOC malloc | 244 | # define YYSTACK_ALLOC YYMALLOC |
251 | # define YYSTACK_FREE free | 245 | # define YYSTACK_FREE YYFREE |
252 | # endif | 246 | # endif |
253 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ | 247 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ |
254 | 248 | ||
255 | 249 | ||
256 | #if (! defined (yyoverflow) \ | 250 | #if (! defined (yyoverflow) \ |
257 | && (! defined (__cplusplus) \ | 251 | && (! defined (__cplusplus) \ |
258 | || (YYSTYPE_IS_TRIVIAL))) | 252 | || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) |
259 | 253 | ||
260 | /* A type that is properly aligned for any stack member. */ | 254 | /* A type that is properly aligned for any stack member. */ |
261 | union yyalloc | 255 | union yyalloc |
262 | { | 256 | { |
263 | short yyss; | 257 | short int yyss; |
264 | YYSTYPE yyvs; | 258 | YYSTYPE yyvs; |
265 | }; | 259 | }; |
266 | 260 | ||
@@ -270,13 +264,13 @@ union yyalloc | |||
270 | /* The size of an array large to enough to hold all stacks, each with | 264 | /* The size of an array large to enough to hold all stacks, each with |
271 | N elements. */ | 265 | N elements. */ |
272 | # define YYSTACK_BYTES(N) \ | 266 | # define YYSTACK_BYTES(N) \ |
273 | ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ | 267 | ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ |
274 | + YYSTACK_GAP_MAXIMUM) | 268 | + YYSTACK_GAP_MAXIMUM) |
275 | 269 | ||
276 | /* Copy COUNT objects from FROM to TO. The source and destination do | 270 | /* Copy COUNT objects from FROM to TO. The source and destination do |
277 | not overlap. */ | 271 | not overlap. */ |
278 | # ifndef YYCOPY | 272 | # ifndef YYCOPY |
279 | # if 1 < __GNUC__ | 273 | # if defined (__GNUC__) && 1 < __GNUC__ |
280 | # define YYCOPY(To, From, Count) \ | 274 | # define YYCOPY(To, From, Count) \ |
281 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) | 275 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
282 | # else | 276 | # else |
@@ -312,28 +306,28 @@ union yyalloc | |||
312 | #if defined (__STDC__) || defined (__cplusplus) | 306 | #if defined (__STDC__) || defined (__cplusplus) |
313 | typedef signed char yysigned_char; | 307 | typedef signed char yysigned_char; |
314 | #else | 308 | #else |
315 | typedef short yysigned_char; | 309 | typedef short int yysigned_char; |
316 | #endif | 310 | #endif |
317 | 311 | ||
318 | /* YYFINAL -- State number of the termination state. */ | 312 | /* YYFINAL -- State number of the termination state. */ |
319 | #define YYFINAL 2 | 313 | #define YYFINAL 3 |
320 | /* YYLAST -- Last index in YYTABLE. */ | 314 | /* YYLAST -- Last index in YYTABLE. */ |
321 | #define YYLAST 201 | 315 | #define YYLAST 264 |
322 | 316 | ||
323 | /* YYNTOKENS -- Number of terminals. */ | 317 | /* YYNTOKENS -- Number of terminals. */ |
324 | #define YYNTOKENS 42 | 318 | #define YYNTOKENS 35 |
325 | /* YYNNTS -- Number of nonterminals. */ | 319 | /* YYNNTS -- Number of nonterminals. */ |
326 | #define YYNNTS 41 | 320 | #define YYNNTS 42 |
327 | /* YYNRULES -- Number of rules. */ | 321 | /* YYNRULES -- Number of rules. */ |
328 | #define YYNRULES 104 | 322 | #define YYNRULES 104 |
329 | /* YYNRULES -- Number of states. */ | 323 | /* YYNRULES -- Number of states. */ |
330 | #define YYNSTATES 182 | 324 | #define YYNSTATES 175 |
331 | 325 | ||
332 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ | 326 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
333 | #define YYUNDEFTOK 2 | 327 | #define YYUNDEFTOK 2 |
334 | #define YYMAXUTOK 296 | 328 | #define YYMAXUTOK 289 |
335 | 329 | ||
336 | #define YYTRANSLATE(YYX) \ | 330 | #define YYTRANSLATE(YYX) \ |
337 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) | 331 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
338 | 332 | ||
339 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ | 333 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
@@ -367,79 +361,78 @@ static const unsigned char yytranslate[] = | |||
367 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, | 361 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
368 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, | 362 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
369 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, | 363 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
370 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, | 364 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34 |
371 | 35, 36, 37, 38, 39, 40, 41 | ||
372 | }; | 365 | }; |
373 | 366 | ||
374 | #if YYDEBUG | 367 | #if YYDEBUG |
375 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in | 368 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
376 | YYRHS. */ | 369 | YYRHS. */ |
377 | static const unsigned short yyprhs[] = | 370 | static const unsigned short int yyprhs[] = |
378 | { | 371 | { |
379 | 0, 0, 3, 4, 7, 9, 11, 13, 17, 19, | 372 | 0, 0, 3, 5, 6, 9, 12, 15, 20, 23, |
380 | 21, 23, 26, 28, 30, 32, 34, 36, 38, 42, | 373 | 28, 33, 37, 39, 41, 43, 45, 47, 49, 51, |
381 | 45, 49, 52, 53, 56, 59, 62, 65, 69, 74, | 374 | 53, 55, 57, 59, 61, 63, 67, 70, 74, 77, |
382 | 78, 83, 87, 91, 95, 100, 105, 110, 116, 119, | 375 | 81, 84, 85, 88, 91, 94, 97, 100, 104, 109, |
383 | 122, 124, 128, 131, 132, 135, 138, 141, 144, 149, | 376 | 114, 119, 125, 128, 131, 133, 137, 138, 141, 144, |
384 | 153, 157, 160, 165, 166, 169, 173, 175, 179, 182, | 377 | 147, 150, 153, 158, 162, 165, 170, 171, 174, 178, |
385 | 183, 186, 189, 192, 196, 199, 201, 205, 208, 209, | 378 | 180, 184, 185, 188, 191, 194, 198, 201, 203, 207, |
386 | 212, 215, 218, 222, 226, 228, 232, 235, 238, 241, | 379 | 208, 211, 214, 217, 221, 225, 228, 231, 234, 235, |
387 | 242, 245, 248, 253, 257, 261, 262, 265, 267, 269, | 380 | 238, 241, 244, 249, 253, 257, 258, 261, 263, 265, |
388 | 272, 275, 278, 280, 282, 283, 286, 288, 292, 296, | 381 | 268, 271, 274, 276, 279, 280, 283, 285, 289, 293, |
389 | 300, 303, 307, 311, 313 | 382 | 297, 300, 304, 308, 310 |
390 | }; | 383 | }; |
391 | 384 | ||
392 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ | 385 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
393 | static const yysigned_char yyrhs[] = | 386 | static const yysigned_char yyrhs[] = |
394 | { | 387 | { |
395 | 43, 0, -1, -1, 43, 44, -1, 45, -1, 55, | 388 | 36, 0, -1, 37, -1, -1, 37, 39, -1, 37, |
396 | -1, 66, -1, 3, 77, 79, -1, 5, -1, 15, | 389 | 50, -1, 37, 61, -1, 37, 3, 71, 73, -1, |
397 | -1, 8, -1, 1, 79, -1, 61, -1, 71, -1, | 390 | 37, 72, -1, 37, 25, 1, 30, -1, 37, 38, |
398 | 47, -1, 49, -1, 69, -1, 79, -1, 10, 28, | 391 | 1, 30, -1, 37, 1, 30, -1, 16, -1, 19, |
399 | 32, -1, 46, 50, -1, 11, 28, 32, -1, 48, | 392 | -1, 20, -1, 22, -1, 18, -1, 23, -1, 21, |
400 | 50, -1, -1, 50, 51, -1, 50, 75, -1, 50, | 393 | -1, 30, -1, 56, -1, 65, -1, 42, -1, 44, |
401 | 73, -1, 50, 32, -1, 21, 76, 32, -1, 22, | 394 | -1, 63, -1, 25, 1, 30, -1, 1, 30, -1, |
402 | 81, 80, 32, -1, 23, 76, 32, -1, 24, 81, | 395 | 10, 25, 30, -1, 41, 45, -1, 11, 25, 30, |
403 | 80, 32, -1, 26, 76, 32, -1, 27, 76, 32, | 396 | -1, 43, 45, -1, -1, 45, 46, -1, 45, 69, |
404 | -1, 25, 76, 32, -1, 19, 77, 80, 32, -1, | 397 | -1, 45, 67, -1, 45, 40, -1, 45, 30, -1, |
405 | 20, 81, 80, 32, -1, 36, 28, 80, 32, -1, | 398 | 20, 70, 30, -1, 19, 71, 74, 30, -1, 21, |
406 | 37, 82, 82, 80, 32, -1, 7, 32, -1, 52, | 399 | 75, 74, 30, -1, 22, 25, 74, 30, -1, 23, |
407 | 56, -1, 78, -1, 53, 58, 54, -1, 53, 58, | 400 | 76, 76, 74, 30, -1, 7, 30, -1, 47, 51, |
408 | -1, -1, 56, 57, -1, 56, 75, -1, 56, 73, | 401 | -1, 72, -1, 48, 53, 49, -1, -1, 51, 52, |
409 | -1, 56, 32, -1, 19, 77, 80, 32, -1, 21, | 402 | -1, 51, 69, -1, 51, 67, -1, 51, 30, -1, |
410 | 76, 32, -1, 23, 76, 32, -1, 18, 32, -1, | 403 | 51, 40, -1, 19, 71, 74, 30, -1, 20, 70, |
411 | 20, 28, 80, 32, -1, -1, 58, 45, -1, 14, | 404 | 30, -1, 18, 30, -1, 21, 25, 74, 30, -1, |
412 | 81, 32, -1, 78, -1, 59, 62, 60, -1, 59, | 405 | -1, 53, 39, -1, 14, 75, 73, -1, 72, -1, |
413 | 62, -1, -1, 62, 45, -1, 62, 66, -1, 62, | 406 | 54, 57, 55, -1, -1, 57, 39, -1, 57, 61, |
414 | 55, -1, 4, 77, 32, -1, 63, 74, -1, 78, | 407 | -1, 57, 50, -1, 4, 71, 30, -1, 58, 68, |
415 | -1, 64, 67, 65, -1, 64, 67, -1, -1, 67, | 408 | -1, 72, -1, 59, 62, 60, -1, -1, 62, 39, |
416 | 45, -1, 67, 66, -1, 67, 55, -1, 67, 1, | 409 | -1, 62, 61, -1, 62, 50, -1, 6, 71, 30, |
417 | 32, -1, 6, 77, 32, -1, 68, -1, 9, 77, | 410 | -1, 9, 71, 30, -1, 64, 68, -1, 12, 30, |
418 | 32, -1, 70, 74, -1, 12, 32, -1, 72, 13, | 411 | -1, 66, 13, -1, -1, 68, 69, -1, 68, 30, |
419 | -1, -1, 74, 75, -1, 74, 32, -1, 16, 35, | 412 | -1, 68, 40, -1, 16, 24, 75, 30, -1, 16, |
420 | 81, 32, -1, 16, 81, 32, -1, 17, 81, 32, | 413 | 75, 30, -1, 17, 75, 30, -1, -1, 71, 74, |
421 | -1, -1, 77, 80, -1, 28, -1, 29, -1, 5, | 414 | -1, 25, -1, 26, -1, 5, 30, -1, 8, 30, |
422 | 79, -1, 8, 79, -1, 15, 79, -1, 32, -1, | 415 | -1, 15, 30, -1, 30, -1, 73, 30, -1, -1, |
423 | 31, -1, -1, 14, 81, -1, 82, -1, 82, 40, | 416 | 14, 75, -1, 76, -1, 76, 33, 76, -1, 76, |
424 | 82, -1, 82, 30, 82, -1, 34, 81, 33, -1, | 417 | 27, 76, -1, 29, 75, 28, -1, 34, 75, -1, |
425 | 41, 81, -1, 81, 38, 81, -1, 81, 39, 81, | 418 | 75, 31, 75, -1, 75, 32, 75, -1, 25, -1, |
426 | -1, 28, -1, 29, -1 | 419 | 26, -1 |
427 | }; | 420 | }; |
428 | 421 | ||
429 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ | 422 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
430 | static const unsigned short yyrline[] = | 423 | static const unsigned short int yyrline[] = |
431 | { | 424 | { |
432 | 0, 94, 94, 95, 98, 99, 100, 101, 102, 103, | 425 | 0, 103, 103, 105, 107, 108, 109, 110, 111, 112, |
433 | 104, 105, 109, 110, 111, 112, 113, 114, 120, 128, | 426 | 113, 117, 121, 121, 121, 121, 121, 121, 121, 125, |
434 | 134, 142, 152, 154, 155, 156, 157, 160, 166, 173, | 427 | 126, 127, 128, 129, 130, 134, 135, 141, 149, 155, |
435 | 179, 186, 192, 198, 204, 210, 216, 222, 230, 239, | 428 | 163, 173, 175, 176, 177, 178, 179, 182, 190, 196, |
436 | 245, 254, 255, 261, 263, 264, 265, 266, 269, 275, | 429 | 206, 212, 220, 229, 234, 242, 245, 247, 248, 249, |
437 | 281, 287, 293, 299, 301, 306, 315, 324, 325, 331, | 430 | 250, 251, 254, 260, 271, 277, 287, 289, 294, 302, |
438 | 333, 334, 335, 340, 347, 353, 362, 363, 369, 371, | 431 | 310, 313, 315, 316, 317, 322, 329, 334, 342, 345, |
439 | 372, 373, 374, 377, 383, 390, 397, 404, 410, 417, | 432 | 347, 348, 349, 352, 360, 367, 374, 380, 387, 389, |
440 | 418, 419, 422, 427, 432, 440, 442, 447, 448, 451, | 433 | 390, 391, 394, 399, 404, 412, 414, 419, 420, 423, |
441 | 452, 453, 457, 457, 459, 460, 463, 464, 465, 466, | 434 | 424, 425, 429, 430, 433, 434, 437, 438, 439, 440, |
442 | 467, 468, 469, 472, 473 | 435 | 441, 442, 443, 446, 447 |
443 | }; | 436 | }; |
444 | #endif | 437 | #endif |
445 | 438 | ||
@@ -451,64 +444,62 @@ static const char *const yytname[] = | |||
451 | "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU", | 444 | "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU", |
452 | "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", | 445 | "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", |
453 | "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", | 446 | "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", |
454 | "T_REQUIRES", "T_OPTIONAL", "T_PROMPT", "T_DEFAULT", "T_TRISTATE", | 447 | "T_REQUIRES", "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", |
455 | "T_DEF_TRISTATE", "T_BOOLEAN", "T_DEF_BOOLEAN", "T_STRING", "T_INT", | 448 | "T_SELECT", "T_RANGE", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", |
456 | "T_HEX", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", "T_EOF", "T_EOL", | 449 | "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL", |
457 | "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_ON", "T_SELECT", "T_RANGE", "T_OR", | 450 | "T_NOT", "$accept", "input", "stmt_list", "option_name", "common_stmt", |
458 | "T_AND", "T_EQUAL", "T_NOT", "$accept", "input", "block", | 451 | "option_error", "config_entry_start", "config_stmt", |
459 | "common_block", "config_entry_start", "config_stmt", | ||
460 | "menuconfig_entry_start", "menuconfig_stmt", "config_option_list", | 452 | "menuconfig_entry_start", "menuconfig_stmt", "config_option_list", |
461 | "config_option", "choice", "choice_entry", "choice_end", "choice_stmt", | 453 | "config_option", "choice", "choice_entry", "choice_end", "choice_stmt", |
462 | "choice_option_list", "choice_option", "choice_block", "if", "if_end", | 454 | "choice_option_list", "choice_option", "choice_block", "if_entry", |
463 | "if_stmt", "if_block", "menu", "menu_entry", "menu_end", "menu_stmt", | 455 | "if_end", "if_stmt", "if_block", "menu", "menu_entry", "menu_end", |
464 | "menu_block", "source", "source_stmt", "comment", "comment_stmt", | 456 | "menu_stmt", "menu_block", "source_stmt", "comment", "comment_stmt", |
465 | "help_start", "help", "depends_list", "depends", "prompt_stmt_opt", | 457 | "help_start", "help", "depends_list", "depends", "prompt_stmt_opt", |
466 | "prompt", "end", "nl_or_eof", "if_expr", "expr", "symbol", 0 | 458 | "prompt", "end", "nl", "if_expr", "expr", "symbol", 0 |
467 | }; | 459 | }; |
468 | #endif | 460 | #endif |
469 | 461 | ||
470 | # ifdef YYPRINT | 462 | # ifdef YYPRINT |
471 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to | 463 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
472 | token YYLEX-NUM. */ | 464 | token YYLEX-NUM. */ |
473 | static const unsigned short yytoknum[] = | 465 | static const unsigned short int yytoknum[] = |
474 | { | 466 | { |
475 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, | 467 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
476 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, | 468 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
477 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, | 469 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
478 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, | 470 | 285, 286, 287, 288, 289 |
479 | 295, 296 | ||
480 | }; | 471 | }; |
481 | # endif | 472 | # endif |
482 | 473 | ||
483 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ | 474 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
484 | static const unsigned char yyr1[] = | 475 | static const unsigned char yyr1[] = |
485 | { | 476 | { |
486 | 0, 42, 43, 43, 44, 44, 44, 44, 44, 44, | 477 | 0, 35, 36, 37, 37, 37, 37, 37, 37, 37, |
487 | 44, 44, 45, 45, 45, 45, 45, 45, 46, 47, | 478 | 37, 37, 38, 38, 38, 38, 38, 38, 38, 39, |
488 | 48, 49, 50, 50, 50, 50, 50, 51, 51, 51, | 479 | 39, 39, 39, 39, 39, 40, 40, 41, 42, 43, |
489 | 51, 51, 51, 51, 51, 51, 51, 51, 52, 53, | 480 | 44, 45, 45, 45, 45, 45, 45, 46, 46, 46, |
490 | 54, 55, 55, 56, 56, 56, 56, 56, 57, 57, | 481 | 46, 46, 47, 48, 49, 50, 51, 51, 51, 51, |
491 | 57, 57, 57, 58, 58, 59, 60, 61, 61, 62, | 482 | 51, 51, 52, 52, 52, 52, 53, 53, 54, 55, |
492 | 62, 62, 62, 63, 64, 65, 66, 66, 67, 67, | 483 | 56, 57, 57, 57, 57, 58, 59, 60, 61, 62, |
493 | 67, 67, 67, 68, 69, 70, 71, 72, 73, 74, | 484 | 62, 62, 62, 63, 64, 65, 66, 67, 68, 68, |
494 | 74, 74, 75, 75, 75, 76, 76, 77, 77, 78, | 485 | 68, 68, 69, 69, 69, 70, 70, 71, 71, 72, |
495 | 78, 78, 79, 79, 80, 80, 81, 81, 81, 81, | 486 | 72, 72, 73, 73, 74, 74, 75, 75, 75, 75, |
496 | 81, 81, 81, 82, 82 | 487 | 75, 75, 75, 76, 76 |
497 | }; | 488 | }; |
498 | 489 | ||
499 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ | 490 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
500 | static const unsigned char yyr2[] = | 491 | static const unsigned char yyr2[] = |
501 | { | 492 | { |
502 | 0, 2, 0, 2, 1, 1, 1, 3, 1, 1, | 493 | 0, 2, 1, 0, 2, 2, 2, 4, 2, 4, |
503 | 1, 2, 1, 1, 1, 1, 1, 1, 3, 2, | 494 | 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, |
504 | 3, 2, 0, 2, 2, 2, 2, 3, 4, 3, | 495 | 1, 1, 1, 1, 1, 3, 2, 3, 2, 3, |
505 | 4, 3, 3, 3, 4, 4, 4, 5, 2, 2, | 496 | 2, 0, 2, 2, 2, 2, 2, 3, 4, 4, |
506 | 1, 3, 2, 0, 2, 2, 2, 2, 4, 3, | 497 | 4, 5, 2, 2, 1, 3, 0, 2, 2, 2, |
507 | 3, 2, 4, 0, 2, 3, 1, 3, 2, 0, | 498 | 2, 2, 4, 3, 2, 4, 0, 2, 3, 1, |
508 | 2, 2, 2, 3, 2, 1, 3, 2, 0, 2, | 499 | 3, 0, 2, 2, 2, 3, 2, 1, 3, 0, |
509 | 2, 2, 3, 3, 1, 3, 2, 2, 2, 0, | 500 | 2, 2, 2, 3, 3, 2, 2, 2, 0, 2, |
510 | 2, 2, 4, 3, 3, 0, 2, 1, 1, 2, | 501 | 2, 2, 4, 3, 3, 0, 2, 1, 1, 2, |
511 | 2, 2, 1, 1, 0, 2, 1, 3, 3, 3, | 502 | 2, 2, 1, 2, 0, 2, 1, 3, 3, 3, |
512 | 2, 3, 3, 1, 1 | 503 | 2, 3, 3, 1, 1 |
513 | }; | 504 | }; |
514 | 505 | ||
@@ -517,151 +508,160 @@ static const unsigned char yyr2[] = | |||
517 | means the default is an error. */ | 508 | means the default is an error. */ |
518 | static const unsigned char yydefact[] = | 509 | static const unsigned char yydefact[] = |
519 | { | 510 | { |
520 | 2, 0, 1, 0, 0, 0, 8, 0, 0, 10, | 511 | 3, 0, 0, 1, 0, 0, 0, 0, 0, 0, |
521 | 0, 0, 0, 0, 9, 93, 92, 3, 4, 22, | 512 | 0, 0, 0, 0, 0, 0, 12, 16, 13, 14, |
522 | 14, 22, 15, 43, 53, 5, 59, 12, 79, 68, | 513 | 18, 15, 17, 0, 19, 0, 4, 31, 22, 31, |
523 | 6, 74, 16, 79, 13, 17, 11, 87, 88, 0, | 514 | 23, 46, 56, 5, 61, 20, 78, 69, 6, 24, |
524 | 0, 0, 38, 0, 0, 0, 103, 104, 0, 0, | 515 | 78, 21, 8, 11, 87, 88, 0, 0, 89, 0, |
525 | 0, 96, 19, 21, 39, 42, 58, 64, 0, 76, | 516 | 42, 90, 0, 0, 0, 103, 104, 0, 0, 0, |
526 | 7, 63, 73, 75, 18, 20, 0, 100, 55, 0, | 517 | 96, 91, 0, 0, 0, 0, 0, 0, 0, 0, |
527 | 0, 0, 0, 0, 0, 0, 0, 0, 85, 0, | 518 | 0, 0, 92, 7, 65, 73, 74, 27, 29, 0, |
528 | 85, 0, 85, 85, 85, 26, 0, 0, 23, 0, | 519 | 100, 0, 0, 58, 0, 0, 9, 10, 0, 0, |
529 | 25, 24, 0, 0, 0, 85, 85, 47, 44, 46, | 520 | 0, 0, 0, 85, 0, 0, 0, 0, 36, 35, |
530 | 45, 0, 0, 0, 54, 41, 40, 60, 62, 57, | 521 | 32, 0, 34, 33, 0, 0, 85, 0, 50, 51, |
531 | 61, 56, 81, 80, 0, 69, 71, 66, 70, 65, | 522 | 47, 49, 48, 57, 45, 44, 62, 64, 60, 63, |
532 | 99, 101, 102, 98, 97, 77, 0, 0, 0, 94, | 523 | 59, 80, 81, 79, 70, 72, 68, 71, 67, 93, |
533 | 94, 0, 94, 94, 0, 94, 0, 0, 0, 94, | 524 | 99, 101, 102, 98, 97, 26, 76, 0, 0, 0, |
534 | 0, 78, 51, 94, 94, 0, 0, 89, 90, 91, | 525 | 94, 0, 94, 94, 94, 0, 0, 77, 54, 94, |
535 | 72, 0, 83, 84, 0, 0, 0, 27, 86, 0, | 526 | 0, 94, 0, 83, 84, 0, 0, 37, 86, 0, |
536 | 29, 0, 33, 31, 32, 0, 94, 0, 0, 49, | 527 | 0, 94, 25, 0, 53, 0, 82, 95, 38, 39, |
537 | 50, 82, 95, 34, 35, 28, 30, 36, 0, 48, | 528 | 40, 0, 52, 55, 41 |
538 | 52, 37 | ||
539 | }; | 529 | }; |
540 | 530 | ||
541 | /* YYDEFGOTO[NTERM-NUM]. */ | 531 | /* YYDEFGOTO[NTERM-NUM]. */ |
542 | static const short yydefgoto[] = | 532 | static const short int yydefgoto[] = |
543 | { | 533 | { |
544 | -1, 1, 17, 18, 19, 20, 21, 22, 52, 88, | 534 | -1, 1, 2, 25, 26, 99, 27, 28, 29, 30, |
545 | 23, 24, 105, 25, 54, 98, 55, 26, 109, 27, | 535 | 64, 100, 31, 32, 114, 33, 66, 110, 67, 34, |
546 | 56, 28, 29, 117, 30, 58, 31, 32, 33, 34, | 536 | 118, 35, 68, 36, 37, 126, 38, 70, 39, 40, |
547 | 89, 90, 57, 91, 131, 132, 106, 35, 155, 50, | 537 | 41, 101, 102, 69, 103, 141, 142, 42, 73, 156, |
548 | 51 | 538 | 59, 60 |
549 | }; | 539 | }; |
550 | 540 | ||
551 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing | 541 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
552 | STATE-NUM. */ | 542 | STATE-NUM. */ |
553 | #define YYPACT_NINF -99 | 543 | #define YYPACT_NINF -78 |
554 | static const short yypact[] = | 544 | static const short int yypact[] = |
555 | { | 545 | { |
556 | -99, 48, -99, 38, 46, 46, -99, 46, -29, -99, | 546 | -78, 2, 159, -78, -21, 0, 0, -12, 0, 1, |
557 | 46, -17, -3, -11, -99, -99, -99, -99, -99, -99, | 547 | 4, 0, 27, 38, 60, 58, -78, -78, -78, -78, |
558 | -99, -99, -99, -99, -99, -99, -99, -99, -99, -99, | 548 | -78, -78, -78, 100, -78, 104, -78, -78, -78, -78, |
559 | -99, -99, -99, -99, -99, -99, -99, -99, -99, 38, | 549 | -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, |
560 | 12, 15, -99, 18, 51, 62, -99, -99, -11, -11, | 550 | -78, -78, -78, -78, -78, -78, 86, 113, -78, 114, |
561 | 4, -24, 138, 138, 160, 121, 110, -4, 81, -4, | 551 | -78, -78, 125, 127, 128, -78, -78, 60, 60, 210, |
562 | -99, -99, -99, -99, -99, -99, -19, -99, -99, -11, | 552 | 65, -78, 141, 142, 39, 103, 182, 200, 6, 66, |
563 | -11, 70, 70, 73, 32, -11, 46, -11, 46, -11, | 553 | 6, 131, -78, 146, -78, -78, -78, -78, -78, 196, |
564 | 46, -11, 46, 46, 46, -99, 36, 70, -99, 95, | 554 | -78, 60, 60, 146, 40, 40, -78, -78, 155, 156, |
565 | -99, -99, 96, 46, 106, 46, 46, -99, -99, -99, | 555 | -2, 60, 0, 0, 60, 105, 40, 194, -78, -78, |
566 | -99, 38, 38, 38, -99, -99, -99, -99, -99, -99, | 556 | -78, 206, -78, -78, 183, 0, 0, 195, -78, -78, |
567 | -99, -99, -99, -99, 112, -99, -99, -99, -99, -99, | 557 | -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, |
568 | -99, 117, -99, -99, -99, -99, -11, 33, 65, 131, | 558 | -78, -78, -78, -78, -78, -78, -78, -78, -78, -78, |
569 | 1, 119, 131, 1, 136, 1, 153, 154, 155, 131, | 559 | -78, 197, -78, -78, -78, -78, -78, 60, 213, 216, |
570 | 70, -99, -99, 131, 131, 156, 157, -99, -99, -99, | 560 | 212, 203, 212, 190, 212, 40, 208, -78, -78, 212, |
571 | -99, 101, -99, -99, -11, 158, 159, -99, -99, 161, | 561 | 222, 212, 219, -78, -78, 60, 223, -78, -78, 224, |
572 | -99, 162, -99, -99, -99, 163, 131, 164, 165, -99, | 562 | 225, 212, -78, 226, -78, 227, -78, 47, -78, -78, |
573 | -99, -99, 99, -99, -99, -99, -99, -99, 166, -99, | 563 | -78, 228, -78, -78, -78 |
574 | -99, -99 | ||
575 | }; | 564 | }; |
576 | 565 | ||
577 | /* YYPGOTO[NTERM-NUM]. */ | 566 | /* YYPGOTO[NTERM-NUM]. */ |
578 | static const short yypgoto[] = | 567 | static const short int yypgoto[] = |
579 | { | 568 | { |
580 | -99, -99, -99, 111, -99, -99, -99, -99, 178, -99, | 569 | -78, -78, -78, -78, 164, -36, -78, -78, -78, -78, |
581 | -99, -99, -99, 91, -99, -99, -99, -99, -99, -99, | 570 | 230, -78, -78, -78, -78, 29, -78, -78, -78, -78, |
582 | -99, -99, -99, -99, 115, -99, -99, -99, -99, -99, | 571 | -78, -78, -78, -78, -78, -78, 59, -78, -78, -78, |
583 | -99, 146, 168, 89, 27, 0, 126, -1, -98, -48, | 572 | -78, -78, 198, 220, 24, 157, -5, 169, 202, 74, |
584 | -63 | 573 | -53, -77 |
585 | }; | 574 | }; |
586 | 575 | ||
587 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If | 576 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
588 | positive, shift that token. If negative, reduce the rule which | 577 | positive, shift that token. If negative, reduce the rule which |
589 | number is the opposite. If zero, do what YYDEFACT says. | 578 | number is the opposite. If zero, do what YYDEFACT says. |
590 | If YYTABLE_NINF, syntax error. */ | 579 | If YYTABLE_NINF, syntax error. */ |
591 | #define YYTABLE_NINF -68 | 580 | #define YYTABLE_NINF -76 |
592 | static const short yytable[] = | 581 | static const short int yytable[] = |
593 | { | 582 | { |
594 | 66, 67, 36, 42, 39, 40, 71, 41, 123, 124, | 583 | 46, 47, 3, 49, 79, 80, 52, 133, 134, 43, |
595 | 43, 44, 74, 75, 120, 154, 72, 46, 47, 69, | 584 | 6, 7, 8, 9, 10, 11, 12, 13, 48, 145, |
596 | 70, 121, 122, 48, 140, 45, 127, 128, 112, 130, | 585 | 14, 15, 137, 55, 56, 44, 45, 57, 131, 132, |
597 | 49, 133, 156, 135, 158, 159, 68, 161, 60, 69, | 586 | 109, 50, 58, 122, 51, 122, 24, 138, 139, -28, |
598 | 70, 165, 69, 70, 61, 167, 168, 62, 2, 3, | 587 | 88, 143, -28, -28, -28, -28, -28, -28, -28, -28, |
599 | 63, 4, 5, 6, 7, 8, 9, 10, 11, 12, | 588 | -28, 89, 53, -28, -28, 90, 91, -28, 92, 93, |
600 | 46, 47, 13, 14, 139, 152, 48, 126, 178, 15, | 589 | 94, 95, 96, 54, 97, 55, 56, 88, 161, 98, |
601 | 16, 69, 70, 49, 37, 38, 129, 166, 151, 15, | 590 | -66, -66, -66, -66, -66, -66, -66, -66, 81, 82, |
602 | 16, -67, 114, 64, -67, 5, 101, 7, 8, 102, | 591 | -66, -66, 90, 91, 152, 55, 56, 140, 61, 57, |
603 | 10, 11, 12, 143, 65, 13, 103, 153, 46, 47, | 592 | 112, 97, 84, 123, 58, 123, 121, 117, 85, 125, |
604 | 147, 148, 149, 69, 70, 125, 172, 134, 141, 136, | 593 | 149, 62, 167, -30, 88, 63, -30, -30, -30, -30, |
605 | 137, 138, 15, 16, 5, 101, 7, 8, 102, 10, | 594 | -30, -30, -30, -30, -30, 89, 72, -30, -30, 90, |
606 | 11, 12, 145, 146, 13, 103, 101, 7, 142, 102, | 595 | 91, -30, 92, 93, 94, 95, 96, 119, 97, 127, |
607 | 10, 11, 12, 171, 144, 13, 103, 69, 70, 69, | 596 | 144, -75, 88, 98, -75, -75, -75, -75, -75, -75, |
608 | 70, 15, 16, 100, 150, 154, 113, 108, 113, 116, | 597 | -75, -75, -75, 74, 75, -75, -75, 90, 91, -75, |
609 | 73, 157, 15, 16, 74, 75, 70, 76, 77, 78, | 598 | -75, -75, -75, -75, -75, 76, 97, 77, 78, -2, |
610 | 79, 80, 81, 82, 83, 84, 104, 107, 160, 115, | 599 | 4, 121, 5, 6, 7, 8, 9, 10, 11, 12, |
611 | 85, 110, 73, 118, 86, 87, 74, 75, 92, 93, | 600 | 13, 86, 87, 14, 15, 16, 129, 17, 18, 19, |
612 | 94, 95, 111, 96, 119, 162, 163, 164, 169, 170, | 601 | 20, 21, 22, 88, 23, 135, 136, -43, -43, 24, |
613 | 173, 174, 97, 175, 176, 177, 179, 180, 181, 53, | 602 | -43, -43, -43, -43, 89, 146, -43, -43, 90, 91, |
614 | 99, 59 | 603 | 104, 105, 106, 107, 155, 7, 8, 97, 10, 11, |
604 | 12, 13, 108, 148, 14, 15, 158, 159, 160, 147, | ||
605 | 151, 81, 82, 163, 130, 165, 155, 81, 82, 82, | ||
606 | 24, 113, 116, 157, 124, 171, 115, 120, 162, 128, | ||
607 | 72, 81, 82, 153, 81, 82, 154, 81, 82, 166, | ||
608 | 81, 82, 164, 168, 169, 170, 172, 173, 174, 65, | ||
609 | 71, 83, 0, 150, 111 | ||
615 | }; | 610 | }; |
616 | 611 | ||
617 | static const unsigned char yycheck[] = | 612 | static const short int yycheck[] = |
618 | { | 613 | { |
619 | 48, 49, 3, 32, 4, 5, 30, 7, 71, 72, | 614 | 5, 6, 0, 8, 57, 58, 11, 84, 85, 30, |
620 | 10, 28, 16, 17, 33, 14, 40, 28, 29, 38, | 615 | 4, 5, 6, 7, 8, 9, 10, 11, 30, 96, |
621 | 39, 69, 70, 34, 87, 28, 74, 75, 32, 77, | 616 | 14, 15, 24, 25, 26, 25, 26, 29, 81, 82, |
622 | 41, 79, 130, 81, 132, 133, 32, 135, 39, 38, | 617 | 66, 30, 34, 69, 30, 71, 30, 90, 91, 0, |
623 | 39, 139, 38, 39, 32, 143, 144, 32, 0, 1, | 618 | 1, 94, 3, 4, 5, 6, 7, 8, 9, 10, |
624 | 32, 3, 4, 5, 6, 7, 8, 9, 10, 11, | 619 | 11, 12, 25, 14, 15, 16, 17, 18, 19, 20, |
625 | 28, 29, 14, 15, 28, 32, 34, 35, 166, 31, | 620 | 21, 22, 23, 25, 25, 25, 26, 1, 145, 30, |
626 | 32, 38, 39, 41, 28, 29, 76, 140, 126, 31, | 621 | 4, 5, 6, 7, 8, 9, 10, 11, 31, 32, |
627 | 32, 0, 1, 32, 3, 4, 5, 6, 7, 8, | 622 | 14, 15, 16, 17, 137, 25, 26, 92, 30, 29, |
628 | 9, 10, 11, 93, 32, 14, 15, 32, 28, 29, | 623 | 66, 25, 27, 69, 34, 71, 30, 68, 33, 70, |
629 | 101, 102, 103, 38, 39, 32, 154, 80, 13, 82, | 624 | 105, 1, 155, 0, 1, 1, 3, 4, 5, 6, |
630 | 83, 84, 31, 32, 4, 5, 6, 7, 8, 9, | 625 | 7, 8, 9, 10, 11, 12, 30, 14, 15, 16, |
631 | 10, 11, 95, 96, 14, 15, 5, 6, 32, 8, | 626 | 17, 18, 19, 20, 21, 22, 23, 68, 25, 70, |
632 | 9, 10, 11, 32, 28, 14, 15, 38, 39, 38, | 627 | 25, 0, 1, 30, 3, 4, 5, 6, 7, 8, |
633 | 39, 31, 32, 54, 32, 14, 57, 56, 59, 58, | 628 | 9, 10, 11, 30, 30, 14, 15, 16, 17, 18, |
634 | 12, 32, 31, 32, 16, 17, 39, 19, 20, 21, | 629 | 19, 20, 21, 22, 23, 30, 25, 30, 30, 0, |
635 | 22, 23, 24, 25, 26, 27, 55, 56, 32, 58, | 630 | 1, 30, 3, 4, 5, 6, 7, 8, 9, 10, |
636 | 32, 56, 12, 58, 36, 37, 16, 17, 18, 19, | 631 | 11, 30, 30, 14, 15, 16, 30, 18, 19, 20, |
637 | 20, 21, 56, 23, 58, 32, 32, 32, 32, 32, | 632 | 21, 22, 23, 1, 25, 30, 30, 5, 6, 30, |
638 | 32, 32, 32, 32, 32, 32, 32, 32, 32, 21, | 633 | 8, 9, 10, 11, 12, 1, 14, 15, 16, 17, |
639 | 54, 33 | 634 | 18, 19, 20, 21, 14, 5, 6, 25, 8, 9, |
635 | 10, 11, 30, 30, 14, 15, 142, 143, 144, 13, | ||
636 | 25, 31, 32, 149, 28, 151, 14, 31, 32, 32, | ||
637 | 30, 67, 68, 30, 70, 161, 67, 68, 30, 70, | ||
638 | 30, 31, 32, 30, 31, 32, 30, 31, 32, 30, | ||
639 | 31, 32, 30, 30, 30, 30, 30, 30, 30, 29, | ||
640 | 40, 59, -1, 106, 66 | ||
640 | }; | 641 | }; |
641 | 642 | ||
642 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing | 643 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
643 | symbol of state STATE-NUM. */ | 644 | symbol of state STATE-NUM. */ |
644 | static const unsigned char yystos[] = | 645 | static const unsigned char yystos[] = |
645 | { | 646 | { |
646 | 0, 43, 0, 1, 3, 4, 5, 6, 7, 8, | 647 | 0, 36, 37, 0, 1, 3, 4, 5, 6, 7, |
647 | 9, 10, 11, 14, 15, 31, 32, 44, 45, 46, | 648 | 8, 9, 10, 11, 14, 15, 16, 18, 19, 20, |
648 | 47, 48, 49, 52, 53, 55, 59, 61, 63, 64, | 649 | 21, 22, 23, 25, 30, 38, 39, 41, 42, 43, |
649 | 66, 68, 69, 70, 71, 79, 79, 28, 29, 77, | 650 | 44, 47, 48, 50, 54, 56, 58, 59, 61, 63, |
650 | 77, 77, 32, 77, 28, 28, 28, 29, 34, 41, | 651 | 64, 65, 72, 30, 25, 26, 71, 71, 30, 71, |
651 | 81, 82, 50, 50, 56, 58, 62, 74, 67, 74, | 652 | 30, 30, 71, 25, 25, 25, 26, 29, 34, 75, |
652 | 79, 32, 32, 32, 32, 32, 81, 81, 32, 38, | 653 | 76, 30, 1, 1, 45, 45, 51, 53, 57, 68, |
653 | 39, 30, 40, 12, 16, 17, 19, 20, 21, 22, | 654 | 62, 68, 30, 73, 30, 30, 30, 30, 30, 75, |
654 | 23, 24, 25, 26, 27, 32, 36, 37, 51, 72, | 655 | 75, 31, 32, 73, 27, 33, 30, 30, 1, 12, |
655 | 73, 75, 18, 19, 20, 21, 23, 32, 57, 73, | 656 | 16, 17, 19, 20, 21, 22, 23, 25, 30, 40, |
656 | 75, 5, 8, 15, 45, 54, 78, 45, 55, 60, | 657 | 46, 66, 67, 69, 18, 19, 20, 21, 30, 40, |
657 | 66, 78, 32, 75, 1, 45, 55, 65, 66, 78, | 658 | 52, 67, 69, 39, 49, 72, 39, 50, 55, 61, |
658 | 33, 81, 81, 82, 82, 32, 35, 81, 81, 77, | 659 | 72, 30, 40, 69, 39, 50, 60, 61, 72, 30, |
659 | 81, 76, 77, 81, 76, 81, 76, 76, 76, 28, | 660 | 28, 75, 75, 76, 76, 30, 30, 24, 75, 75, |
660 | 82, 13, 32, 77, 28, 76, 76, 79, 79, 79, | 661 | 71, 70, 71, 75, 25, 76, 1, 13, 30, 71, |
661 | 32, 81, 32, 32, 14, 80, 80, 32, 80, 80, | 662 | 70, 25, 75, 30, 30, 14, 74, 30, 74, 74, |
662 | 32, 80, 32, 32, 32, 80, 82, 80, 80, 32, | 663 | 74, 76, 30, 74, 30, 74, 30, 75, 30, 30, |
663 | 32, 32, 81, 32, 32, 32, 32, 32, 80, 32, | 664 | 30, 74, 30, 30, 30 |
664 | 32, 32 | ||
665 | }; | 665 | }; |
666 | 666 | ||
667 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) | 667 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) |
@@ -687,7 +687,7 @@ static const unsigned char yystos[] = | |||
687 | 687 | ||
688 | #define YYACCEPT goto yyacceptlab | 688 | #define YYACCEPT goto yyacceptlab |
689 | #define YYABORT goto yyabortlab | 689 | #define YYABORT goto yyabortlab |
690 | #define YYERROR goto yyerrlab1 | 690 | #define YYERROR goto yyerrorlab |
691 | 691 | ||
692 | 692 | ||
693 | /* Like YYERROR except do call yyerror. This remains here temporarily | 693 | /* Like YYERROR except do call yyerror. This remains here temporarily |
@@ -709,26 +709,59 @@ do \ | |||
709 | goto yybackup; \ | 709 | goto yybackup; \ |
710 | } \ | 710 | } \ |
711 | else \ | 711 | else \ |
712 | { \ | 712 | { \ |
713 | yyerror ("syntax error: cannot back up");\ | 713 | yyerror ("syntax error: cannot back up");\ |
714 | YYERROR; \ | 714 | YYERROR; \ |
715 | } \ | 715 | } \ |
716 | while (0) | 716 | while (0) |
717 | 717 | ||
718 | |||
718 | #define YYTERROR 1 | 719 | #define YYTERROR 1 |
719 | #define YYERRCODE 256 | 720 | #define YYERRCODE 256 |
720 | 721 | ||
721 | /* YYLLOC_DEFAULT -- Compute the default location (before the actions | ||
722 | are run). */ | ||
723 | 722 | ||
723 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. | ||
724 | If N is 0, then set CURRENT to the empty location which ends | ||
725 | the previous symbol: RHS[0] (always defined). */ | ||
726 | |||
727 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) | ||
724 | #ifndef YYLLOC_DEFAULT | 728 | #ifndef YYLLOC_DEFAULT |
725 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ | 729 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
726 | Current.first_line = Rhs[1].first_line; \ | 730 | do \ |
727 | Current.first_column = Rhs[1].first_column; \ | 731 | if (N) \ |
728 | Current.last_line = Rhs[N].last_line; \ | 732 | { \ |
729 | Current.last_column = Rhs[N].last_column; | 733 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
734 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ | ||
735 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ | ||
736 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ | ||
737 | } \ | ||
738 | else \ | ||
739 | { \ | ||
740 | (Current).first_line = (Current).last_line = \ | ||
741 | YYRHSLOC (Rhs, 0).last_line; \ | ||
742 | (Current).first_column = (Current).last_column = \ | ||
743 | YYRHSLOC (Rhs, 0).last_column; \ | ||
744 | } \ | ||
745 | while (0) | ||
730 | #endif | 746 | #endif |
731 | 747 | ||
748 | |||
749 | /* YY_LOCATION_PRINT -- Print the location on the stream. | ||
750 | This macro was not mandated originally: define only if we know | ||
751 | we won't break user code: when these are the locations we know. */ | ||
752 | |||
753 | #ifndef YY_LOCATION_PRINT | ||
754 | # if YYLTYPE_IS_TRIVIAL | ||
755 | # define YY_LOCATION_PRINT(File, Loc) \ | ||
756 | fprintf (File, "%d.%d-%d.%d", \ | ||
757 | (Loc).first_line, (Loc).first_column, \ | ||
758 | (Loc).last_line, (Loc).last_column) | ||
759 | # else | ||
760 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) | ||
761 | # endif | ||
762 | #endif | ||
763 | |||
764 | |||
732 | /* YYLEX -- calling `yylex' with the right arguments. */ | 765 | /* YYLEX -- calling `yylex' with the right arguments. */ |
733 | 766 | ||
734 | #ifdef YYLEX_PARAM | 767 | #ifdef YYLEX_PARAM |
@@ -751,36 +784,30 @@ do { \ | |||
751 | YYFPRINTF Args; \ | 784 | YYFPRINTF Args; \ |
752 | } while (0) | 785 | } while (0) |
753 | 786 | ||
754 | # define YYDSYMPRINT(Args) \ | 787 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
755 | do { \ | ||
756 | if (yydebug) \ | ||
757 | yysymprint Args; \ | ||
758 | } while (0) | ||
759 | |||
760 | # define YYDSYMPRINTF(Title, Token, Value, Location) \ | ||
761 | do { \ | 788 | do { \ |
762 | if (yydebug) \ | 789 | if (yydebug) \ |
763 | { \ | 790 | { \ |
764 | YYFPRINTF (stderr, "%s ", Title); \ | 791 | YYFPRINTF (stderr, "%s ", Title); \ |
765 | yysymprint (stderr, \ | 792 | yysymprint (stderr, \ |
766 | Token, Value); \ | 793 | Type, Value); \ |
767 | YYFPRINTF (stderr, "\n"); \ | 794 | YYFPRINTF (stderr, "\n"); \ |
768 | } \ | 795 | } \ |
769 | } while (0) | 796 | } while (0) |
770 | 797 | ||
771 | /*------------------------------------------------------------------. | 798 | /*------------------------------------------------------------------. |
772 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | | 799 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
773 | | TOP (cinluded). | | 800 | | TOP (included). | |
774 | `------------------------------------------------------------------*/ | 801 | `------------------------------------------------------------------*/ |
775 | 802 | ||
776 | #if defined (__STDC__) || defined (__cplusplus) | 803 | #if defined (__STDC__) || defined (__cplusplus) |
777 | static void | 804 | static void |
778 | yy_stack_print (short *bottom, short *top) | 805 | yy_stack_print (short int *bottom, short int *top) |
779 | #else | 806 | #else |
780 | static void | 807 | static void |
781 | yy_stack_print (bottom, top) | 808 | yy_stack_print (bottom, top) |
782 | short *bottom; | 809 | short int *bottom; |
783 | short *top; | 810 | short int *top; |
784 | #endif | 811 | #endif |
785 | { | 812 | { |
786 | YYFPRINTF (stderr, "Stack now"); | 813 | YYFPRINTF (stderr, "Stack now"); |
@@ -810,9 +837,9 @@ yy_reduce_print (yyrule) | |||
810 | #endif | 837 | #endif |
811 | { | 838 | { |
812 | int yyi; | 839 | int yyi; |
813 | unsigned int yylineno = yyrline[yyrule]; | 840 | unsigned int yylno = yyrline[yyrule]; |
814 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", | 841 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", |
815 | yyrule - 1, yylineno); | 842 | yyrule - 1, yylno); |
816 | /* Print the symbols being reduced, and their result. */ | 843 | /* Print the symbols being reduced, and their result. */ |
817 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) | 844 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
818 | YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); | 845 | YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); |
@@ -830,8 +857,7 @@ do { \ | |||
830 | int yydebug; | 857 | int yydebug; |
831 | #else /* !YYDEBUG */ | 858 | #else /* !YYDEBUG */ |
832 | # define YYDPRINTF(Args) | 859 | # define YYDPRINTF(Args) |
833 | # define YYDSYMPRINT(Args) | 860 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
834 | # define YYDSYMPRINTF(Title, Token, Value, Location) | ||
835 | # define YY_STACK_PRINT(Bottom, Top) | 861 | # define YY_STACK_PRINT(Bottom, Top) |
836 | # define YY_REDUCE_PRINT(Rule) | 862 | # define YY_REDUCE_PRINT(Rule) |
837 | #endif /* !YYDEBUG */ | 863 | #endif /* !YYDEBUG */ |
@@ -849,10 +875,6 @@ int yydebug; | |||
849 | SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) | 875 | SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) |
850 | evaluated with infinite-precision integer arithmetic. */ | 876 | evaluated with infinite-precision integer arithmetic. */ |
851 | 877 | ||
852 | #if YYMAXDEPTH == 0 | ||
853 | # undef YYMAXDEPTH | ||
854 | #endif | ||
855 | |||
856 | #ifndef YYMAXDEPTH | 878 | #ifndef YYMAXDEPTH |
857 | # define YYMAXDEPTH 10000 | 879 | # define YYMAXDEPTH 10000 |
858 | #endif | 880 | #endif |
@@ -934,15 +956,15 @@ yysymprint (yyoutput, yytype, yyvaluep) | |||
934 | (void) yyvaluep; | 956 | (void) yyvaluep; |
935 | 957 | ||
936 | if (yytype < YYNTOKENS) | 958 | if (yytype < YYNTOKENS) |
937 | { | 959 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
938 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); | ||
939 | # ifdef YYPRINT | ||
940 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | ||
941 | # endif | ||
942 | } | ||
943 | else | 960 | else |
944 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); | 961 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
945 | 962 | ||
963 | |||
964 | # ifdef YYPRINT | ||
965 | if (yytype < YYNTOKENS) | ||
966 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | ||
967 | # endif | ||
946 | switch (yytype) | 968 | switch (yytype) |
947 | { | 969 | { |
948 | default: | 970 | default: |
@@ -958,10 +980,11 @@ yysymprint (yyoutput, yytype, yyvaluep) | |||
958 | 980 | ||
959 | #if defined (__STDC__) || defined (__cplusplus) | 981 | #if defined (__STDC__) || defined (__cplusplus) |
960 | static void | 982 | static void |
961 | yydestruct (int yytype, YYSTYPE *yyvaluep) | 983 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
962 | #else | 984 | #else |
963 | static void | 985 | static void |
964 | yydestruct (yytype, yyvaluep) | 986 | yydestruct (yymsg, yytype, yyvaluep) |
987 | const char *yymsg; | ||
965 | int yytype; | 988 | int yytype; |
966 | YYSTYPE *yyvaluep; | 989 | YYSTYPE *yyvaluep; |
967 | #endif | 990 | #endif |
@@ -969,8 +992,42 @@ yydestruct (yytype, yyvaluep) | |||
969 | /* Pacify ``unused variable'' warnings. */ | 992 | /* Pacify ``unused variable'' warnings. */ |
970 | (void) yyvaluep; | 993 | (void) yyvaluep; |
971 | 994 | ||
995 | if (!yymsg) | ||
996 | yymsg = "Deleting"; | ||
997 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); | ||
998 | |||
972 | switch (yytype) | 999 | switch (yytype) |
973 | { | 1000 | { |
1001 | case 48: /* choice_entry */ | ||
1002 | |||
1003 | { | ||
1004 | fprintf(stderr, "%s:%d: missing end statement for this entry\n", | ||
1005 | (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno); | ||
1006 | if (current_menu == (yyvaluep->menu)) | ||
1007 | menu_end_menu(); | ||
1008 | }; | ||
1009 | |||
1010 | break; | ||
1011 | case 54: /* if_entry */ | ||
1012 | |||
1013 | { | ||
1014 | fprintf(stderr, "%s:%d: missing end statement for this entry\n", | ||
1015 | (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno); | ||
1016 | if (current_menu == (yyvaluep->menu)) | ||
1017 | menu_end_menu(); | ||
1018 | }; | ||
1019 | |||
1020 | break; | ||
1021 | case 59: /* menu_entry */ | ||
1022 | |||
1023 | { | ||
1024 | fprintf(stderr, "%s:%d: missing end statement for this entry\n", | ||
1025 | (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno); | ||
1026 | if (current_menu == (yyvaluep->menu)) | ||
1027 | menu_end_menu(); | ||
1028 | }; | ||
1029 | |||
1030 | break; | ||
974 | 1031 | ||
975 | default: | 1032 | default: |
976 | break; | 1033 | break; |
@@ -996,10 +1053,10 @@ int yyparse (); | |||
996 | 1053 | ||
997 | 1054 | ||
998 | 1055 | ||
999 | /* The lookahead symbol. */ | 1056 | /* The look-ahead symbol. */ |
1000 | int yychar; | 1057 | int yychar; |
1001 | 1058 | ||
1002 | /* The semantic value of the lookahead symbol. */ | 1059 | /* The semantic value of the look-ahead symbol. */ |
1003 | YYSTYPE yylval; | 1060 | YYSTYPE yylval; |
1004 | 1061 | ||
1005 | /* Number of syntax errors so far. */ | 1062 | /* Number of syntax errors so far. */ |
@@ -1029,13 +1086,13 @@ yyparse () | |||
1029 | #endif | 1086 | #endif |
1030 | #endif | 1087 | #endif |
1031 | { | 1088 | { |
1032 | 1089 | ||
1033 | register int yystate; | 1090 | register int yystate; |
1034 | register int yyn; | 1091 | register int yyn; |
1035 | int yyresult; | 1092 | int yyresult; |
1036 | /* Number of tokens to shift before error messages enabled. */ | 1093 | /* Number of tokens to shift before error messages enabled. */ |
1037 | int yyerrstatus; | 1094 | int yyerrstatus; |
1038 | /* Lookahead token as an internal (translated) token number. */ | 1095 | /* Look-ahead token as an internal (translated) token number. */ |
1039 | int yytoken = 0; | 1096 | int yytoken = 0; |
1040 | 1097 | ||
1041 | /* Three stacks and their tools: | 1098 | /* Three stacks and their tools: |
@@ -1047,9 +1104,9 @@ yyparse () | |||
1047 | to reallocate them elsewhere. */ | 1104 | to reallocate them elsewhere. */ |
1048 | 1105 | ||
1049 | /* The state stack. */ | 1106 | /* The state stack. */ |
1050 | short yyssa[YYINITDEPTH]; | 1107 | short int yyssa[YYINITDEPTH]; |
1051 | short *yyss = yyssa; | 1108 | short int *yyss = yyssa; |
1052 | register short *yyssp; | 1109 | register short int *yyssp; |
1053 | 1110 | ||
1054 | /* The semantic value stack. */ | 1111 | /* The semantic value stack. */ |
1055 | YYSTYPE yyvsa[YYINITDEPTH]; | 1112 | YYSTYPE yyvsa[YYINITDEPTH]; |
@@ -1086,6 +1143,9 @@ yyparse () | |||
1086 | yyssp = yyss; | 1143 | yyssp = yyss; |
1087 | yyvsp = yyvs; | 1144 | yyvsp = yyvs; |
1088 | 1145 | ||
1146 | |||
1147 | yyvsp[0] = yylval; | ||
1148 | |||
1089 | goto yysetstate; | 1149 | goto yysetstate; |
1090 | 1150 | ||
1091 | /*------------------------------------------------------------. | 1151 | /*------------------------------------------------------------. |
@@ -1111,7 +1171,7 @@ yyparse () | |||
1111 | these so that the &'s don't force the real ones into | 1171 | these so that the &'s don't force the real ones into |
1112 | memory. */ | 1172 | memory. */ |
1113 | YYSTYPE *yyvs1 = yyvs; | 1173 | YYSTYPE *yyvs1 = yyvs; |
1114 | short *yyss1 = yyss; | 1174 | short int *yyss1 = yyss; |
1115 | 1175 | ||
1116 | 1176 | ||
1117 | /* Each stack pointer address is followed by the size of the | 1177 | /* Each stack pointer address is followed by the size of the |
@@ -1139,7 +1199,7 @@ yyparse () | |||
1139 | yystacksize = YYMAXDEPTH; | 1199 | yystacksize = YYMAXDEPTH; |
1140 | 1200 | ||
1141 | { | 1201 | { |
1142 | short *yyss1 = yyss; | 1202 | short int *yyss1 = yyss; |
1143 | union yyalloc *yyptr = | 1203 | union yyalloc *yyptr = |
1144 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); | 1204 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
1145 | if (! yyptr) | 1205 | if (! yyptr) |
@@ -1175,18 +1235,18 @@ yyparse () | |||
1175 | yybackup: | 1235 | yybackup: |
1176 | 1236 | ||
1177 | /* Do appropriate processing given the current state. */ | 1237 | /* Do appropriate processing given the current state. */ |
1178 | /* Read a lookahead token if we need one and don't already have one. */ | 1238 | /* Read a look-ahead token if we need one and don't already have one. */ |
1179 | /* yyresume: */ | 1239 | /* yyresume: */ |
1180 | 1240 | ||
1181 | /* First try to decide what to do without reference to lookahead token. */ | 1241 | /* First try to decide what to do without reference to look-ahead token. */ |
1182 | 1242 | ||
1183 | yyn = yypact[yystate]; | 1243 | yyn = yypact[yystate]; |
1184 | if (yyn == YYPACT_NINF) | 1244 | if (yyn == YYPACT_NINF) |
1185 | goto yydefault; | 1245 | goto yydefault; |
1186 | 1246 | ||
1187 | /* Not known => get a lookahead token if don't already have one. */ | 1247 | /* Not known => get a look-ahead token if don't already have one. */ |
1188 | 1248 | ||
1189 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ | 1249 | /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ |
1190 | if (yychar == YYEMPTY) | 1250 | if (yychar == YYEMPTY) |
1191 | { | 1251 | { |
1192 | YYDPRINTF ((stderr, "Reading a token: ")); | 1252 | YYDPRINTF ((stderr, "Reading a token: ")); |
@@ -1201,7 +1261,7 @@ yybackup: | |||
1201 | else | 1261 | else |
1202 | { | 1262 | { |
1203 | yytoken = YYTRANSLATE (yychar); | 1263 | yytoken = YYTRANSLATE (yychar); |
1204 | YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); | 1264 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
1205 | } | 1265 | } |
1206 | 1266 | ||
1207 | /* If the proper action on seeing token YYTOKEN is to reduce or to | 1267 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
@@ -1221,8 +1281,8 @@ yybackup: | |||
1221 | if (yyn == YYFINAL) | 1281 | if (yyn == YYFINAL) |
1222 | YYACCEPT; | 1282 | YYACCEPT; |
1223 | 1283 | ||
1224 | /* Shift the lookahead token. */ | 1284 | /* Shift the look-ahead token. */ |
1225 | YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); | 1285 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
1226 | 1286 | ||
1227 | /* Discard the token being shifted unless it is eof. */ | 1287 | /* Discard the token being shifted unless it is eof. */ |
1228 | if (yychar != YYEOF) | 1288 | if (yychar != YYEOF) |
@@ -1273,155 +1333,123 @@ yyreduce: | |||
1273 | { | 1333 | { |
1274 | case 8: | 1334 | case 8: |
1275 | 1335 | ||
1276 | { zconfprint("unexpected 'endmenu' statement"); ;} | 1336 | { zconf_error("unexpected end statement"); ;} |
1277 | break; | 1337 | break; |
1278 | 1338 | ||
1279 | case 9: | 1339 | case 9: |
1280 | 1340 | ||
1281 | { zconfprint("unexpected 'endif' statement"); ;} | 1341 | { zconf_error("unknown statement \"%s\"", (yyvsp[-2].string)); ;} |
1282 | break; | 1342 | break; |
1283 | 1343 | ||
1284 | case 10: | 1344 | case 10: |
1285 | 1345 | ||
1286 | { zconfprint("unexpected 'endchoice' statement"); ;} | 1346 | { |
1347 | zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[-2].id)->name); | ||
1348 | ;} | ||
1287 | break; | 1349 | break; |
1288 | 1350 | ||
1289 | case 11: | 1351 | case 11: |
1290 | 1352 | ||
1291 | { zconfprint("syntax error"); yyerrok; ;} | 1353 | { zconf_error("invalid statement"); ;} |
1292 | break; | 1354 | break; |
1293 | 1355 | ||
1294 | case 18: | 1356 | case 25: |
1295 | 1357 | ||
1296 | { | 1358 | { zconf_error("unknown option \"%s\"", (yyvsp[-2].string)); ;} |
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; | 1359 | break; |
1303 | 1360 | ||
1304 | case 19: | 1361 | case 26: |
1305 | 1362 | ||
1306 | { | 1363 | { zconf_error("invalid option"); ;} |
1307 | menu_end_entry(); | ||
1308 | printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); | ||
1309 | ;} | ||
1310 | break; | 1364 | break; |
1311 | 1365 | ||
1312 | case 20: | 1366 | case 27: |
1313 | 1367 | ||
1314 | { | 1368 | { |
1315 | struct symbol *sym = sym_lookup(yyvsp[-1].string, 0); | 1369 | struct symbol *sym = sym_lookup((yyvsp[-1].string), 0); |
1316 | sym->flags |= SYMBOL_OPTIONAL; | 1370 | sym->flags |= SYMBOL_OPTIONAL; |
1317 | menu_add_entry(sym); | 1371 | menu_add_entry(sym); |
1318 | printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); | 1372 | printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string)); |
1319 | ;} | 1373 | ;} |
1320 | break; | 1374 | break; |
1321 | 1375 | ||
1322 | case 21: | 1376 | case 28: |
1323 | 1377 | ||
1324 | { | 1378 | { |
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(); | 1379 | menu_end_entry(); |
1330 | printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); | 1380 | printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); |
1331 | ;} | 1381 | ;} |
1332 | break; | 1382 | break; |
1333 | 1383 | ||
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: | 1384 | case 29: |
1352 | 1385 | ||
1353 | { | 1386 | { |
1354 | menu_set_type(S_BOOLEAN); | 1387 | struct symbol *sym = sym_lookup((yyvsp[-1].string), 0); |
1355 | printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); | 1388 | sym->flags |= SYMBOL_OPTIONAL; |
1389 | menu_add_entry(sym); | ||
1390 | printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string)); | ||
1356 | ;} | 1391 | ;} |
1357 | break; | 1392 | break; |
1358 | 1393 | ||
1359 | case 30: | 1394 | case 30: |
1360 | 1395 | ||
1361 | { | 1396 | { |
1362 | menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); | 1397 | if (current_entry->prompt) |
1363 | menu_set_type(S_BOOLEAN); | 1398 | current_entry->prompt->type = P_MENU; |
1364 | printd(DEBUG_PARSE, "%s:%d:def_boolean\n", zconf_curname(), zconf_lineno()); | 1399 | else |
1365 | ;} | 1400 | zconfprint("warning: menuconfig statement without prompt"); |
1366 | break; | 1401 | menu_end_entry(); |
1367 | 1402 | printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); | |
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 | ;} | 1403 | ;} |
1382 | break; | 1404 | break; |
1383 | 1405 | ||
1384 | case 33: | 1406 | case 37: |
1385 | 1407 | ||
1386 | { | 1408 | { |
1387 | menu_set_type(S_STRING); | 1409 | menu_set_type((yyvsp[-2].id)->stype); |
1388 | printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno()); | 1410 | printd(DEBUG_PARSE, "%s:%d:type(%u)\n", |
1411 | zconf_curname(), zconf_lineno(), | ||
1412 | (yyvsp[-2].id)->stype); | ||
1389 | ;} | 1413 | ;} |
1390 | break; | 1414 | break; |
1391 | 1415 | ||
1392 | case 34: | 1416 | case 38: |
1393 | 1417 | ||
1394 | { | 1418 | { |
1395 | menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr); | 1419 | menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr)); |
1396 | printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); | 1420 | printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); |
1397 | ;} | 1421 | ;} |
1398 | break; | 1422 | break; |
1399 | 1423 | ||
1400 | case 35: | 1424 | case 39: |
1401 | 1425 | ||
1402 | { | 1426 | { |
1403 | menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr); | 1427 | menu_add_expr(P_DEFAULT, (yyvsp[-2].expr), (yyvsp[-1].expr)); |
1404 | printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); | 1428 | if ((yyvsp[-3].id)->stype != S_UNKNOWN) |
1429 | menu_set_type((yyvsp[-3].id)->stype); | ||
1430 | printd(DEBUG_PARSE, "%s:%d:default(%u)\n", | ||
1431 | zconf_curname(), zconf_lineno(), | ||
1432 | (yyvsp[-3].id)->stype); | ||
1405 | ;} | 1433 | ;} |
1406 | break; | 1434 | break; |
1407 | 1435 | ||
1408 | case 36: | 1436 | case 40: |
1409 | 1437 | ||
1410 | { | 1438 | { |
1411 | menu_add_symbol(P_SELECT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr); | 1439 | 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()); | 1440 | printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); |
1413 | ;} | 1441 | ;} |
1414 | break; | 1442 | break; |
1415 | 1443 | ||
1416 | case 37: | 1444 | case 41: |
1417 | 1445 | ||
1418 | { | 1446 | { |
1419 | menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,yyvsp[-3].symbol, yyvsp[-2].symbol), yyvsp[-1].expr); | 1447 | 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()); | 1448 | printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); |
1421 | ;} | 1449 | ;} |
1422 | break; | 1450 | break; |
1423 | 1451 | ||
1424 | case 38: | 1452 | case 42: |
1425 | 1453 | ||
1426 | { | 1454 | { |
1427 | struct symbol *sym = sym_lookup(NULL, 0); | 1455 | struct symbol *sym = sym_lookup(NULL, 0); |
@@ -1432,57 +1460,45 @@ yyreduce: | |||
1432 | ;} | 1460 | ;} |
1433 | break; | 1461 | break; |
1434 | 1462 | ||
1435 | case 39: | 1463 | case 43: |
1436 | 1464 | ||
1437 | { | 1465 | { |
1438 | menu_end_entry(); | 1466 | (yyval.menu) = menu_add_menu(); |
1439 | menu_add_menu(); | ||
1440 | ;} | 1467 | ;} |
1441 | break; | 1468 | break; |
1442 | 1469 | ||
1443 | case 40: | 1470 | case 44: |
1444 | 1471 | ||
1445 | { | 1472 | { |
1446 | if (zconf_endtoken(yyvsp[0].token, T_CHOICE, T_ENDCHOICE)) { | 1473 | if (zconf_endtoken((yyvsp[0].id), T_CHOICE, T_ENDCHOICE)) { |
1447 | menu_end_menu(); | 1474 | menu_end_menu(); |
1448 | printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); | 1475 | printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); |
1449 | } | 1476 | } |
1450 | ;} | 1477 | ;} |
1451 | break; | 1478 | break; |
1452 | 1479 | ||
1453 | case 42: | 1480 | case 52: |
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 | 1481 | ||
1463 | { | 1482 | { |
1464 | menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr); | 1483 | menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr)); |
1465 | printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); | 1484 | printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); |
1466 | ;} | 1485 | ;} |
1467 | break; | 1486 | break; |
1468 | 1487 | ||
1469 | case 49: | 1488 | case 53: |
1470 | 1489 | ||
1471 | { | 1490 | { |
1472 | menu_set_type(S_TRISTATE); | 1491 | if ((yyvsp[-2].id)->stype == S_BOOLEAN || (yyvsp[-2].id)->stype == S_TRISTATE) { |
1473 | printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); | 1492 | menu_set_type((yyvsp[-2].id)->stype); |
1493 | printd(DEBUG_PARSE, "%s:%d:type(%u)\n", | ||
1494 | zconf_curname(), zconf_lineno(), | ||
1495 | (yyvsp[-2].id)->stype); | ||
1496 | } else | ||
1497 | YYERROR; | ||
1474 | ;} | 1498 | ;} |
1475 | break; | 1499 | break; |
1476 | 1500 | ||
1477 | case 50: | 1501 | case 54: |
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 | 1502 | ||
1487 | { | 1503 | { |
1488 | current_entry->sym->flags |= SYMBOL_OPTIONAL; | 1504 | current_entry->sym->flags |= SYMBOL_OPTIONAL; |
@@ -1490,115 +1506,89 @@ yyreduce: | |||
1490 | ;} | 1506 | ;} |
1491 | break; | 1507 | break; |
1492 | 1508 | ||
1493 | case 52: | 1509 | case 55: |
1494 | 1510 | ||
1495 | { | 1511 | { |
1496 | menu_add_symbol(P_DEFAULT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr); | 1512 | if ((yyvsp[-3].id)->stype == S_UNKNOWN) { |
1497 | printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); | 1513 | menu_add_symbol(P_DEFAULT, sym_lookup((yyvsp[-2].string), 0), (yyvsp[-1].expr)); |
1514 | printd(DEBUG_PARSE, "%s:%d:default\n", | ||
1515 | zconf_curname(), zconf_lineno()); | ||
1516 | } else | ||
1517 | YYERROR; | ||
1498 | ;} | 1518 | ;} |
1499 | break; | 1519 | break; |
1500 | 1520 | ||
1501 | case 55: | 1521 | case 58: |
1502 | 1522 | ||
1503 | { | 1523 | { |
1504 | printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); | 1524 | printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); |
1505 | menu_add_entry(NULL); | 1525 | menu_add_entry(NULL); |
1506 | menu_add_dep(yyvsp[-1].expr); | 1526 | menu_add_dep((yyvsp[-1].expr)); |
1507 | menu_end_entry(); | 1527 | (yyval.menu) = menu_add_menu(); |
1508 | menu_add_menu(); | ||
1509 | ;} | 1528 | ;} |
1510 | break; | 1529 | break; |
1511 | 1530 | ||
1512 | case 56: | 1531 | case 59: |
1513 | 1532 | ||
1514 | { | 1533 | { |
1515 | if (zconf_endtoken(yyvsp[0].token, T_IF, T_ENDIF)) { | 1534 | if (zconf_endtoken((yyvsp[0].id), T_IF, T_ENDIF)) { |
1516 | menu_end_menu(); | 1535 | menu_end_menu(); |
1517 | printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); | 1536 | printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); |
1518 | } | 1537 | } |
1519 | ;} | 1538 | ;} |
1520 | break; | 1539 | break; |
1521 | 1540 | ||
1522 | case 58: | 1541 | case 65: |
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 | 1542 | ||
1532 | { | 1543 | { |
1533 | menu_add_entry(NULL); | 1544 | menu_add_entry(NULL); |
1534 | menu_add_prop(P_MENU, yyvsp[-1].string, NULL, NULL); | 1545 | menu_add_prompt(P_MENU, (yyvsp[-1].string), NULL); |
1535 | printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); | 1546 | printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); |
1536 | ;} | 1547 | ;} |
1537 | break; | 1548 | break; |
1538 | 1549 | ||
1539 | case 64: | 1550 | case 66: |
1540 | 1551 | ||
1541 | { | 1552 | { |
1542 | menu_end_entry(); | 1553 | (yyval.menu) = menu_add_menu(); |
1543 | menu_add_menu(); | ||
1544 | ;} | 1554 | ;} |
1545 | break; | 1555 | break; |
1546 | 1556 | ||
1547 | case 65: | 1557 | case 67: |
1548 | 1558 | ||
1549 | { | 1559 | { |
1550 | if (zconf_endtoken(yyvsp[0].token, T_MENU, T_ENDMENU)) { | 1560 | if (zconf_endtoken((yyvsp[0].id), T_MENU, T_ENDMENU)) { |
1551 | menu_end_menu(); | 1561 | menu_end_menu(); |
1552 | printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); | 1562 | printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); |
1553 | } | 1563 | } |
1554 | ;} | 1564 | ;} |
1555 | break; | 1565 | break; |
1556 | 1566 | ||
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: | 1567 | case 73: |
1571 | 1568 | ||
1572 | { | 1569 | { |
1573 | yyval.string = yyvsp[-1].string; | 1570 | printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string)); |
1574 | printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string); | 1571 | zconf_nextfile((yyvsp[-1].string)); |
1575 | ;} | 1572 | ;} |
1576 | break; | 1573 | break; |
1577 | 1574 | ||
1578 | case 74: | 1575 | case 74: |
1579 | 1576 | ||
1580 | { | 1577 | { |
1581 | zconf_nextfile(yyvsp[0].string); | ||
1582 | ;} | ||
1583 | break; | ||
1584 | |||
1585 | case 75: | ||
1586 | |||
1587 | { | ||
1588 | menu_add_entry(NULL); | 1578 | menu_add_entry(NULL); |
1589 | menu_add_prop(P_COMMENT, yyvsp[-1].string, NULL, NULL); | 1579 | menu_add_prompt(P_COMMENT, (yyvsp[-1].string), NULL); |
1590 | printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); | 1580 | printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); |
1591 | ;} | 1581 | ;} |
1592 | break; | 1582 | break; |
1593 | 1583 | ||
1594 | case 76: | 1584 | case 75: |
1595 | 1585 | ||
1596 | { | 1586 | { |
1597 | menu_end_entry(); | 1587 | menu_end_entry(); |
1598 | ;} | 1588 | ;} |
1599 | break; | 1589 | break; |
1600 | 1590 | ||
1601 | case 77: | 1591 | case 76: |
1602 | 1592 | ||
1603 | { | 1593 | { |
1604 | printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); | 1594 | printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); |
@@ -1606,17 +1596,17 @@ yyreduce: | |||
1606 | ;} | 1596 | ;} |
1607 | break; | 1597 | break; |
1608 | 1598 | ||
1609 | case 78: | 1599 | case 77: |
1610 | 1600 | ||
1611 | { | 1601 | { |
1612 | current_entry->sym->help = yyvsp[0].string; | 1602 | current_entry->sym->help = (yyvsp[0].string); |
1613 | ;} | 1603 | ;} |
1614 | break; | 1604 | break; |
1615 | 1605 | ||
1616 | case 82: | 1606 | case 82: |
1617 | 1607 | ||
1618 | { | 1608 | { |
1619 | menu_add_dep(yyvsp[-1].expr); | 1609 | menu_add_dep((yyvsp[-1].expr)); |
1620 | printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); | 1610 | printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); |
1621 | ;} | 1611 | ;} |
1622 | break; | 1612 | break; |
@@ -1624,7 +1614,7 @@ yyreduce: | |||
1624 | case 83: | 1614 | case 83: |
1625 | 1615 | ||
1626 | { | 1616 | { |
1627 | menu_add_dep(yyvsp[-1].expr); | 1617 | menu_add_dep((yyvsp[-1].expr)); |
1628 | printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); | 1618 | printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno()); |
1629 | ;} | 1619 | ;} |
1630 | break; | 1620 | break; |
@@ -1632,7 +1622,7 @@ yyreduce: | |||
1632 | case 84: | 1622 | case 84: |
1633 | 1623 | ||
1634 | { | 1624 | { |
1635 | menu_add_dep(yyvsp[-1].expr); | 1625 | menu_add_dep((yyvsp[-1].expr)); |
1636 | printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); | 1626 | printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno()); |
1637 | ;} | 1627 | ;} |
1638 | break; | 1628 | break; |
@@ -1640,84 +1630,84 @@ yyreduce: | |||
1640 | case 86: | 1630 | case 86: |
1641 | 1631 | ||
1642 | { | 1632 | { |
1643 | menu_add_prop(P_PROMPT, yyvsp[-1].string, NULL, yyvsp[0].expr); | 1633 | menu_add_prompt(P_PROMPT, (yyvsp[-1].string), (yyvsp[0].expr)); |
1644 | ;} | 1634 | ;} |
1645 | break; | 1635 | break; |
1646 | 1636 | ||
1647 | case 89: | 1637 | case 89: |
1648 | 1638 | ||
1649 | { yyval.token = T_ENDMENU; ;} | 1639 | { (yyval.id) = (yyvsp[-1].id); ;} |
1650 | break; | 1640 | break; |
1651 | 1641 | ||
1652 | case 90: | 1642 | case 90: |
1653 | 1643 | ||
1654 | { yyval.token = T_ENDCHOICE; ;} | 1644 | { (yyval.id) = (yyvsp[-1].id); ;} |
1655 | break; | 1645 | break; |
1656 | 1646 | ||
1657 | case 91: | 1647 | case 91: |
1658 | 1648 | ||
1659 | { yyval.token = T_ENDIF; ;} | 1649 | { (yyval.id) = (yyvsp[-1].id); ;} |
1660 | break; | 1650 | break; |
1661 | 1651 | ||
1662 | case 94: | 1652 | case 94: |
1663 | 1653 | ||
1664 | { yyval.expr = NULL; ;} | 1654 | { (yyval.expr) = NULL; ;} |
1665 | break; | 1655 | break; |
1666 | 1656 | ||
1667 | case 95: | 1657 | case 95: |
1668 | 1658 | ||
1669 | { yyval.expr = yyvsp[0].expr; ;} | 1659 | { (yyval.expr) = (yyvsp[0].expr); ;} |
1670 | break; | 1660 | break; |
1671 | 1661 | ||
1672 | case 96: | 1662 | case 96: |
1673 | 1663 | ||
1674 | { yyval.expr = expr_alloc_symbol(yyvsp[0].symbol); ;} | 1664 | { (yyval.expr) = expr_alloc_symbol((yyvsp[0].symbol)); ;} |
1675 | break; | 1665 | break; |
1676 | 1666 | ||
1677 | case 97: | 1667 | case 97: |
1678 | 1668 | ||
1679 | { yyval.expr = expr_alloc_comp(E_EQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;} | 1669 | { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); ;} |
1680 | break; | 1670 | break; |
1681 | 1671 | ||
1682 | case 98: | 1672 | case 98: |
1683 | 1673 | ||
1684 | { yyval.expr = expr_alloc_comp(E_UNEQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;} | 1674 | { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); ;} |
1685 | break; | 1675 | break; |
1686 | 1676 | ||
1687 | case 99: | 1677 | case 99: |
1688 | 1678 | ||
1689 | { yyval.expr = yyvsp[-1].expr; ;} | 1679 | { (yyval.expr) = (yyvsp[-1].expr); ;} |
1690 | break; | 1680 | break; |
1691 | 1681 | ||
1692 | case 100: | 1682 | case 100: |
1693 | 1683 | ||
1694 | { yyval.expr = expr_alloc_one(E_NOT, yyvsp[0].expr); ;} | 1684 | { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[0].expr)); ;} |
1695 | break; | 1685 | break; |
1696 | 1686 | ||
1697 | case 101: | 1687 | case 101: |
1698 | 1688 | ||
1699 | { yyval.expr = expr_alloc_two(E_OR, yyvsp[-2].expr, yyvsp[0].expr); ;} | 1689 | { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} |
1700 | break; | 1690 | break; |
1701 | 1691 | ||
1702 | case 102: | 1692 | case 102: |
1703 | 1693 | ||
1704 | { yyval.expr = expr_alloc_two(E_AND, yyvsp[-2].expr, yyvsp[0].expr); ;} | 1694 | { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[-2].expr), (yyvsp[0].expr)); ;} |
1705 | break; | 1695 | break; |
1706 | 1696 | ||
1707 | case 103: | 1697 | case 103: |
1708 | 1698 | ||
1709 | { yyval.symbol = sym_lookup(yyvsp[0].string, 0); free(yyvsp[0].string); ;} | 1699 | { (yyval.symbol) = sym_lookup((yyvsp[0].string), 0); free((yyvsp[0].string)); ;} |
1710 | break; | 1700 | break; |
1711 | 1701 | ||
1712 | case 104: | 1702 | case 104: |
1713 | 1703 | ||
1714 | { yyval.symbol = sym_lookup(yyvsp[0].string, 1); free(yyvsp[0].string); ;} | 1704 | { (yyval.symbol) = sym_lookup((yyvsp[0].string), 1); free((yyvsp[0].string)); ;} |
1715 | break; | 1705 | break; |
1716 | 1706 | ||
1717 | 1707 | ||
1718 | } | 1708 | } |
1719 | 1709 | ||
1720 | /* Line 999 of yacc.c. */ | 1710 | /* Line 1037 of yacc.c. */ |
1721 | 1711 | ||
1722 | 1712 | ||
1723 | yyvsp -= yylen; | 1713 | yyvsp -= yylen; |
@@ -1759,18 +1749,33 @@ yyerrlab: | |||
1759 | { | 1749 | { |
1760 | YYSIZE_T yysize = 0; | 1750 | YYSIZE_T yysize = 0; |
1761 | int yytype = YYTRANSLATE (yychar); | 1751 | int yytype = YYTRANSLATE (yychar); |
1752 | const char* yyprefix; | ||
1762 | char *yymsg; | 1753 | char *yymsg; |
1763 | int yyx, yycount; | 1754 | int yyx; |
1764 | 1755 | ||
1765 | yycount = 0; | ||
1766 | /* Start YYX at -YYN if negative to avoid negative indexes in | 1756 | /* Start YYX at -YYN if negative to avoid negative indexes in |
1767 | YYCHECK. */ | 1757 | YYCHECK. */ |
1768 | for (yyx = yyn < 0 ? -yyn : 0; | 1758 | int yyxbegin = yyn < 0 ? -yyn : 0; |
1769 | yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) | 1759 | |
1760 | /* Stay within bounds of both yycheck and yytname. */ | ||
1761 | int yychecklim = YYLAST - yyn; | ||
1762 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; | ||
1763 | int yycount = 0; | ||
1764 | |||
1765 | yyprefix = ", expecting "; | ||
1766 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) | ||
1770 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) | 1767 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
1771 | yysize += yystrlen (yytname[yyx]) + 15, yycount++; | 1768 | { |
1772 | yysize += yystrlen ("syntax error, unexpected ") + 1; | 1769 | yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); |
1773 | yysize += yystrlen (yytname[yytype]); | 1770 | yycount += 1; |
1771 | if (yycount == 5) | ||
1772 | { | ||
1773 | yysize = 0; | ||
1774 | break; | ||
1775 | } | ||
1776 | } | ||
1777 | yysize += (sizeof ("syntax error, unexpected ") | ||
1778 | + yystrlen (yytname[yytype])); | ||
1774 | yymsg = (char *) YYSTACK_ALLOC (yysize); | 1779 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
1775 | if (yymsg != 0) | 1780 | if (yymsg != 0) |
1776 | { | 1781 | { |
@@ -1779,16 +1784,13 @@ yyerrlab: | |||
1779 | 1784 | ||
1780 | if (yycount < 5) | 1785 | if (yycount < 5) |
1781 | { | 1786 | { |
1782 | yycount = 0; | 1787 | yyprefix = ", expecting "; |
1783 | for (yyx = yyn < 0 ? -yyn : 0; | 1788 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
1784 | yyx < (int) (sizeof (yytname) / sizeof (char *)); | ||
1785 | yyx++) | ||
1786 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) | 1789 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
1787 | { | 1790 | { |
1788 | const char *yyq = ! yycount ? ", expecting " : " or "; | 1791 | yyp = yystpcpy (yyp, yyprefix); |
1789 | yyp = yystpcpy (yyp, yyq); | ||
1790 | yyp = yystpcpy (yyp, yytname[yyx]); | 1792 | yyp = yystpcpy (yyp, yytname[yyx]); |
1791 | yycount++; | 1793 | yyprefix = " or "; |
1792 | } | 1794 | } |
1793 | } | 1795 | } |
1794 | yyerror (yymsg); | 1796 | yyerror (yymsg); |
@@ -1806,38 +1808,57 @@ yyerrlab: | |||
1806 | 1808 | ||
1807 | if (yyerrstatus == 3) | 1809 | if (yyerrstatus == 3) |
1808 | { | 1810 | { |
1809 | /* If just tried and failed to reuse lookahead token after an | 1811 | /* If just tried and failed to reuse look-ahead token after an |
1810 | error, discard it. */ | 1812 | error, discard it. */ |
1811 | 1813 | ||
1812 | /* Return failure if at end of input. */ | 1814 | if (yychar <= YYEOF) |
1813 | if (yychar == YYEOF) | ||
1814 | { | 1815 | { |
1815 | /* Pop the error token. */ | 1816 | /* If at end of input, pop the error token, |
1816 | YYPOPSTACK; | 1817 | then the rest of the stack, then return failure. */ |
1817 | /* Pop the rest of the stack. */ | 1818 | if (yychar == YYEOF) |
1818 | while (yyss < yyssp) | 1819 | for (;;) |
1819 | { | 1820 | { |
1820 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); | 1821 | |
1821 | yydestruct (yystos[*yyssp], yyvsp); | 1822 | YYPOPSTACK; |
1822 | YYPOPSTACK; | 1823 | if (yyssp == yyss) |
1823 | } | 1824 | YYABORT; |
1824 | YYABORT; | 1825 | yydestruct ("Error: popping", |
1826 | yystos[*yyssp], yyvsp); | ||
1827 | } | ||
1825 | } | 1828 | } |
1826 | 1829 | else | |
1827 | YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); | 1830 | { |
1828 | yydestruct (yytoken, &yylval); | 1831 | yydestruct ("Error: discarding", yytoken, &yylval); |
1829 | yychar = YYEMPTY; | 1832 | yychar = YYEMPTY; |
1830 | 1833 | } | |
1831 | } | 1834 | } |
1832 | 1835 | ||
1833 | /* Else will try to reuse lookahead token after shifting the error | 1836 | /* Else will try to reuse look-ahead token after shifting the error |
1834 | token. */ | 1837 | token. */ |
1835 | goto yyerrlab1; | 1838 | goto yyerrlab1; |
1836 | 1839 | ||
1837 | 1840 | ||
1838 | /*----------------------------------------------------. | 1841 | /*---------------------------------------------------. |
1839 | | yyerrlab1 -- error raised explicitly by an action. | | 1842 | | yyerrorlab -- error raised explicitly by YYERROR. | |
1840 | `----------------------------------------------------*/ | 1843 | `---------------------------------------------------*/ |
1844 | yyerrorlab: | ||
1845 | |||
1846 | #ifdef __GNUC__ | ||
1847 | /* Pacify GCC when the user code never invokes YYERROR and the label | ||
1848 | yyerrorlab therefore never appears in user code. */ | ||
1849 | if (0) | ||
1850 | goto yyerrorlab; | ||
1851 | #endif | ||
1852 | |||
1853 | yyvsp -= yylen; | ||
1854 | yyssp -= yylen; | ||
1855 | yystate = *yyssp; | ||
1856 | goto yyerrlab1; | ||
1857 | |||
1858 | |||
1859 | /*-------------------------------------------------------------. | ||
1860 | | yyerrlab1 -- common code for both syntax error and YYERROR. | | ||
1861 | `-------------------------------------------------------------*/ | ||
1841 | yyerrlab1: | 1862 | yyerrlab1: |
1842 | yyerrstatus = 3; /* Each real token shifted decrements this. */ | 1863 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
1843 | 1864 | ||
@@ -1859,22 +1880,22 @@ yyerrlab1: | |||
1859 | if (yyssp == yyss) | 1880 | if (yyssp == yyss) |
1860 | YYABORT; | 1881 | YYABORT; |
1861 | 1882 | ||
1862 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); | ||
1863 | yydestruct (yystos[yystate], yyvsp); | ||
1864 | yyvsp--; | ||
1865 | yystate = *--yyssp; | ||
1866 | 1883 | ||
1884 | yydestruct ("Error: popping", yystos[yystate], yyvsp); | ||
1885 | YYPOPSTACK; | ||
1886 | yystate = *yyssp; | ||
1867 | YY_STACK_PRINT (yyss, yyssp); | 1887 | YY_STACK_PRINT (yyss, yyssp); |
1868 | } | 1888 | } |
1869 | 1889 | ||
1870 | if (yyn == YYFINAL) | 1890 | if (yyn == YYFINAL) |
1871 | YYACCEPT; | 1891 | YYACCEPT; |
1872 | 1892 | ||
1873 | YYDPRINTF ((stderr, "Shifting error token, ")); | ||
1874 | |||
1875 | *++yyvsp = yylval; | 1893 | *++yyvsp = yylval; |
1876 | 1894 | ||
1877 | 1895 | ||
1896 | /* Shift the error token. */ | ||
1897 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); | ||
1898 | |||
1878 | yystate = yyn; | 1899 | yystate = yyn; |
1879 | goto yynewstate; | 1900 | goto yynewstate; |
1880 | 1901 | ||
@@ -1890,6 +1911,9 @@ yyacceptlab: | |||
1890 | | yyabortlab -- YYABORT comes here. | | 1911 | | yyabortlab -- YYABORT comes here. | |
1891 | `-----------------------------------*/ | 1912 | `-----------------------------------*/ |
1892 | yyabortlab: | 1913 | yyabortlab: |
1914 | yydestruct ("Error: discarding lookahead", | ||
1915 | yytoken, &yylval); | ||
1916 | yychar = YYEMPTY; | ||
1893 | yyresult = 1; | 1917 | yyresult = 1; |
1894 | goto yyreturn; | 1918 | goto yyreturn; |
1895 | 1919 | ||
@@ -1925,18 +1949,18 @@ void conf_parse(const char *name) | |||
1925 | sym_init(); | 1949 | sym_init(); |
1926 | menu_init(); | 1950 | menu_init(); |
1927 | modules_sym = sym_lookup("MODULES", 0); | 1951 | modules_sym = sym_lookup("MODULES", 0); |
1928 | rootmenu.prompt = menu_add_prop(P_MENU, "BusyBox Configuration", NULL, NULL); | 1952 | rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); |
1929 | 1953 | ||
1930 | //zconfdebug = 1; | 1954 | #if YYDEBUG |
1955 | if (getenv("ZCONF_DEBUG")) | ||
1956 | zconfdebug = 1; | ||
1957 | #endif | ||
1931 | zconfparse(); | 1958 | zconfparse(); |
1932 | if (zconfnerrs) | 1959 | if (zconfnerrs) |
1933 | exit(1); | 1960 | exit(1); |
1934 | menu_finalize(&rootmenu); | 1961 | menu_finalize(&rootmenu); |
1935 | for_all_symbols(i, sym) { | 1962 | for_all_symbols(i, sym) { |
1936 | if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym)) | 1963 | sym_check_deps(sym); |
1937 | printf("\n"); | ||
1938 | else | ||
1939 | sym->flags |= SYMBOL_CHECK_DONE; | ||
1940 | } | 1964 | } |
1941 | 1965 | ||
1942 | sym_change_count = 1; | 1966 | sym_change_count = 1; |
@@ -1951,20 +1975,25 @@ const char *zconf_tokenname(int token) | |||
1951 | case T_ENDCHOICE: return "endchoice"; | 1975 | case T_ENDCHOICE: return "endchoice"; |
1952 | case T_IF: return "if"; | 1976 | case T_IF: return "if"; |
1953 | case T_ENDIF: return "endif"; | 1977 | case T_ENDIF: return "endif"; |
1978 | case T_DEPENDS: return "depends"; | ||
1954 | } | 1979 | } |
1955 | return "<token>"; | 1980 | return "<token>"; |
1956 | } | 1981 | } |
1957 | 1982 | ||
1958 | static bool zconf_endtoken(int token, int starttoken, int endtoken) | 1983 | static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken) |
1959 | { | 1984 | { |
1960 | if (token != endtoken) { | 1985 | if (id->token != endtoken) { |
1961 | zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken)); | 1986 | zconf_error("unexpected '%s' within %s block", |
1987 | kconf_id_strings + id->name, zconf_tokenname(starttoken)); | ||
1962 | zconfnerrs++; | 1988 | zconfnerrs++; |
1963 | return false; | 1989 | return false; |
1964 | } | 1990 | } |
1965 | if (current_menu->file != current_file) { | 1991 | if (current_menu->file != current_file) { |
1966 | zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken)); | 1992 | zconf_error("'%s' in different file than '%s'", |
1967 | zconfprint("location of the '%s'", zconf_tokenname(starttoken)); | 1993 | kconf_id_strings + id->name, zconf_tokenname(starttoken)); |
1994 | fprintf(stderr, "%s:%d: location of the '%s'\n", | ||
1995 | current_menu->file->name, current_menu->lineno, | ||
1996 | zconf_tokenname(starttoken)); | ||
1968 | zconfnerrs++; | 1997 | zconfnerrs++; |
1969 | return false; | 1998 | return false; |
1970 | } | 1999 | } |
@@ -1975,7 +2004,19 @@ static void zconfprint(const char *err, ...) | |||
1975 | { | 2004 | { |
1976 | va_list ap; | 2005 | va_list ap; |
1977 | 2006 | ||
1978 | fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno() + 1); | 2007 | fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); |
2008 | va_start(ap, err); | ||
2009 | vfprintf(stderr, err, ap); | ||
2010 | va_end(ap); | ||
2011 | fprintf(stderr, "\n"); | ||
2012 | } | ||
2013 | |||
2014 | static void zconf_error(const char *err, ...) | ||
2015 | { | ||
2016 | va_list ap; | ||
2017 | |||
2018 | zconfnerrs++; | ||
2019 | fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); | ||
1979 | va_start(ap, err); | 2020 | va_start(ap, err); |
1980 | vfprintf(stderr, err, ap); | 2021 | vfprintf(stderr, err, ap); |
1981 | va_end(ap); | 2022 | va_end(ap); |
@@ -1984,7 +2025,9 @@ static void zconfprint(const char *err, ...) | |||
1984 | 2025 | ||
1985 | static void zconferror(const char *err) | 2026 | static void zconferror(const char *err) |
1986 | { | 2027 | { |
2028 | #if YYDEBUG | ||
1987 | fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); | 2029 | fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); |
2030 | #endif | ||
1988 | } | 2031 | } |
1989 | 2032 | ||
1990 | void print_quoted_string(FILE *out, const char *str) | 2033 | void print_quoted_string(FILE *out, const char *str) |
diff --git a/scripts/config/zconf.y b/scripts/kconfig/zconf.y index 5ebaf0a78..1f61fba6a 100644 --- a/scripts/config/zconf.y +++ b/scripts/kconfig/zconf.y | |||
@@ -11,6 +11,11 @@ | |||
11 | #include <string.h> | 11 | #include <string.h> |
12 | #include <stdbool.h> | 12 | #include <stdbool.h> |
13 | 13 | ||
14 | #define LKC_DIRECT_LINK | ||
15 | #include "lkc.h" | ||
16 | |||
17 | #include "zconf.hash.c" | ||
18 | |||
14 | #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) | 19 | #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) |
15 | 20 | ||
16 | #define PRINTD 0x0001 | 21 | #define PRINTD 0x0001 |
@@ -20,61 +25,59 @@ int cdebug = PRINTD; | |||
20 | 25 | ||
21 | extern int zconflex(void); | 26 | extern int zconflex(void); |
22 | static void zconfprint(const char *err, ...); | 27 | static void zconfprint(const char *err, ...); |
28 | static void zconf_error(const char *err, ...); | ||
23 | static void zconferror(const char *err); | 29 | static void zconferror(const char *err); |
24 | static bool zconf_endtoken(int token, int starttoken, int endtoken); | 30 | static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken); |
25 | 31 | ||
26 | struct symbol *symbol_hash[257]; | 32 | struct symbol *symbol_hash[257]; |
27 | 33 | ||
28 | static struct menu *current_menu, *current_entry; | 34 | static struct menu *current_menu, *current_entry; |
29 | 35 | ||
36 | #define YYDEBUG 0 | ||
37 | #if YYDEBUG | ||
30 | #define YYERROR_VERBOSE | 38 | #define YYERROR_VERBOSE |
39 | #endif | ||
31 | %} | 40 | %} |
32 | %expect 40 | 41 | %expect 26 |
33 | 42 | ||
34 | %union | 43 | %union |
35 | { | 44 | { |
36 | int token; | ||
37 | char *string; | 45 | char *string; |
46 | struct file *file; | ||
38 | struct symbol *symbol; | 47 | struct symbol *symbol; |
39 | struct expr *expr; | 48 | struct expr *expr; |
40 | struct menu *menu; | 49 | struct menu *menu; |
50 | struct kconf_id *id; | ||
41 | } | 51 | } |
42 | 52 | ||
43 | %token T_MAINMENU | 53 | %token <id>T_MAINMENU |
44 | %token T_MENU | 54 | %token <id>T_MENU |
45 | %token T_ENDMENU | 55 | %token <id>T_ENDMENU |
46 | %token T_SOURCE | 56 | %token <id>T_SOURCE |
47 | %token T_CHOICE | 57 | %token <id>T_CHOICE |
48 | %token T_ENDCHOICE | 58 | %token <id>T_ENDCHOICE |
49 | %token T_COMMENT | 59 | %token <id>T_COMMENT |
50 | %token T_CONFIG | 60 | %token <id>T_CONFIG |
51 | %token T_MENUCONFIG | 61 | %token <id>T_MENUCONFIG |
52 | %token T_HELP | 62 | %token <id>T_HELP |
53 | %token <string> T_HELPTEXT | 63 | %token <string> T_HELPTEXT |
54 | %token T_IF | 64 | %token <id>T_IF |
55 | %token T_ENDIF | 65 | %token <id>T_ENDIF |
56 | %token T_DEPENDS | 66 | %token <id>T_DEPENDS |
57 | %token T_REQUIRES | 67 | %token <id>T_REQUIRES |
58 | %token T_OPTIONAL | 68 | %token <id>T_OPTIONAL |
59 | %token T_PROMPT | 69 | %token <id>T_PROMPT |
60 | %token T_DEFAULT | 70 | %token <id>T_TYPE |
61 | %token T_TRISTATE | 71 | %token <id>T_DEFAULT |
62 | %token T_DEF_TRISTATE | 72 | %token <id>T_SELECT |
63 | %token T_BOOLEAN | 73 | %token <id>T_RANGE |
64 | %token T_DEF_BOOLEAN | 74 | %token <id>T_ON |
65 | %token T_STRING | ||
66 | %token T_INT | ||
67 | %token T_HEX | ||
68 | %token <string> T_WORD | 75 | %token <string> T_WORD |
69 | %token <string> T_WORD_QUOTE | 76 | %token <string> T_WORD_QUOTE |
70 | %token T_UNEQUAL | 77 | %token T_UNEQUAL |
71 | %token T_EOF | ||
72 | %token T_EOL | ||
73 | %token T_CLOSE_PAREN | 78 | %token T_CLOSE_PAREN |
74 | %token T_OPEN_PAREN | 79 | %token T_OPEN_PAREN |
75 | %token T_ON | 80 | %token T_EOL |
76 | %token T_SELECT | ||
77 | %token T_RANGE | ||
78 | 81 | ||
79 | %left T_OR | 82 | %left T_OR |
80 | %left T_AND | 83 | %left T_AND |
@@ -82,38 +85,54 @@ static struct menu *current_menu, *current_entry; | |||
82 | %nonassoc T_NOT | 85 | %nonassoc T_NOT |
83 | 86 | ||
84 | %type <string> prompt | 87 | %type <string> prompt |
85 | %type <string> source | ||
86 | %type <symbol> symbol | 88 | %type <symbol> symbol |
87 | %type <expr> expr | 89 | %type <expr> expr |
88 | %type <expr> if_expr | 90 | %type <expr> if_expr |
89 | %type <token> end | 91 | %type <id> end |
92 | %type <id> option_name | ||
93 | %type <menu> if_entry menu_entry choice_entry | ||
94 | |||
95 | %destructor { | ||
96 | fprintf(stderr, "%s:%d: missing end statement for this entry\n", | ||
97 | $$->file->name, $$->lineno); | ||
98 | if (current_menu == $$) | ||
99 | menu_end_menu(); | ||
100 | } if_entry menu_entry choice_entry | ||
90 | 101 | ||
91 | %{ | ||
92 | #define LKC_DIRECT_LINK | ||
93 | #include "lkc.h" | ||
94 | %} | ||
95 | %% | 102 | %% |
96 | input: /* empty */ | 103 | input: stmt_list; |
97 | | input block | 104 | |
105 | stmt_list: | ||
106 | /* empty */ | ||
107 | | stmt_list common_stmt | ||
108 | | stmt_list choice_stmt | ||
109 | | stmt_list menu_stmt | ||
110 | | stmt_list T_MAINMENU prompt nl | ||
111 | | stmt_list end { zconf_error("unexpected end statement"); } | ||
112 | | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); } | ||
113 | | stmt_list option_name error T_EOL | ||
114 | { | ||
115 | zconf_error("unexpected option \"%s\"", kconf_id_strings + $2->name); | ||
116 | } | ||
117 | | stmt_list error T_EOL { zconf_error("invalid statement"); } | ||
98 | ; | 118 | ; |
99 | 119 | ||
100 | block: common_block | 120 | option_name: |
101 | | choice_stmt | 121 | T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT |
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 | ; | 122 | ; |
109 | 123 | ||
110 | common_block: | 124 | common_stmt: |
111 | if_stmt | 125 | T_EOL |
126 | | if_stmt | ||
112 | | comment_stmt | 127 | | comment_stmt |
113 | | config_stmt | 128 | | config_stmt |
114 | | menuconfig_stmt | 129 | | menuconfig_stmt |
115 | | source_stmt | 130 | | source_stmt |
116 | | nl_or_eof | 131 | ; |
132 | |||
133 | option_error: | ||
134 | T_WORD error T_EOL { zconf_error("unknown option \"%s\"", $1); } | ||
135 | | error T_EOL { zconf_error("invalid option"); } | ||
117 | ; | 136 | ; |
118 | 137 | ||
119 | 138 | ||
@@ -156,51 +175,16 @@ config_option_list: | |||
156 | | config_option_list config_option | 175 | | config_option_list config_option |
157 | | config_option_list depends | 176 | | config_option_list depends |
158 | | config_option_list help | 177 | | config_option_list help |
178 | | config_option_list option_error | ||
159 | | config_option_list T_EOL | 179 | | config_option_list T_EOL |
160 | ; | 180 | ; |
161 | 181 | ||
162 | config_option: T_TRISTATE prompt_stmt_opt T_EOL | 182 | config_option: T_TYPE prompt_stmt_opt T_EOL |
163 | { | 183 | { |
164 | menu_set_type(S_TRISTATE); | 184 | menu_set_type($1->stype); |
165 | printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno()); | 185 | printd(DEBUG_PARSE, "%s:%d:type(%u)\n", |
166 | }; | 186 | zconf_curname(), zconf_lineno(), |
167 | 187 | $1->stype); | |
168 | config_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 | |||
175 | config_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 | |||
181 | config_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 | |||
188 | config_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 | |||
194 | config_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 | |||
200 | config_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 | }; | 188 | }; |
205 | 189 | ||
206 | config_option: T_PROMPT prompt if_expr T_EOL | 190 | config_option: T_PROMPT prompt if_expr T_EOL |
@@ -212,7 +196,11 @@ config_option: T_PROMPT prompt if_expr T_EOL | |||
212 | config_option: T_DEFAULT expr if_expr T_EOL | 196 | config_option: T_DEFAULT expr if_expr T_EOL |
213 | { | 197 | { |
214 | menu_add_expr(P_DEFAULT, $2, $3); | 198 | menu_add_expr(P_DEFAULT, $2, $3); |
215 | printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); | 199 | if ($1->stype != S_UNKNOWN) |
200 | menu_set_type($1->stype); | ||
201 | printd(DEBUG_PARSE, "%s:%d:default(%u)\n", | ||
202 | zconf_curname(), zconf_lineno(), | ||
203 | $1->stype); | ||
216 | }; | 204 | }; |
217 | 205 | ||
218 | config_option: T_SELECT T_WORD if_expr T_EOL | 206 | config_option: T_SELECT T_WORD if_expr T_EOL |
@@ -240,8 +228,7 @@ choice: T_CHOICE T_EOL | |||
240 | 228 | ||
241 | choice_entry: choice choice_option_list | 229 | choice_entry: choice choice_option_list |
242 | { | 230 | { |
243 | menu_end_entry(); | 231 | $$ = menu_add_menu(); |
244 | menu_add_menu(); | ||
245 | }; | 232 | }; |
246 | 233 | ||
247 | choice_end: end | 234 | choice_end: end |
@@ -252,13 +239,8 @@ choice_end: end | |||
252 | } | 239 | } |
253 | }; | 240 | }; |
254 | 241 | ||
255 | choice_stmt: | 242 | choice_stmt: choice_entry choice_block choice_end |
256 | choice_entry choice_block choice_end | 243 | ; |
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 | 244 | ||
263 | choice_option_list: | 245 | choice_option_list: |
264 | /* empty */ | 246 | /* empty */ |
@@ -266,6 +248,7 @@ choice_option_list: | |||
266 | | choice_option_list depends | 248 | | choice_option_list depends |
267 | | choice_option_list help | 249 | | choice_option_list help |
268 | | choice_option_list T_EOL | 250 | | choice_option_list T_EOL |
251 | | choice_option_list option_error | ||
269 | ; | 252 | ; |
270 | 253 | ||
271 | choice_option: T_PROMPT prompt if_expr T_EOL | 254 | choice_option: T_PROMPT prompt if_expr T_EOL |
@@ -274,16 +257,15 @@ choice_option: T_PROMPT prompt if_expr T_EOL | |||
274 | printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); | 257 | printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); |
275 | }; | 258 | }; |
276 | 259 | ||
277 | choice_option: T_TRISTATE prompt_stmt_opt T_EOL | 260 | choice_option: T_TYPE 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 | |||
283 | choice_option: T_BOOLEAN prompt_stmt_opt T_EOL | ||
284 | { | 261 | { |
285 | menu_set_type(S_BOOLEAN); | 262 | if ($1->stype == S_BOOLEAN || $1->stype == S_TRISTATE) { |
286 | printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno()); | 263 | menu_set_type($1->stype); |
264 | printd(DEBUG_PARSE, "%s:%d:type(%u)\n", | ||
265 | zconf_curname(), zconf_lineno(), | ||
266 | $1->stype); | ||
267 | } else | ||
268 | YYERROR; | ||
287 | }; | 269 | }; |
288 | 270 | ||
289 | choice_option: T_OPTIONAL T_EOL | 271 | choice_option: T_OPTIONAL T_EOL |
@@ -294,24 +276,27 @@ choice_option: T_OPTIONAL T_EOL | |||
294 | 276 | ||
295 | choice_option: T_DEFAULT T_WORD if_expr T_EOL | 277 | choice_option: T_DEFAULT T_WORD if_expr T_EOL |
296 | { | 278 | { |
297 | menu_add_symbol(P_DEFAULT, sym_lookup($2, 0), $3); | 279 | if ($1->stype == S_UNKNOWN) { |
298 | printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno()); | 280 | menu_add_symbol(P_DEFAULT, sym_lookup($2, 0), $3); |
281 | printd(DEBUG_PARSE, "%s:%d:default\n", | ||
282 | zconf_curname(), zconf_lineno()); | ||
283 | } else | ||
284 | YYERROR; | ||
299 | }; | 285 | }; |
300 | 286 | ||
301 | choice_block: | 287 | choice_block: |
302 | /* empty */ | 288 | /* empty */ |
303 | | choice_block common_block | 289 | | choice_block common_stmt |
304 | ; | 290 | ; |
305 | 291 | ||
306 | /* if entry */ | 292 | /* if entry */ |
307 | 293 | ||
308 | if: T_IF expr T_EOL | 294 | if_entry: T_IF expr nl |
309 | { | 295 | { |
310 | printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); | 296 | printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); |
311 | menu_add_entry(NULL); | 297 | menu_add_entry(NULL); |
312 | menu_add_dep($2); | 298 | menu_add_dep($2); |
313 | menu_end_entry(); | 299 | $$ = menu_add_menu(); |
314 | menu_add_menu(); | ||
315 | }; | 300 | }; |
316 | 301 | ||
317 | if_end: end | 302 | if_end: end |
@@ -322,17 +307,12 @@ if_end: end | |||
322 | } | 307 | } |
323 | }; | 308 | }; |
324 | 309 | ||
325 | if_stmt: | 310 | if_stmt: if_entry if_block if_end |
326 | if if_block if_end | 311 | ; |
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 | 312 | ||
333 | if_block: | 313 | if_block: |
334 | /* empty */ | 314 | /* empty */ |
335 | | if_block common_block | 315 | | if_block common_stmt |
336 | | if_block menu_stmt | 316 | | if_block menu_stmt |
337 | | if_block choice_stmt | 317 | | if_block choice_stmt |
338 | ; | 318 | ; |
@@ -342,14 +322,13 @@ if_block: | |||
342 | menu: T_MENU prompt T_EOL | 322 | menu: T_MENU prompt T_EOL |
343 | { | 323 | { |
344 | menu_add_entry(NULL); | 324 | menu_add_entry(NULL); |
345 | menu_add_prop(P_MENU, $2, NULL, NULL); | 325 | menu_add_prompt(P_MENU, $2, NULL); |
346 | printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); | 326 | printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); |
347 | }; | 327 | }; |
348 | 328 | ||
349 | menu_entry: menu depends_list | 329 | menu_entry: menu depends_list |
350 | { | 330 | { |
351 | menu_end_entry(); | 331 | $$ = menu_add_menu(); |
352 | menu_add_menu(); | ||
353 | }; | 332 | }; |
354 | 333 | ||
355 | menu_end: end | 334 | menu_end: end |
@@ -360,31 +339,20 @@ menu_end: end | |||
360 | } | 339 | } |
361 | }; | 340 | }; |
362 | 341 | ||
363 | menu_stmt: | 342 | menu_stmt: menu_entry menu_block menu_end |
364 | menu_entry menu_block menu_end | 343 | ; |
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 | 344 | ||
371 | menu_block: | 345 | menu_block: |
372 | /* empty */ | 346 | /* empty */ |
373 | | menu_block common_block | 347 | | menu_block common_stmt |
374 | | menu_block menu_stmt | 348 | | menu_block menu_stmt |
375 | | menu_block choice_stmt | 349 | | menu_block choice_stmt |
376 | | menu_block error T_EOL { zconfprint("invalid menu option"); yyerrok; } | ||
377 | ; | 350 | ; |
378 | 351 | ||
379 | source: T_SOURCE prompt T_EOL | 352 | source_stmt: T_SOURCE prompt T_EOL |
380 | { | 353 | { |
381 | $$ = $2; | ||
382 | printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); | 354 | printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); |
383 | }; | 355 | zconf_nextfile($2); |
384 | |||
385 | source_stmt: source | ||
386 | { | ||
387 | zconf_nextfile($1); | ||
388 | }; | 356 | }; |
389 | 357 | ||
390 | /* comment entry */ | 358 | /* comment entry */ |
@@ -392,7 +360,7 @@ source_stmt: source | |||
392 | comment: T_COMMENT prompt T_EOL | 360 | comment: T_COMMENT prompt T_EOL |
393 | { | 361 | { |
394 | menu_add_entry(NULL); | 362 | menu_add_entry(NULL); |
395 | menu_add_prop(P_COMMENT, $2, NULL, NULL); | 363 | menu_add_prompt(P_COMMENT, $2, NULL); |
396 | printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); | 364 | printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); |
397 | }; | 365 | }; |
398 | 366 | ||
@@ -416,9 +384,11 @@ help: help_start T_HELPTEXT | |||
416 | 384 | ||
417 | /* depends option */ | 385 | /* depends option */ |
418 | 386 | ||
419 | depends_list: /* empty */ | 387 | depends_list: |
420 | | depends_list depends | 388 | /* empty */ |
421 | | depends_list T_EOL | 389 | | depends_list depends |
390 | | depends_list T_EOL | ||
391 | | depends_list option_error | ||
422 | ; | 392 | ; |
423 | 393 | ||
424 | depends: T_DEPENDS T_ON expr T_EOL | 394 | depends: T_DEPENDS T_ON expr T_EOL |
@@ -443,20 +413,22 @@ prompt_stmt_opt: | |||
443 | /* empty */ | 413 | /* empty */ |
444 | | prompt if_expr | 414 | | prompt if_expr |
445 | { | 415 | { |
446 | menu_add_prop(P_PROMPT, $1, NULL, $2); | 416 | menu_add_prompt(P_PROMPT, $1, $2); |
447 | }; | 417 | }; |
448 | 418 | ||
449 | prompt: T_WORD | 419 | prompt: T_WORD |
450 | | T_WORD_QUOTE | 420 | | T_WORD_QUOTE |
451 | ; | 421 | ; |
452 | 422 | ||
453 | end: T_ENDMENU nl_or_eof { $$ = T_ENDMENU; } | 423 | end: T_ENDMENU T_EOL { $$ = $1; } |
454 | | T_ENDCHOICE nl_or_eof { $$ = T_ENDCHOICE; } | 424 | | T_ENDCHOICE T_EOL { $$ = $1; } |
455 | | T_ENDIF nl_or_eof { $$ = T_ENDIF; } | 425 | | T_ENDIF T_EOL { $$ = $1; } |
456 | ; | 426 | ; |
457 | 427 | ||
458 | nl_or_eof: | 428 | nl: |
459 | T_EOL | T_EOF; | 429 | T_EOL |
430 | | nl T_EOL | ||
431 | ; | ||
460 | 432 | ||
461 | if_expr: /* empty */ { $$ = NULL; } | 433 | if_expr: /* empty */ { $$ = NULL; } |
462 | | T_IF expr { $$ = $2; } | 434 | | T_IF expr { $$ = $2; } |
@@ -487,18 +459,18 @@ void conf_parse(const char *name) | |||
487 | sym_init(); | 459 | sym_init(); |
488 | menu_init(); | 460 | menu_init(); |
489 | modules_sym = sym_lookup("MODULES", 0); | 461 | modules_sym = sym_lookup("MODULES", 0); |
490 | rootmenu.prompt = menu_add_prop(P_MENU, "BusyBox Configuration", NULL, NULL); | 462 | rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); |
491 | 463 | ||
492 | //zconfdebug = 1; | 464 | #if YYDEBUG |
465 | if (getenv("ZCONF_DEBUG")) | ||
466 | zconfdebug = 1; | ||
467 | #endif | ||
493 | zconfparse(); | 468 | zconfparse(); |
494 | if (zconfnerrs) | 469 | if (zconfnerrs) |
495 | exit(1); | 470 | exit(1); |
496 | menu_finalize(&rootmenu); | 471 | menu_finalize(&rootmenu); |
497 | for_all_symbols(i, sym) { | 472 | for_all_symbols(i, sym) { |
498 | if (!(sym->flags & SYMBOL_CHECKED) && sym_check_deps(sym)) | 473 | sym_check_deps(sym); |
499 | printf("\n"); | ||
500 | else | ||
501 | sym->flags |= SYMBOL_CHECK_DONE; | ||
502 | } | 474 | } |
503 | 475 | ||
504 | sym_change_count = 1; | 476 | sym_change_count = 1; |
@@ -513,20 +485,25 @@ const char *zconf_tokenname(int token) | |||
513 | case T_ENDCHOICE: return "endchoice"; | 485 | case T_ENDCHOICE: return "endchoice"; |
514 | case T_IF: return "if"; | 486 | case T_IF: return "if"; |
515 | case T_ENDIF: return "endif"; | 487 | case T_ENDIF: return "endif"; |
488 | case T_DEPENDS: return "depends"; | ||
516 | } | 489 | } |
517 | return "<token>"; | 490 | return "<token>"; |
518 | } | 491 | } |
519 | 492 | ||
520 | static bool zconf_endtoken(int token, int starttoken, int endtoken) | 493 | static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken) |
521 | { | 494 | { |
522 | if (token != endtoken) { | 495 | if (id->token != endtoken) { |
523 | zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken)); | 496 | zconf_error("unexpected '%s' within %s block", |
497 | kconf_id_strings + id->name, zconf_tokenname(starttoken)); | ||
524 | zconfnerrs++; | 498 | zconfnerrs++; |
525 | return false; | 499 | return false; |
526 | } | 500 | } |
527 | if (current_menu->file != current_file) { | 501 | if (current_menu->file != current_file) { |
528 | zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken)); | 502 | zconf_error("'%s' in different file than '%s'", |
529 | zconfprint("location of the '%s'", zconf_tokenname(starttoken)); | 503 | kconf_id_strings + id->name, zconf_tokenname(starttoken)); |
504 | fprintf(stderr, "%s:%d: location of the '%s'\n", | ||
505 | current_menu->file->name, current_menu->lineno, | ||
506 | zconf_tokenname(starttoken)); | ||
530 | zconfnerrs++; | 507 | zconfnerrs++; |
531 | return false; | 508 | return false; |
532 | } | 509 | } |
@@ -537,7 +514,19 @@ static void zconfprint(const char *err, ...) | |||
537 | { | 514 | { |
538 | va_list ap; | 515 | va_list ap; |
539 | 516 | ||
540 | fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno() + 1); | 517 | fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); |
518 | va_start(ap, err); | ||
519 | vfprintf(stderr, err, ap); | ||
520 | va_end(ap); | ||
521 | fprintf(stderr, "\n"); | ||
522 | } | ||
523 | |||
524 | static void zconf_error(const char *err, ...) | ||
525 | { | ||
526 | va_list ap; | ||
527 | |||
528 | zconfnerrs++; | ||
529 | fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); | ||
541 | va_start(ap, err); | 530 | va_start(ap, err); |
542 | vfprintf(stderr, err, ap); | 531 | vfprintf(stderr, err, ap); |
543 | va_end(ap); | 532 | va_end(ap); |
@@ -546,7 +535,9 @@ static void zconfprint(const char *err, ...) | |||
546 | 535 | ||
547 | static void zconferror(const char *err) | 536 | static void zconferror(const char *err) |
548 | { | 537 | { |
538 | #if YYDEBUG | ||
549 | fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); | 539 | fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); |
540 | #endif | ||
550 | } | 541 | } |
551 | 542 | ||
552 | void print_quoted_string(FILE *out, const char *str) | 543 | void print_quoted_string(FILE *out, const char *str) |
diff --git a/scripts/config/mkconfigs b/scripts/mkconfigs index fda9de72f..fda9de72f 100755 --- a/scripts/config/mkconfigs +++ b/scripts/mkconfigs | |||
diff --git a/scripts/trylink b/scripts/trylink new file mode 100755 index 000000000..dfe282db5 --- /dev/null +++ b/scripts/trylink | |||
@@ -0,0 +1,18 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | debug=false | ||
4 | |||
5 | function try { | ||
6 | added="$1" | ||
7 | shift | ||
8 | $debug && echo "Trying: $* $added" | ||
9 | "$@" $added >/dev/null 2>&1 \ | ||
10 | && exit 0 | ||
11 | } | ||
12 | |||
13 | try "" "$@" | ||
14 | try "-lm" "$@" | ||
15 | try "-lcrypt" "$@" | ||
16 | try "-Wl,--start-group -lcrypt -lm -Wl,--end-group" "$@" | ||
17 | # It failed. Rerun & let people see the error messages | ||
18 | "$@" $added | ||
diff --git a/scripts/usage.c b/scripts/usage.c index 373642cd6..adb290e4d 100644 --- a/scripts/usage.c +++ b/scripts/usage.c | |||
@@ -1,11 +1,13 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | #include <unistd.h> | 2 | #include <unistd.h> |
3 | #include "busybox.h" | 3 | |
4 | #include "../include/autoconf.h" | ||
5 | #include "../include/busybox.h" | ||
4 | 6 | ||
5 | static const char usage_messages[] = | 7 | static const char usage_messages[] = |
6 | #define MAKE_USAGE | 8 | #define MAKE_USAGE |
7 | #include "usage.h" | 9 | #include "../include/usage.h" |
8 | #include "applets.h" | 10 | #include "../include/applets.h" |
9 | ; | 11 | ; |
10 | 12 | ||
11 | int main(void) | 13 | int main(void) |
diff --git a/scripts/usage_compressed b/scripts/usage_compressed index 8e2228af2..ab164aa12 100644..100755 --- a/scripts/usage_compressed +++ b/scripts/usage_compressed | |||
@@ -1,13 +1,19 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | loc="$1" | 3 | target="$1" |
4 | loc="$2" | ||
4 | 5 | ||
6 | test "$target" || exit 1 | ||
5 | test "$loc" || loc=. | 7 | test "$loc" || loc=. |
6 | test -x "$loc/usage" || exit 1 | 8 | test -x "$loc/usage" || exit 1 |
9 | test "$SED" || SED=sed | ||
10 | |||
11 | sz=`"$loc/usage" | wc -c` || exit 1 | ||
12 | |||
13 | exec >"$target" | ||
7 | 14 | ||
8 | echo 'static const char packed_usage[] = ' | 15 | echo 'static const char packed_usage[] = ' |
9 | "$loc"/usage | bzip2 -1 | od -v -t x1 \ | 16 | "$loc/usage" | bzip2 -1 | od -v -t x1 \ |
10 | | $SED -e 's/^[^ ]*//' -e 's/ \(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/' || exit 1 | 17 | | $SED -e 's/^[^ ]*//' -e 's/ \(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/' |
11 | echo ';' | 18 | echo ';' |
12 | sz=`"$loc"/usage | wc -c` || exit 1 | ||
13 | echo '#define SIZEOF_usage_messages' `expr 0 + $sz` | 19 | echo '#define SIZEOF_usage_messages' `expr 0 + $sz` |