Commit 562f36ed authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'kconfig-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kconfig updates from Masahiro Yamada:
 "A pretty big batch of Kconfig updates.

  I have to mention the lexer and parser of Kconfig are now built from
  real .l and .y sources. So, flex and bison are the requirement for
  building the kernel. Both of them (unlike gperf) have been stable for
  a long time. This change has been tested several weeks in linux-next,
  and I did not receive any problem report about this.

  Summary:

   - add checks for mistakes, like the choice default is not in choice,
     help is doubled

   - document data structure and complex code

   - fix various memory leaks

   - change Makefile to build lexer and parser instead of using
     pre-generated C files

   - drop 'boolean' keyword, which is equivalent to 'bool'

   - use default 'yy' prefix and remove unneeded Make variables

   - fix gettext() check for xconfig

   - announce that oldnoconfig will be finally removed

   - make 'Selected by:' and 'Implied by' readable in help and search
     result

   - hide silentoldconfig from 'make help' to stop confusing people

   - fix misc things and cleanups"

* tag 'kconfig-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (37 commits)
  kconfig: Remove silentoldconfig from help and docs; fix kconfig/conf's help
  kconfig: make "Selected by:" and "Implied by:" readable
  kconfig: announce removal of oldnoconfig if used
  kconfig: fix make xconfig when gettext is missing
  kconfig: Clarify menu and 'if' dependency propagation
  kconfig: Document 'if' flattening logic
  kconfig: Clarify choice dependency propagation
  kconfig: Document SYMBOL_OPTIONAL logic
  kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX
  kconfig: use default 'yy' prefix for lexer and parser
  kconfig: make conf_unsaved a local variable of conf_read()
  kconfig: make xfgets() really static
  kconfig: make input_mode static
  kconfig: Warn if there is more than one help text
  kconfig: drop 'boolean' keyword
  kconfig: use bool instead of boolean for type definition attributes, again
  kconfig: Remove menu_end_entry()
  kconfig: Document important expression functions
  kconfig: Document automatic submenu creation code
  kconfig: Fix choice symbol expression leak
  ...
parents a659f159 cedd55d4
...@@ -170,11 +170,6 @@ Configuring the kernel ...@@ -170,11 +170,6 @@ Configuring the kernel
your existing ./.config file and asking about your existing ./.config file and asking about
new config symbols. new config symbols.
"make silentoldconfig"
Like above, but avoids cluttering the screen
with questions already answered.
Additionally updates the dependencies.
"make olddefconfig" "make olddefconfig"
Like above, but sets new symbols to their default Like above, but sets new symbols to their default
values without prompting. values without prompting.
......
...@@ -32,6 +32,8 @@ you probably needn't concern yourself with isdn4k-utils. ...@@ -32,6 +32,8 @@ you probably needn't concern yourself with isdn4k-utils.
GNU C 3.2 gcc --version GNU C 3.2 gcc --version
GNU make 3.81 make --version GNU make 3.81 make --version
binutils 2.20 ld -v binutils 2.20 ld -v
flex 2.5.35 flex --version
bison 2.0 bison --version
util-linux 2.10o fdformat --version util-linux 2.10o fdformat --version
module-init-tools 0.9.10 depmod -V module-init-tools 0.9.10 depmod -V
e2fsprogs 1.41.4 e2fsck -V e2fsprogs 1.41.4 e2fsck -V
...@@ -79,6 +81,19 @@ The build system has, as of 4.13, switched to using thin archives (`ar T`) ...@@ -79,6 +81,19 @@ The build system has, as of 4.13, switched to using thin archives (`ar T`)
rather than incremental linking (`ld -r`) for built-in.o intermediate steps. rather than incremental linking (`ld -r`) for built-in.o intermediate steps.
This requires binutils 2.20 or newer. This requires binutils 2.20 or newer.
Flex
----
Since Linux 4.16, the build system generates lexical analyzers
during build. This requires flex 2.5.35 or later.
Bison
-----
Since Linux 4.16, the build system generates parsers
during build. This requires bison 2.0 or later.
Perl Perl
---- ----
...@@ -333,6 +348,16 @@ Binutils ...@@ -333,6 +348,16 @@ Binutils
- <https://www.kernel.org/pub/linux/devel/binutils/> - <https://www.kernel.org/pub/linux/devel/binutils/>
Flex
----
- <https://github.com/westes/flex/releases>
Bison
-----
- <ftp://ftp.gnu.org/gnu/bison/>
OpenSSL OpenSSL
------- -------
......
...@@ -377,6 +377,8 @@ NM = $(CROSS_COMPILE)nm ...@@ -377,6 +377,8 @@ NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump OBJDUMP = $(CROSS_COMPILE)objdump
LEX = flex
YACC = bison
AWK = awk AWK = awk
GENKSYMS = scripts/genksyms/genksyms GENKSYMS = scripts/genksyms/genksyms
INSTALLKERNEL := installkernel INSTALLKERNEL := installkernel
...@@ -428,7 +430,7 @@ GCC_PLUGINS_CFLAGS := ...@@ -428,7 +430,7 @@ GCC_PLUGINS_CFLAGS :=
export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
export CPP AR NM STRIP OBJCOPY OBJDUMP HOSTLDFLAGS HOST_LOADLIBES export CPP AR NM STRIP OBJCOPY OBJDUMP HOSTLDFLAGS HOST_LOADLIBES
export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE
export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
......
...@@ -113,7 +113,7 @@ config EFI_CAPSULE_LOADER ...@@ -113,7 +113,7 @@ config EFI_CAPSULE_LOADER
Most users should say N. Most users should say N.
config EFI_CAPSULE_QUIRK_QUARK_CSH config EFI_CAPSULE_QUIRK_QUARK_CSH
boolean "Add support for Quark capsules with non-standard headers" bool "Add support for Quark capsules with non-standard headers"
depends on X86 && !64BIT depends on X86 && !64BIT
select EFI_CAPSULE_LOADER select EFI_CAPSULE_LOADER
default y default y
......
...@@ -7,6 +7,6 @@ config R8822BE ...@@ -7,6 +7,6 @@ config R8822BE
wireless network adapters. wireless network adapters.
config RTLWIFI_DEBUG_ST config RTLWIFI_DEBUG_ST
boolean bool
depends on R8822BE depends on R8822BE
default y default y
...@@ -186,39 +186,49 @@ $(foreach m, $(notdir $1), \ ...@@ -186,39 +186,49 @@ $(foreach m, $(notdir $1), \
$(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s))))))) $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
endef endef
ifdef REGENERATE_PARSERS
# LEX # LEX
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
LEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy)
quiet_cmd_flex = LEX $@ quiet_cmd_flex = LEX $@
cmd_flex = flex -o$@ -L -P $(LEX_PREFIX) $< cmd_flex = $(LEX) -o$@ -L $<
ifdef REGENERATE_PARSERS
.PRECIOUS: $(src)/%.lex.c_shipped .PRECIOUS: $(src)/%.lex.c_shipped
$(src)/%.lex.c_shipped: $(src)/%.l $(src)/%.lex.c_shipped: $(src)/%.l
$(call cmd,flex) $(call cmd,flex)
endif
.PRECIOUS: $(obj)/%.lex.c
$(filter %.lex.c,$(targets)): $(obj)/%.lex.c: $(src)/%.l FORCE
$(call if_changed,flex)
# YACC # YACC
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
YACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy)
quiet_cmd_bison = YACC $@ quiet_cmd_bison = YACC $@
cmd_bison = bison -o$@ -t -l -p $(YACC_PREFIX) $< cmd_bison = $(YACC) -o$@ -t -l $<
ifdef REGENERATE_PARSERS
.PRECIOUS: $(src)/%.tab.c_shipped .PRECIOUS: $(src)/%.tab.c_shipped
$(src)/%.tab.c_shipped: $(src)/%.y $(src)/%.tab.c_shipped: $(src)/%.y
$(call cmd,bison) $(call cmd,bison)
endif
.PRECIOUS: $(obj)/%.tab.c
$(filter %.tab.c,$(targets)): $(obj)/%.tab.c: $(src)/%.y FORCE
$(call if_changed,bison)
quiet_cmd_bison_h = YACC $@ quiet_cmd_bison_h = YACC $@
cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $< cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $<
ifdef REGENERATE_PARSERS
.PRECIOUS: $(src)/%.tab.h_shipped .PRECIOUS: $(src)/%.tab.h_shipped
$(src)/%.tab.h_shipped: $(src)/%.y $(src)/%.tab.h_shipped: $(src)/%.y
$(call cmd,bison_h) $(call cmd,bison_h)
endif endif
.PRECIOUS: $(obj)/%.tab.h
$(filter %.tab.h,$(targets)): $(obj)/%.tab.h: $(src)/%.y FORCE
$(call if_changed,bison_h)
# Shipped files # Shipped files
# =========================================================================== # ===========================================================================
......
...@@ -34,6 +34,8 @@ config: $(obj)/conf ...@@ -34,6 +34,8 @@ config: $(obj)/conf
nconfig: $(obj)/nconf nconfig: $(obj)/nconf
$< $(silent) $(Kconfig) $< $(silent) $(Kconfig)
# This has become an internal implementation detail and is now deprecated
# for external use.
silentoldconfig: $(obj)/conf silentoldconfig: $(obj)/conf
$(Q)mkdir -p include/config include/generated $(Q)mkdir -p include/config include/generated
$(Q)test -e include/generated/autoksyms.h || \ $(Q)test -e include/generated/autoksyms.h || \
...@@ -92,6 +94,8 @@ PHONY += oldnoconfig savedefconfig defconfig ...@@ -92,6 +94,8 @@ PHONY += oldnoconfig savedefconfig defconfig
# on its behavior (sets new symbols to their default value but not 'n') with the # on its behavior (sets new symbols to their default value but not 'n') with the
# counter-intuitive name. # counter-intuitive name.
oldnoconfig: olddefconfig oldnoconfig: olddefconfig
@echo " WARNING: \"oldnoconfig\" target will be removed after Linux 4.19"
@echo " Please use \"olddefconfig\" instead, which is an alias."
savedefconfig: $(obj)/conf savedefconfig: $(obj)/conf
$< $(silent) --$@=defconfig $(Kconfig) $< $(silent) --$@=defconfig $(Kconfig)
...@@ -142,7 +146,6 @@ help: ...@@ -142,7 +146,6 @@ help:
@echo ' oldconfig - Update current config utilising a provided .config as base' @echo ' oldconfig - Update current config utilising a provided .config as base'
@echo ' localmodconfig - Update current config disabling modules not loaded' @echo ' localmodconfig - Update current config disabling modules not loaded'
@echo ' localyesconfig - Update current config converting local mods to core' @echo ' localyesconfig - Update current config converting local mods to core'
@echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
@echo ' defconfig - New config with default from ARCH supplied defconfig' @echo ' defconfig - New config with default from ARCH supplied defconfig'
@echo ' savedefconfig - Save current config as ./defconfig (minimal config)' @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
@echo ' allnoconfig - New config where all options are answered with no' @echo ' allnoconfig - New config where all options are answered with no'
...@@ -151,8 +154,8 @@ help: ...@@ -151,8 +154,8 @@ help:
@echo ' alldefconfig - New config with all symbols set to default' @echo ' alldefconfig - New config with all symbols set to default'
@echo ' randconfig - New config with random answer to all options' @echo ' randconfig - New config with random answer to all options'
@echo ' listnewconfig - List new options' @echo ' listnewconfig - List new options'
@echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their' @echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
@echo ' default value' @echo ' default value without prompting'
@echo ' kvmconfig - Enable additional options for kvm guest kernel support' @echo ' kvmconfig - Enable additional options for kvm guest kernel support'
@echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support' @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support'
@echo ' tinyconfig - Configure the tiniest possible kernel' @echo ' tinyconfig - Configure the tiniest possible kernel'
...@@ -191,6 +194,7 @@ gconf-objs := gconf.o zconf.tab.o ...@@ -191,6 +194,7 @@ gconf-objs := gconf.o zconf.tab.o
hostprogs-y := conf nconf mconf kxgettext qconf gconf hostprogs-y := conf nconf mconf kxgettext qconf gconf
targets += zconf.tab.c zconf.lex.c
clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck
clean-files += zconf.tab.c zconf.lex.c gconf.glade.h clean-files += zconf.tab.c zconf.lex.c gconf.glade.h
clean-files += config.pot linux.pot clean-files += config.pot linux.pot
...@@ -205,14 +209,12 @@ always := dochecklxdialog ...@@ -205,14 +209,12 @@ always := dochecklxdialog
# Add environment specific flags # Add environment specific flags
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)) HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
HOST_EXTRACXXFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCXX) $(HOSTCXXFLAGS))
# generated files seem to need this to find local include files # generated files seem to need this to find local include files
HOSTCFLAGS_zconf.lex.o := -I$(src) HOSTCFLAGS_zconf.lex.o := -I$(src)
HOSTCFLAGS_zconf.tab.o := -I$(src) HOSTCFLAGS_zconf.tab.o := -I$(src)
LEX_PREFIX_zconf := zconf
YACC_PREFIX_zconf := zconf
HOSTLOADLIBES_qconf = $(KC_QT_LIBS) HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
static void conf(struct menu *menu); static void conf(struct menu *menu);
static void check_conf(struct menu *menu); static void check_conf(struct menu *menu);
static void xfgets(char *str, int size, FILE *in);
enum input_mode { enum input_mode {
oldaskconfig, oldaskconfig,
...@@ -35,7 +34,8 @@ enum input_mode { ...@@ -35,7 +34,8 @@ enum input_mode {
savedefconfig, savedefconfig,
listnewconfig, listnewconfig,
olddefconfig, olddefconfig,
} input_mode = oldaskconfig; };
static enum input_mode input_mode = oldaskconfig;
static int indent = 1; static int indent = 1;
static int tty_stdio; static int tty_stdio;
...@@ -82,6 +82,13 @@ static void check_stdin(void) ...@@ -82,6 +82,13 @@ static void check_stdin(void)
} }
} }
/* Helper function to facilitate fgets() by Jean Sacren. */
static void xfgets(char *str, int size, FILE *in)
{
if (!fgets(str, size, in))
fprintf(stderr, "\nError in reading or end of file.\n");
}
static int conf_askvalue(struct symbol *sym, const char *def) static int conf_askvalue(struct symbol *sym, const char *def)
{ {
enum symbol_type type = sym_get_type(sym); enum symbol_type type = sym_get_type(sym);
...@@ -477,8 +484,9 @@ static void conf_usage(const char *progname) ...@@ -477,8 +484,9 @@ static void conf_usage(const char *progname)
printf(" --listnewconfig List new options\n"); printf(" --listnewconfig List new options\n");
printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); printf(" --oldaskconfig Start a new configuration using a line-oriented program\n");
printf(" --oldconfig Update a configuration using a provided .config as base\n"); printf(" --oldconfig Update a configuration using a provided .config as base\n");
printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n"); printf(" --silentoldconfig Similar to oldconfig but generates configuration in\n"
printf(" --olddefconfig Same as silentoldconfig but sets new symbols to their default value\n"); " include/{generated/,config/} (oldconfig used to be more verbose)\n");
printf(" --olddefconfig Same as oldconfig but sets new symbols to their default value\n");
printf(" --oldnoconfig An alias of olddefconfig\n"); printf(" --oldnoconfig An alias of olddefconfig\n");
printf(" --defconfig <file> New config with default defined in <file>\n"); printf(" --defconfig <file> New config with default defined in <file>\n");
printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n"); printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n");
...@@ -712,12 +720,3 @@ int main(int ac, char **av) ...@@ -712,12 +720,3 @@ int main(int ac, char **av)
} }
return 0; return 0;
} }
/*
* Helper function to facilitate fgets() by Jean Sacren.
*/
void xfgets(char *str, int size, FILE *in)
{
if (fgets(str, size, in) == NULL)
fprintf(stderr, "\nError in reading or end of file.\n");
}
...@@ -28,7 +28,7 @@ static void conf_message(const char *fmt, ...) ...@@ -28,7 +28,7 @@ static void conf_message(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2))); __attribute__ ((format (printf, 1, 2)));
static const char *conf_filename; static const char *conf_filename;
static int conf_lineno, conf_warnings, conf_unsaved; static int conf_lineno, conf_warnings;
const char conf_defname[] = "arch/$ARCH/defconfig"; const char conf_defname[] = "arch/$ARCH/defconfig";
...@@ -290,7 +290,6 @@ int conf_read_simple(const char *name, int def) ...@@ -290,7 +290,6 @@ int conf_read_simple(const char *name, int def)
conf_filename = name; conf_filename = name;
conf_lineno = 0; conf_lineno = 0;
conf_warnings = 0; conf_warnings = 0;
conf_unsaved = 0;
def_flags = SYMBOL_DEF << def; def_flags = SYMBOL_DEF << def;
for_all_symbols(i, sym) { for_all_symbols(i, sym) {
...@@ -409,6 +408,7 @@ int conf_read_simple(const char *name, int def) ...@@ -409,6 +408,7 @@ int conf_read_simple(const char *name, int def)
int conf_read(const char *name) int conf_read(const char *name)
{ {
struct symbol *sym; struct symbol *sym;
int conf_unsaved = 0;
int i; int i;
sym_set_change_count(0); sym_set_change_count(0);
...@@ -1123,7 +1123,7 @@ void set_all_choice_values(struct symbol *csym) ...@@ -1123,7 +1123,7 @@ void set_all_choice_values(struct symbol *csym)
bool conf_set_all_new_symbols(enum conf_def_mode mode) bool conf_set_all_new_symbols(enum conf_def_mode mode)
{ {
struct symbol *sym, *csym; struct symbol *sym, *csym;
int i, cnt, pby, pty, ptm; /* pby: probability of boolean = y int i, cnt, pby, pty, ptm; /* pby: probability of bool = y
* pty: probability of tristate = y * pty: probability of tristate = y
* ptm: probability of tristate = m * ptm: probability of tristate = m
*/ */
......
...@@ -113,7 +113,7 @@ void expr_free(struct expr *e) ...@@ -113,7 +113,7 @@ void expr_free(struct expr *e)
break; break;
case E_NOT: case E_NOT:
expr_free(e->left.expr); expr_free(e->left.expr);
return; break;
case E_EQUAL: case E_EQUAL:
case E_GEQ: case E_GEQ:
case E_GTH: case E_GTH:
...@@ -138,8 +138,18 @@ static int trans_count; ...@@ -138,8 +138,18 @@ static int trans_count;
#define e1 (*ep1) #define e1 (*ep1)
#define e2 (*ep2) #define e2 (*ep2)
/*
* expr_eliminate_eq() helper.
*
* Walks the two expression trees given in 'ep1' and 'ep2'. Any node that does
* not have type 'type' (E_OR/E_AND) is considered a leaf, and is compared
* against all other leaves. Two equal leaves are both replaced with either 'y'
* or 'n' as appropriate for 'type', to be eliminated later.
*/
static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2) static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2)
{ {
/* Recurse down to leaves */
if (e1->type == type) { if (e1->type == type) {
__expr_eliminate_eq(type, &e1->left.expr, &e2); __expr_eliminate_eq(type, &e1->left.expr, &e2);
__expr_eliminate_eq(type, &e1->right.expr, &e2); __expr_eliminate_eq(type, &e1->right.expr, &e2);
...@@ -150,12 +160,18 @@ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct e ...@@ -150,12 +160,18 @@ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct e
__expr_eliminate_eq(type, &e1, &e2->right.expr); __expr_eliminate_eq(type, &e1, &e2->right.expr);
return; return;
} }
/* e1 and e2 are leaves. Compare them. */
if (e1->type == E_SYMBOL && e2->type == E_SYMBOL && if (e1->type == E_SYMBOL && e2->type == E_SYMBOL &&
e1->left.sym == e2->left.sym && e1->left.sym == e2->left.sym &&
(e1->left.sym == &symbol_yes || e1->left.sym == &symbol_no)) (e1->left.sym == &symbol_yes || e1->left.sym == &symbol_no))
return; return;
if (!expr_eq(e1, e2)) if (!expr_eq(e1, e2))
return; return;
/* e1 and e2 are equal leaves. Prepare them for elimination. */
trans_count++; trans_count++;
expr_free(e1); expr_free(e2); expr_free(e1); expr_free(e2);
switch (type) { switch (type) {
...@@ -172,6 +188,35 @@ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct e ...@@ -172,6 +188,35 @@ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct e
} }
} }
/*
* Rewrites the expressions 'ep1' and 'ep2' to remove operands common to both.
* Example reductions:
*
* ep1: A && B -> ep1: y
* ep2: A && B && C -> ep2: C
*
* ep1: A || B -> ep1: n
* ep2: A || B || C -> ep2: C
*
* ep1: A && (B && FOO) -> ep1: FOO
* ep2: (BAR && B) && A -> ep2: BAR
*
* ep1: A && (B || C) -> ep1: y
* ep2: (C || B) && A -> ep2: y
*
* Comparisons are done between all operands at the same "level" of && or ||.
* For example, in the expression 'e1 && (e2 || e3) && (e4 || e5)', the
* following operands will be compared:
*
* - 'e1', 'e2 || e3', and 'e4 || e5', against each other
* - e2 against e3
* - e4 against e5
*
* Parentheses are irrelevant within a single level. 'e1 && (e2 && e3)' and
* '(e1 && e2) && e3' are both a single level.
*
* See __expr_eliminate_eq() as well.
*/
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) void expr_eliminate_eq(struct expr **ep1, struct expr **ep2)
{ {
if (!e1 || !e2) if (!e1 || !e2)
...@@ -197,6 +242,12 @@ void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) ...@@ -197,6 +242,12 @@ void expr_eliminate_eq(struct expr **ep1, struct expr **ep2)
#undef e1 #undef e1
#undef e2 #undef e2
/*
* Returns true if 'e1' and 'e2' are equal, after minor simplification. Two
* &&/|| expressions are considered equal if every operand in one expression
* equals some operand in the other (operands do not need to appear in the same
* order), recursively.
*/
static int expr_eq(struct expr *e1, struct expr *e2) static int expr_eq(struct expr *e1, struct expr *e2)
{ {
int res, old_count; int res, old_count;
...@@ -243,6 +294,17 @@ static int expr_eq(struct expr *e1, struct expr *e2) ...@@ -243,6 +294,17 @@ static int expr_eq(struct expr *e1, struct expr *e2)
return 0; return 0;
} }
/*
* Recursively performs the following simplifications in-place (as well as the
* corresponding simplifications with swapped operands):
*
* expr && n -> n
* expr && y -> expr
* expr || n -> expr
* expr || y -> y
*
* Returns the optimized expression.
*/
static struct expr *expr_eliminate_yn(struct expr *e) static struct expr *expr_eliminate_yn(struct expr *e)
{ {
struct expr *tmp; struct expr *tmp;
...@@ -516,12 +578,21 @@ static struct expr *expr_join_and(struct expr *e1, struct expr *e2) ...@@ -516,12 +578,21 @@ static struct expr *expr_join_and(struct expr *e1, struct expr *e2)
return NULL; return NULL;
} }
/*
* expr_eliminate_dups() helper.
*
* Walks the two expression trees given in 'ep1' and 'ep2'. Any node that does
* not have type 'type' (E_OR/E_AND) is considered a leaf, and is compared
* against all other leaves to look for simplifications.
*/
static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2) static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2)
{ {
#define e1 (*ep1) #define e1 (*ep1)
#define e2 (*ep2) #define e2 (*ep2)
struct expr *tmp; struct expr *tmp;
/* Recurse down to leaves */
if (e1->type == type) { if (e1->type == type) {
expr_eliminate_dups1(type, &e1->left.expr, &e2); expr_eliminate_dups1(type, &e1->left.expr, &e2);
expr_eliminate_dups1(type, &e1->right.expr, &e2); expr_eliminate_dups1(type, &e1->right.expr, &e2);
...@@ -532,6 +603,9 @@ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct ...@@ -532,6 +603,9 @@ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct
expr_eliminate_dups1(type, &e1, &e2->right.expr); expr_eliminate_dups1(type, &e1, &e2->right.expr);
return; return;
} }
/* e1 and e2 are leaves. Compare and process them. */
if (e1 == e2) if (e1 == e2)
return; return;
...@@ -568,6 +642,17 @@ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct ...@@ -568,6 +642,17 @@ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct
#undef e2 #undef e2
} }
/*
* Rewrites 'e' in-place to remove ("join") duplicate and other redundant
* operands.
*
* Example simplifications:
*
* A || B || A -> A || B
* A && B && A=y -> A=y && B
*
* Returns the deduplicated expression.
*/
struct expr *expr_eliminate_dups(struct expr *e) struct expr *expr_eliminate_dups(struct expr *e)
{ {
int oldcount; int oldcount;
...@@ -584,6 +669,7 @@ struct expr *expr_eliminate_dups(struct expr *e) ...@@ -584,6 +669,7 @@ struct expr *expr_eliminate_dups(struct expr *e)
; ;
} }
if (!trans_count) if (!trans_count)
/* No simplifications done in this pass. We're done */
break; break;
e = expr_eliminate_yn(e); e = expr_eliminate_yn(e);
} }
...@@ -591,6 +677,12 @@ struct expr *expr_eliminate_dups(struct expr *e) ...@@ -591,6 +677,12 @@ struct expr *expr_eliminate_dups(struct expr *e)
return e; return e;
} }
/*
* Performs various simplifications involving logical operators and
* comparisons.
*
* Allocates and returns a new expression.
*/
struct expr *expr_transform(struct expr *e) struct expr *expr_transform(struct expr *e)
{ {
struct expr *tmp; struct expr *tmp;
...@@ -805,6 +897,20 @@ bool expr_depends_symbol(struct expr *dep, struct symbol *sym) ...@@ -805,6 +897,20 @@ bool expr_depends_symbol(struct expr *dep, struct symbol *sym)
return false; return false;
} }
/*
* Inserts explicit comparisons of type 'type' to symbol 'sym' into the
* expression 'e'.
*
* Examples transformations for type == E_UNEQUAL, sym == &symbol_no:
*
* A -> A!=n
* !A -> A=n
* A && B -> !(A=n || B=n)
* A || B -> !(A=n && B=n)
* A && (B || C) -> !(A=n || (B=n && C=n))
*
* Allocates and returns a new expression.
*/
struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym) struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym)
{ {
struct expr *e1, *e2; struct expr *e1, *e2;
...@@ -1073,7 +1179,7 @@ struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2) ...@@ -1073,7 +1179,7 @@ struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2)
return expr_get_leftmost_symbol(ret); return expr_get_leftmost_symbol(ret);
} }
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken, bool revdep)
{ {
if (!e) { if (!e) {
fn(data, NULL, "y"); fn(data, NULL, "y");
...@@ -1128,9 +1234,14 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char * ...@@ -1128,9 +1234,14 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *
fn(data, e->right.sym, e->right.sym->name); fn(data, e->right.sym, e->right.sym->name);
break; break;
case E_OR: case E_OR:
expr_print(e->left.expr, fn, data, E_OR); if (revdep && e->left.expr->type != E_OR)
fn(data, NULL, "\n - ");
__expr_print(e->left.expr, fn, data, E_OR, revdep);
if (revdep)
fn(data, NULL, "\n - ");
else
fn(data, NULL, " || "); fn(data, NULL, " || ");
expr_print(e->right.expr, fn, data, E_OR); __expr_print(e->right.expr, fn, data, E_OR, revdep);
break; break;
case E_AND: case E_AND:
expr_print(e->left.expr, fn, data, E_AND); expr_print(e->left.expr, fn, data, E_AND);
...@@ -1163,6 +1274,11 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char * ...@@ -1163,6 +1274,11 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *
fn(data, NULL, ")"); fn(data, NULL, ")");
} }
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
{
__expr_print(e, fn, data, prevtoken, false);
}
static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) static void expr_print_file_helper(void *data, struct symbol *sym, const char *str)
{ {
xfwrite(str, strlen(str), 1, data); xfwrite(str, strlen(str), 1, data);
...@@ -1207,3 +1323,13 @@ void expr_gstr_print(struct expr *e, struct gstr *gs) ...@@ -1207,3 +1323,13 @@ void expr_gstr_print(struct expr *e, struct gstr *gs)
{ {
expr_print(e, expr_print_gstr_helper, gs, E_NONE); expr_print(e, expr_print_gstr_helper, gs, E_NONE);
} }
/*
* Transform the top level "||" tokens into newlines and prepend each
* line with a minus. This makes expressions much easier to read.
* Suitable for reverse dependency expressions.
*/
void expr_gstr_print_revdep(struct expr *e, struct gstr *gs)
{
__expr_print(e, expr_print_gstr_helper, gs, E_NONE, true);
}
...@@ -74,17 +74,60 @@ enum { ...@@ -74,17 +74,60 @@ enum {
S_DEF_COUNT S_DEF_COUNT
}; };
/*
* Represents a configuration symbol.
*
* Choices are represented as a special kind of symbol and have the
* SYMBOL_CHOICE bit set in 'flags'.
*/
struct symbol { struct symbol {
/* The next symbol in the same bucket in the symbol hash table */
struct symbol *next; struct symbol *next;
/* The name of the symbol, e.g. "FOO" for 'config FOO' */
char *name; char *name;
/* S_BOOLEAN, S_TRISTATE, ... */
enum symbol_type type; enum symbol_type type;
/*
* The calculated value of the symbol. The SYMBOL_VALID bit is set in
* 'flags' when this is up to date. Note that this value might differ
* from the user value set in e.g. a .config file, due to visibility.
*/
struct symbol_value curr; struct symbol_value curr;
/*
* Values for the symbol provided from outside. def[S_DEF_USER] holds
* the .config value.
*/
struct symbol_value def[S_DEF_COUNT]; struct symbol_value def[S_DEF_COUNT];
/*
* An upper bound on the tristate value the user can set for the symbol
* if it is a boolean or tristate. Calculated from prompt dependencies,
* which also inherit dependencies from enclosing menus, choices, and
* ifs. If 'n', the user value will be ignored.
*
* Symbols lacking prompts always have visibility 'n'.
*/
tristate visible; tristate visible;
/* SYMBOL_* flags */
int flags; int flags;
/* List of properties. See prop_type. */
struct property *prop; struct property *prop;
/* Dependencies from enclosing menus, choices, and ifs */
struct expr_value dir_dep; struct expr_value dir_dep;
/* Reverse dependencies through being selected by other symbols */
struct expr_value rev_dep; struct expr_value rev_dep;
/*
* "Weak" reverse dependencies through being implied by other symbols
*/
struct expr_value implied; struct expr_value implied;
}; };
...@@ -133,7 +176,7 @@ enum prop_type { ...@@ -133,7 +176,7 @@ enum prop_type {
P_UNKNOWN, P_UNKNOWN,
P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */ P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */
P_COMMENT, /* text associated with a comment */ P_COMMENT, /* text associated with a comment */
P_MENU, /* prompt associated with a menuconfig option */ P_MENU, /* prompt associated with a menu or menuconfig symbol */
P_DEFAULT, /* default y */ P_DEFAULT, /* default y */
P_CHOICE, /* choice value */ P_CHOICE, /* choice value */
P_SELECT, /* select BAR */ P_SELECT, /* select BAR */
...@@ -166,22 +209,67 @@ struct property { ...@@ -166,22 +209,67 @@ struct property {
for (st = sym->prop; st; st = st->next) \ for (st = sym->prop; st; st = st->next) \
if (st->text) if (st->text)
/*
* Represents a node in the menu tree, as seen in e.g. menuconfig (though used
* for all front ends). Each symbol, menu, etc. defined in the Kconfig files
* gets a node. A symbol defined in multiple locations gets one node at each
* location.
*/
struct menu { struct menu {
/* The next menu node at the same level */
struct menu *next; struct menu *next;
/* The parent menu node, corresponding to e.g. a menu or choice */
struct menu *parent; struct menu *parent;
/* The first child menu node, for e.g. menus and choices */
struct menu *list; struct menu *list;
/*
* The symbol associated with the menu node. Choices are implemented as
* a special kind of symbol. NULL for menus, comments, and ifs.
*/
struct symbol *sym; struct symbol *sym;
/*
* The prompt associated with the node. This holds the prompt for a
* symbol as well as the text for a menu or comment, along with the
* type (P_PROMPT, P_MENU, etc.)
*/
struct property *prompt; struct property *prompt;
/*
* 'visible if' dependencies. If more than one is given, they will be
* ANDed together.
*/
struct expr *visibility; struct expr *visibility;
/*
* Ordinary dependencies from e.g. 'depends on' and 'if', ANDed
* together
*/
struct expr *dep; struct expr *dep;
/* MENU_* flags */
unsigned int flags; unsigned int flags;
/* Any help text associated with the node */
char *help; char *help;
/* The location where the menu node appears in the Kconfig files */
struct file *file; struct file *file;
int lineno; int lineno;
/* For use by front ends that need to store auxiliary data */
void *data; void *data;
}; };
/*
* Set on a menu node when the corresponding symbol changes state in some way.
* Can be checked by front ends.
*/
#define MENU_CHANGED 0x0001 #define MENU_CHANGED 0x0001
#define MENU_ROOT 0x0002 #define MENU_ROOT 0x0002
struct jump_key { struct jump_key {
...@@ -222,6 +310,7 @@ struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2); ...@@ -222,6 +310,7 @@ struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2);
void expr_fprint(struct expr *e, FILE *out); void expr_fprint(struct expr *e, FILE *out);
struct gstr; /* forward */ struct gstr; /* forward */
void expr_gstr_print(struct expr *e, struct gstr *gs); void expr_gstr_print(struct expr *e, struct gstr *gs);
void expr_gstr_print_revdep(struct expr *e, struct gstr *gs);
static inline int expr_is_yes(struct expr *e) static inline int expr_is_yes(struct expr *e)
{ {
......
...@@ -20,7 +20,6 @@ static struct kconf_id kconf_id_array[] = { ...@@ -20,7 +20,6 @@ static struct kconf_id kconf_id_array[] = {
{ "tristate", T_TYPE, TF_COMMAND, S_TRISTATE }, { "tristate", T_TYPE, TF_COMMAND, S_TRISTATE },
{ "def_tristate", T_DEFAULT, TF_COMMAND, S_TRISTATE }, { "def_tristate", T_DEFAULT, TF_COMMAND, S_TRISTATE },
{ "bool", T_TYPE, TF_COMMAND, S_BOOLEAN }, { "bool", T_TYPE, TF_COMMAND, S_BOOLEAN },
{ "boolean", T_TYPE, TF_COMMAND, S_BOOLEAN },
{ "def_bool", T_DEFAULT, TF_COMMAND, S_BOOLEAN }, { "def_bool", T_DEFAULT, TF_COMMAND, S_BOOLEAN },
{ "int", T_TYPE, TF_COMMAND, S_INT }, { "int", T_TYPE, TF_COMMAND, S_INT },
{ "hex", T_TYPE, TF_COMMAND, S_HEX }, { "hex", T_TYPE, TF_COMMAND, S_HEX },
......
...@@ -100,7 +100,6 @@ void menu_warn(struct menu *menu, const char *fmt, ...); ...@@ -100,7 +100,6 @@ void menu_warn(struct menu *menu, const char *fmt, ...);
struct menu *menu_add_menu(void); struct menu *menu_add_menu(void);
void menu_end_menu(void); void menu_end_menu(void);
void menu_add_entry(struct symbol *sym); void menu_add_entry(struct symbol *sym);
void menu_end_entry(void);
void menu_add_dep(struct expr *dep); void menu_add_dep(struct expr *dep);
void menu_add_visibility(struct expr *dep); void menu_add_visibility(struct expr *dep);
struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
......
...@@ -246,7 +246,7 @@ search_help[] = N_( ...@@ -246,7 +246,7 @@ search_help[] = N_(
" Selected by: BAR [=n]\n" " Selected by: BAR [=n]\n"
"-----------------------------------------------------------------\n" "-----------------------------------------------------------------\n"
"o The line 'Type:' shows the type of the configuration option for\n" "o The line 'Type:' shows the type of the configuration option for\n"
" this symbol (boolean, tristate, string, ...)\n" " this symbol (bool, tristate, string, ...)\n"
"o The line 'Prompt:' shows the text used in the menu structure for\n" "o The line 'Prompt:' shows the text used in the menu structure for\n"
" this symbol\n" " this symbol\n"
"o The 'Defined at' line tells at what file / line number the symbol\n" "o The 'Defined at' line tells at what file / line number the symbol\n"
......
...@@ -62,13 +62,8 @@ void menu_add_entry(struct symbol *sym) ...@@ -62,13 +62,8 @@ void menu_add_entry(struct symbol *sym)
menu_add_symbol(P_SYMBOL, sym, NULL); menu_add_symbol(P_SYMBOL, sym, NULL);
} }
void menu_end_entry(void)
{
}
struct menu *menu_add_menu(void) struct menu *menu_add_menu(void)
{ {
menu_end_entry();
last_entry_ptr = &current_entry->list; last_entry_ptr = &current_entry->list;
return current_menu = current_entry; return current_menu = current_entry;
} }
...@@ -79,19 +74,23 @@ void menu_end_menu(void) ...@@ -79,19 +74,23 @@ void menu_end_menu(void)
current_menu = current_menu->parent; current_menu = current_menu->parent;
} }
static struct expr *menu_check_dep(struct expr *e) /*
* Rewrites 'm' to 'm' && MODULES, so that it evaluates to 'n' when running
* without modules
*/
static struct expr *rewrite_m(struct expr *e)
{ {
if (!e) if (!e)
return e; return e;
switch (e->type) { switch (e->type) {
case E_NOT: case E_NOT:
e->left.expr = menu_check_dep(e->left.expr); e->left.expr = rewrite_m(e->left.expr);
break; break;
case E_OR: case E_OR:
case E_AND: case E_AND:
e->left.expr = menu_check_dep(e->left.expr); e->left.expr = rewrite_m(e->left.expr);
e->right.expr = menu_check_dep(e->right.expr); e->right.expr = rewrite_m(e->right.expr);
break; break;
case E_SYMBOL: case E_SYMBOL:
/* change 'm' into 'm' && MODULES */ /* change 'm' into 'm' && MODULES */
...@@ -106,7 +105,7 @@ static struct expr *menu_check_dep(struct expr *e) ...@@ -106,7 +105,7 @@ static struct expr *menu_check_dep(struct expr *e)
void menu_add_dep(struct expr *dep) void menu_add_dep(struct expr *dep)
{ {
current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep)); current_entry->dep = expr_alloc_and(current_entry->dep, dep);
} }
void menu_set_type(int type) void menu_set_type(int type)
...@@ -131,7 +130,7 @@ static struct property *menu_add_prop(enum prop_type type, char *prompt, struct ...@@ -131,7 +130,7 @@ static struct property *menu_add_prop(enum prop_type type, char *prompt, struct
prop->menu = current_entry; prop->menu = current_entry;
prop->expr = expr; prop->expr = expr;
prop->visible.expr = menu_check_dep(dep); prop->visible.expr = dep;
if (prompt) { if (prompt) {
if (isspace(*prompt)) { if (isspace(*prompt)) {
...@@ -252,6 +251,16 @@ static void sym_check_prop(struct symbol *sym) ...@@ -252,6 +251,16 @@ static void sym_check_prop(struct symbol *sym)
"'%s': number is invalid", "'%s': number is invalid",
sym->name); sym->name);
} }
if (sym_is_choice(sym)) {
struct property *choice_prop =
sym_get_choice_prop(sym2);
if (!choice_prop ||
prop_get_symbol(choice_prop) != sym)
prop_warn(prop,
"choice default symbol '%s' is not contained in the choice",
sym2->name);
}
break; break;
case P_SELECT: case P_SELECT:
case P_IMPLY: case P_IMPLY:
...@@ -260,13 +269,13 @@ static void sym_check_prop(struct symbol *sym) ...@@ -260,13 +269,13 @@ static void sym_check_prop(struct symbol *sym)
if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE) if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE)
prop_warn(prop, prop_warn(prop,
"config symbol '%s' uses %s, but is " "config symbol '%s' uses %s, but is "
"not boolean or tristate", sym->name, use); "not bool or tristate", sym->name, use);
else if (sym2->type != S_UNKNOWN && else if (sym2->type != S_UNKNOWN &&
sym2->type != S_BOOLEAN && sym2->type != S_BOOLEAN &&
sym2->type != S_TRISTATE) sym2->type != S_TRISTATE)
prop_warn(prop, prop_warn(prop,
"'%s' has wrong type. '%s' only " "'%s' has wrong type. '%s' only "
"accept arguments of boolean and " "accept arguments of bool and "
"tristate type", sym2->name, use); "tristate type", sym2->name, use);
break; break;
case P_RANGE: case P_RANGE:
...@@ -292,6 +301,11 @@ void menu_finalize(struct menu *parent) ...@@ -292,6 +301,11 @@ void menu_finalize(struct menu *parent)
sym = parent->sym; sym = parent->sym;
if (parent->list) { if (parent->list) {
/*
* This menu node has children. We (recursively) process them
* and propagate parent dependencies before moving on.
*/
if (sym && sym_is_choice(sym)) { if (sym && sym_is_choice(sym)) {
if (sym->type == S_UNKNOWN) { if (sym->type == S_UNKNOWN) {
/* find the first choice value to find out choice type */ /* find the first choice value to find out choice type */
...@@ -309,30 +323,83 @@ void menu_finalize(struct menu *parent) ...@@ -309,30 +323,83 @@ void menu_finalize(struct menu *parent)
if (menu->sym && menu->sym->type == S_UNKNOWN) if (menu->sym && menu->sym->type == S_UNKNOWN)
menu_set_type(sym->type); menu_set_type(sym->type);
} }
/*
* Use the choice itself as the parent dependency of
* the contained items. This turns the mode of the
* choice into an upper bound on the visibility of the
* choice value symbols.
*/
parentdep = expr_alloc_symbol(sym); parentdep = expr_alloc_symbol(sym);
} else if (parent->prompt) } else if (parent->prompt)
/* Menu node for 'menu' */
parentdep = parent->prompt->visible.expr; parentdep = parent->prompt->visible.expr;
else else
/* Menu node for 'if' */
parentdep = parent->dep; parentdep = parent->dep;
/* For each child menu node... */
for (menu = parent->list; menu; menu = menu->next) { for (menu = parent->list; menu; menu = menu->next) {
basedep = expr_transform(menu->dep); /*
* Propagate parent dependencies to the child menu
* node, also rewriting and simplifying expressions
*/
basedep = rewrite_m(menu->dep);
basedep = expr_transform(basedep);
basedep = expr_alloc_and(expr_copy(parentdep), basedep); basedep = expr_alloc_and(expr_copy(parentdep), basedep);
basedep = expr_eliminate_dups(basedep); basedep = expr_eliminate_dups(basedep);
menu->dep = basedep; menu->dep = basedep;
if (menu->sym) if (menu->sym)
/*
* Note: For symbols, all prompts are included
* too in the symbol's own property list
*/
prop = menu->sym->prop; prop = menu->sym->prop;
else else
/*
* For non-symbol menu nodes, we just need to
* handle the prompt
*/
prop = menu->prompt; prop = menu->prompt;
/* For each property... */
for (; prop; prop = prop->next) { for (; prop; prop = prop->next) {
if (prop->menu != menu) if (prop->menu != menu)
/*
* Two possibilities:
*
* 1. The property lacks dependencies
* and so isn't location-specific,
* e.g. an 'option'
*
* 2. The property belongs to a symbol
* defined in multiple locations and
* is from some other location. It
* will be handled there in that
* case.
*
* Skip the property.
*/
continue; continue;
dep = expr_transform(prop->visible.expr);
/*
* Propagate parent dependencies to the
* property's condition, rewriting and
* simplifying expressions at the same time
*/
dep = rewrite_m(prop->visible.expr);
dep = expr_transform(dep);
dep = expr_alloc_and(expr_copy(basedep), dep); dep = expr_alloc_and(expr_copy(basedep), dep);
dep = expr_eliminate_dups(dep); dep = expr_eliminate_dups(dep);
if (menu->sym && menu->sym->type != S_TRISTATE) if (menu->sym && menu->sym->type != S_TRISTATE)
dep = expr_trans_bool(dep); dep = expr_trans_bool(dep);
prop->visible.expr = dep; prop->visible.expr = dep;
/*
* Handle selects and implies, which modify the
* dependencies of the selected/implied symbol
*/
if (prop->type == P_SELECT) { if (prop->type == P_SELECT) {
struct symbol *es = prop_get_symbol(prop); struct symbol *es = prop_get_symbol(prop);
es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr, es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr,
...@@ -344,34 +411,81 @@ void menu_finalize(struct menu *parent) ...@@ -344,34 +411,81 @@ void menu_finalize(struct menu *parent)
} }
} }
} }
if (sym && sym_is_choice(sym))
expr_free(parentdep);
/*
* Recursively process children in the same fashion before
* moving on
*/
for (menu = parent->list; menu; menu = menu->next) for (menu = parent->list; menu; menu = menu->next)
menu_finalize(menu); menu_finalize(menu);
} else if (sym) { } else if (sym) {
/*
* Automatic submenu creation. If sym is a symbol and A, B, C,
* ... are consecutive items (symbols, menus, ifs, etc.) that
* all depend on sym, then the following menu structure is
* created:
*
* sym
* +-A
* +-B
* +-C
* ...
*
* This also works recursively, giving the following structure
* if A is a symbol and B depends on A:
*
* sym
* +-A
* | +-B
* +-C
* ...
*/
basedep = parent->prompt ? parent->prompt->visible.expr : NULL; basedep = parent->prompt ? parent->prompt->visible.expr : NULL;
basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
basedep = expr_eliminate_dups(expr_transform(basedep)); basedep = expr_eliminate_dups(expr_transform(basedep));
/* Examine consecutive elements after sym */
last_menu = NULL; last_menu = NULL;
for (menu = parent->next; menu; menu = menu->next) { for (menu = parent->next; menu; menu = menu->next) {
dep = menu->prompt ? menu->prompt->visible.expr : menu->dep; dep = menu->prompt ? menu->prompt->visible.expr : menu->dep;
if (!expr_contains_symbol(dep, sym)) if (!expr_contains_symbol(dep, sym))
/* No dependency, quit */
break; break;
if (expr_depends_symbol(dep, sym)) if (expr_depends_symbol(dep, sym))
/* Absolute dependency, put in submenu */
goto next; goto next;
/*
* Also consider it a dependency on sym if our
* dependencies contain sym and are a "superset" of
* sym's dependencies, e.g. '(sym || Q) && R' when sym
* depends on R.
*
* Note that 'R' might be from an enclosing menu or if,
* making this a more common case than it might seem.
*/
dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no); dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no);
dep = expr_eliminate_dups(expr_transform(dep)); dep = expr_eliminate_dups(expr_transform(dep));
dep2 = expr_copy(basedep); dep2 = expr_copy(basedep);
expr_eliminate_eq(&dep, &dep2); expr_eliminate_eq(&dep, &dep2);
expr_free(dep); expr_free(dep);
if (!expr_is_yes(dep2)) { if (!expr_is_yes(dep2)) {
/* Not superset, quit */
expr_free(dep2); expr_free(dep2);
break; break;
} }
/* Superset, put in submenu */
expr_free(dep2); expr_free(dep2);
next: next:
menu_finalize(menu); menu_finalize(menu);
menu->parent = parent; menu->parent = parent;
last_menu = menu; last_menu = menu;
} }
expr_free(basedep);
if (last_menu) { if (last_menu) {
parent->list = parent->next; parent->list = parent->next;
parent->next = last_menu->next; parent->next = last_menu->next;
...@@ -420,6 +534,35 @@ void menu_finalize(struct menu *parent) ...@@ -420,6 +534,35 @@ void menu_finalize(struct menu *parent)
*ep = expr_alloc_one(E_LIST, NULL); *ep = expr_alloc_one(E_LIST, NULL);
(*ep)->right.sym = menu->sym; (*ep)->right.sym = menu->sym;
} }
/*
* This code serves two purposes:
*
* (1) Flattening 'if' blocks, which do not specify a submenu
* and only add dependencies.
*
* (Automatic submenu creation might still create a submenu
* from an 'if' before this code runs.)
*
* (2) "Undoing" any automatic submenus created earlier below
* promptless symbols.
*
* Before:
*
* A
* if ... (or promptless symbol)
* +-B
* +-C
* D
*
* After:
*
* A
* if ... (or promptless symbol)
* B
* C
* D
*/
if (menu->list && (!menu->prompt || !menu->prompt->text)) { if (menu->list && (!menu->prompt || !menu->prompt->text)) {
for (last_menu = menu->list; ; last_menu = last_menu->next) { for (last_menu = menu->list; ; last_menu = last_menu->next) {
last_menu->parent = parent; last_menu->parent = parent;
...@@ -444,6 +587,15 @@ void menu_finalize(struct menu *parent) ...@@ -444,6 +587,15 @@ void menu_finalize(struct menu *parent)
sym->flags |= SYMBOL_WARNED; sym->flags |= SYMBOL_WARNED;
} }
/*
* For non-optional choices, add a reverse dependency (corresponding to
* a select) of '<visibility> && m'. This prevents the user from
* setting the choice mode to 'n' when the choice is visible.
*
* This would also work for non-choice symbols, but only non-optional
* choices clear SYMBOL_OPTIONAL as of writing. Choices are implemented
* as a type of symbol.
*/
if (sym && !sym_is_optional(sym) && parent->prompt) { if (sym && !sym_is_optional(sym) && parent->prompt) {
sym->rev_dep.expr = expr_alloc_or(sym->rev_dep.expr, sym->rev_dep.expr = expr_alloc_or(sym->rev_dep.expr,
expr_alloc_and(parent->prompt->visible.expr, expr_alloc_and(parent->prompt->visible.expr,
...@@ -676,14 +828,14 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym, ...@@ -676,14 +828,14 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym,
get_symbol_props_str(r, sym, P_SELECT, _(" Selects: ")); get_symbol_props_str(r, sym, P_SELECT, _(" Selects: "));
if (sym->rev_dep.expr) { if (sym->rev_dep.expr) {
str_append(r, _(" Selected by: ")); str_append(r, _(" Selected by: "));
expr_gstr_print(sym->rev_dep.expr, r); expr_gstr_print_revdep(sym->rev_dep.expr, r);
str_append(r, "\n"); str_append(r, "\n");
} }
get_symbol_props_str(r, sym, P_IMPLY, _(" Implies: ")); get_symbol_props_str(r, sym, P_IMPLY, _(" Implies: "));
if (sym->implied.expr) { if (sym->implied.expr) {
str_append(r, _(" Implied by: ")); str_append(r, _(" Implied by: "));
expr_gstr_print(sym->implied.expr, r); expr_gstr_print_revdep(sym->implied.expr, r);
str_append(r, "\n"); str_append(r, "\n");
} }
......
...@@ -77,7 +77,7 @@ const char *sym_type_name(enum symbol_type type) ...@@ -77,7 +77,7 @@ const char *sym_type_name(enum symbol_type type)
{ {
switch (type) { switch (type) {
case S_BOOLEAN: case S_BOOLEAN:
return "boolean"; return "bool";
case S_TRISTATE: case S_TRISTATE:
return "tristate"; return "tristate";
case S_INT: case S_INT:
...@@ -907,6 +907,10 @@ const char *sym_expand_string_value(const char *in) ...@@ -907,6 +907,10 @@ const char *sym_expand_string_value(const char *in)
char *res; char *res;
size_t reslen; size_t reslen;
/*
* Note: 'in' might come from a token that's about to be
* freed, so make sure to always allocate a new string
*/
reslen = strlen(in) + 1; reslen = strlen(in) + 1;
res = xmalloc(reslen); res = xmalloc(reslen);
res[0] = '\0'; res[0] = '\0';
...@@ -1150,8 +1154,7 @@ static void sym_check_print_recursive(struct symbol *last_sym) ...@@ -1150,8 +1154,7 @@ static void sym_check_print_recursive(struct symbol *last_sym)
if (stack->sym == last_sym) if (stack->sym == last_sym)
fprintf(stderr, "%s:%d:error: recursive dependency detected!\n", fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
prop->file->name, prop->lineno); prop->file->name, prop->lineno);
fprintf(stderr, "For a resolution refer to Documentation/kbuild/kconfig-language.txt\n");
fprintf(stderr, "subsection \"Kconfig recursive dependency limitations\"\n");
if (stack->expr) { if (stack->expr) {
fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n", fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
prop->file->name, prop->lineno, prop->file->name, prop->lineno,
...@@ -1181,6 +1184,11 @@ static void sym_check_print_recursive(struct symbol *last_sym) ...@@ -1181,6 +1184,11 @@ static void sym_check_print_recursive(struct symbol *last_sym)
} }
} }
fprintf(stderr,
"For a resolution refer to Documentation/kbuild/kconfig-language.txt\n"
"subsection \"Kconfig recursive dependency limitations\"\n"
"\n");
if (check_top == &cv_stack) if (check_top == &cv_stack)
dep_stack_remove(); dep_stack_remove();
} }
......
...@@ -106,11 +106,11 @@ n [A-Za-z0-9_-] ...@@ -106,11 +106,11 @@ n [A-Za-z0-9_-]
current_pos.file = current_file; current_pos.file = current_file;
current_pos.lineno = current_file->lineno; current_pos.lineno = current_file->lineno;
if (id && id->flags & TF_COMMAND) { if (id && id->flags & TF_COMMAND) {
zconflval.id = id; yylval.id = id;
return id->token; return id->token;
} }
alloc_string(yytext, yyleng); alloc_string(yytext, yyleng);
zconflval.string = text; yylval.string = text;
return T_WORD; return T_WORD;
} }
. warn_ignored_character(*yytext); . warn_ignored_character(*yytext);
...@@ -142,11 +142,11 @@ n [A-Za-z0-9_-] ...@@ -142,11 +142,11 @@ n [A-Za-z0-9_-]
({n}|[/.])+ { ({n}|[/.])+ {
const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
if (id && id->flags & TF_PARAM) { if (id && id->flags & TF_PARAM) {
zconflval.id = id; yylval.id = id;
return id->token; return id->token;
} }
alloc_string(yytext, yyleng); alloc_string(yytext, yyleng);
zconflval.string = text; yylval.string = text;
return T_WORD; return T_WORD;
} }
#.* /* comment */ #.* /* comment */
...@@ -161,7 +161,7 @@ n [A-Za-z0-9_-] ...@@ -161,7 +161,7 @@ n [A-Za-z0-9_-]
<STRING>{ <STRING>{
[^'"\\\n]+/\n { [^'"\\\n]+/\n {
append_string(yytext, yyleng); append_string(yytext, yyleng);
zconflval.string = text; yylval.string = text;
return T_WORD_QUOTE; return T_WORD_QUOTE;
} }
[^'"\\\n]+ { [^'"\\\n]+ {
...@@ -169,7 +169,7 @@ n [A-Za-z0-9_-] ...@@ -169,7 +169,7 @@ n [A-Za-z0-9_-]
} }
\\.?/\n { \\.?/\n {
append_string(yytext + 1, yyleng - 1); append_string(yytext + 1, yyleng - 1);
zconflval.string = text; yylval.string = text;
return T_WORD_QUOTE; return T_WORD_QUOTE;
} }
\\.? { \\.? {
...@@ -178,7 +178,7 @@ n [A-Za-z0-9_-] ...@@ -178,7 +178,7 @@ n [A-Za-z0-9_-]
\'|\" { \'|\" {
if (str == yytext[0]) { if (str == yytext[0]) {
BEGIN(PARAM); BEGIN(PARAM);
zconflval.string = text; yylval.string = text;
return T_WORD_QUOTE; return T_WORD_QUOTE;
} else } else
append_string(yytext, 1); append_string(yytext, 1);
...@@ -261,7 +261,7 @@ void zconf_starthelp(void) ...@@ -261,7 +261,7 @@ void zconf_starthelp(void)
static void zconf_endhelp(void) static void zconf_endhelp(void)
{ {
zconflval.string = text; yylval.string = text;
BEGIN(INITIAL); BEGIN(INITIAL);
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
int cdebug = PRINTD; int cdebug = PRINTD;
extern int zconflex(void); int yylex(void);
static void yyerror(const char *err);
static void zconfprint(const char *err, ...); static void zconfprint(const char *err, ...);
static void zconf_error(const char *err, ...); static void zconf_error(const char *err, ...);
static void zconferror(const char *err);
static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken);
struct symbol *symbol_hash[SYMBOL_HASHSIZE]; struct symbol *symbol_hash[SYMBOL_HASHSIZE];
...@@ -85,6 +85,7 @@ static struct menu *current_menu, *current_entry; ...@@ -85,6 +85,7 @@ static struct menu *current_menu, *current_entry;
%nonassoc T_NOT %nonassoc T_NOT
%type <string> prompt %type <string> prompt
%type <symbol> nonconst_symbol
%type <symbol> symbol %type <symbol> symbol
%type <expr> expr %type <expr> expr
%type <expr> if_expr %type <expr> if_expr
...@@ -101,14 +102,34 @@ static struct menu *current_menu, *current_entry; ...@@ -101,14 +102,34 @@ static struct menu *current_menu, *current_entry;
} if_entry menu_entry choice_entry } if_entry menu_entry choice_entry
%{ %{
/* Include zconf_id.c here so it can see the token constants. */ /* Include kconf_id.c here so it can see the token constants. */
#include "kconf_id.c" #include "kconf_id.c"
%} %}
%% %%
input: nl start | start; input: nl start | start;
start: mainmenu_stmt stmt_list | stmt_list; start: mainmenu_stmt stmt_list | no_mainmenu_stmt stmt_list;
/* mainmenu entry */
mainmenu_stmt: T_MAINMENU prompt nl
{
menu_add_prompt(P_MENU, $2, NULL);
};
/* Default main menu, if there's no mainmenu entry */
no_mainmenu_stmt: /* empty */
{
/*
* Hack: Keep the main menu title on the heap so we can safely free it
* later regardless of whether it comes from the 'prompt' in
* mainmenu_stmt or here
*/
menu_add_prompt(P_MENU, strdup("Linux Kernel Configuration"), NULL);
};
stmt_list: stmt_list:
/* empty */ /* empty */
...@@ -145,26 +166,23 @@ option_error: ...@@ -145,26 +166,23 @@ option_error:
/* config/menuconfig entry */ /* config/menuconfig entry */
config_entry_start: T_CONFIG T_WORD T_EOL config_entry_start: T_CONFIG nonconst_symbol T_EOL
{ {
struct symbol *sym = sym_lookup($2, 0); $2->flags |= SYMBOL_OPTIONAL;
sym->flags |= SYMBOL_OPTIONAL; menu_add_entry($2);
menu_add_entry(sym); printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2->name);
printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2);
}; };
config_stmt: config_entry_start config_option_list config_stmt: config_entry_start config_option_list
{ {
menu_end_entry();
printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
}; };
menuconfig_entry_start: T_MENUCONFIG T_WORD T_EOL menuconfig_entry_start: T_MENUCONFIG nonconst_symbol T_EOL
{ {
struct symbol *sym = sym_lookup($2, 0); $2->flags |= SYMBOL_OPTIONAL;
sym->flags |= SYMBOL_OPTIONAL; menu_add_entry($2);
menu_add_entry(sym); printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2->name);
printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2);
}; };
menuconfig_stmt: menuconfig_entry_start config_option_list menuconfig_stmt: menuconfig_entry_start config_option_list
...@@ -173,7 +191,6 @@ menuconfig_stmt: menuconfig_entry_start config_option_list ...@@ -173,7 +191,6 @@ menuconfig_stmt: menuconfig_entry_start config_option_list
current_entry->prompt->type = P_MENU; current_entry->prompt->type = P_MENU;
else else
zconfprint("warning: menuconfig statement without prompt"); zconfprint("warning: menuconfig statement without prompt");
menu_end_entry();
printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
}; };
...@@ -211,15 +228,15 @@ config_option: T_DEFAULT expr if_expr T_EOL ...@@ -211,15 +228,15 @@ config_option: T_DEFAULT expr if_expr T_EOL
$1->stype); $1->stype);
}; };
config_option: T_SELECT T_WORD if_expr T_EOL config_option: T_SELECT nonconst_symbol if_expr T_EOL
{ {
menu_add_symbol(P_SELECT, sym_lookup($2, 0), $3); menu_add_symbol(P_SELECT, $2, $3);
printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
}; };
config_option: T_IMPLY T_WORD if_expr T_EOL config_option: T_IMPLY nonconst_symbol if_expr T_EOL
{ {
menu_add_symbol(P_IMPLY, sym_lookup($2, 0), $3); menu_add_symbol(P_IMPLY, $2, $3);
printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno());
}; };
...@@ -237,8 +254,10 @@ symbol_option_list: ...@@ -237,8 +254,10 @@ symbol_option_list:
| symbol_option_list T_WORD symbol_option_arg | symbol_option_list T_WORD symbol_option_arg
{ {
const struct kconf_id *id = kconf_id_lookup($2, strlen($2)); const struct kconf_id *id = kconf_id_lookup($2, strlen($2));
if (id && id->flags & TF_OPTION) if (id && id->flags & TF_OPTION) {
menu_add_option(id->token, $3); menu_add_option(id->token, $3);
free($3);
}
else else
zconfprint("warning: ignoring unknown option %s", $2); zconfprint("warning: ignoring unknown option %s", $2);
free($2); free($2);
...@@ -308,10 +327,10 @@ choice_option: T_OPTIONAL T_EOL ...@@ -308,10 +327,10 @@ choice_option: T_OPTIONAL T_EOL
printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
}; };
choice_option: T_DEFAULT T_WORD if_expr T_EOL choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL
{ {
if ($1->stype == S_UNKNOWN) { if ($1->stype == S_UNKNOWN) {
menu_add_symbol(P_DEFAULT, sym_lookup($2, 0), $3); menu_add_symbol(P_DEFAULT, $2, $3);
printd(DEBUG_PARSE, "%s:%d:default\n", printd(DEBUG_PARSE, "%s:%d:default\n",
zconf_curname(), zconf_lineno()); zconf_curname(), zconf_lineno());
} else } else
...@@ -351,13 +370,6 @@ if_block: ...@@ -351,13 +370,6 @@ if_block:
| if_block choice_stmt | if_block choice_stmt
; ;
/* mainmenu entry */
mainmenu_stmt: T_MAINMENU prompt nl
{
menu_add_prompt(P_MENU, $2, NULL);
};
/* menu entry */ /* menu entry */
menu: T_MENU prompt T_EOL menu: T_MENU prompt T_EOL
...@@ -394,6 +406,7 @@ source_stmt: T_SOURCE prompt T_EOL ...@@ -394,6 +406,7 @@ source_stmt: T_SOURCE prompt T_EOL
{ {
printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2);
zconf_nextfile($2); zconf_nextfile($2);
free($2);
}; };
/* comment entry */ /* comment entry */
...@@ -406,9 +419,7 @@ comment: T_COMMENT prompt T_EOL ...@@ -406,9 +419,7 @@ comment: T_COMMENT prompt T_EOL
}; };
comment_stmt: comment depends_list comment_stmt: comment depends_list
{ ;
menu_end_entry();
};
/* help option */ /* help option */
...@@ -420,6 +431,11 @@ help_start: T_HELP T_EOL ...@@ -420,6 +431,11 @@ help_start: T_HELP T_EOL
help: help_start T_HELPTEXT help: help_start T_HELPTEXT
{ {
if (current_entry->help) {
free(current_entry->help);
zconfprint("warning: '%s' defined with more than one help text -- only the last one will be used",
current_entry->sym->name ?: "<choice>");
}
current_entry->help = $2; current_entry->help = $2;
}; };
...@@ -491,7 +507,10 @@ expr: symbol { $$ = expr_alloc_symbol($1); } ...@@ -491,7 +507,10 @@ expr: symbol { $$ = expr_alloc_symbol($1); }
| expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); } | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); }
; ;
symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); } /* For symbol definitions, selects, etc., where quotes are not accepted */
nonconst_symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); };
symbol: nonconst_symbol
| T_WORD_QUOTE { $$ = sym_lookup($1, SYMBOL_CONST); free($1); } | T_WORD_QUOTE { $$ = sym_lookup($1, SYMBOL_CONST); free($1); }
; ;
...@@ -502,6 +521,7 @@ word_opt: /* empty */ { $$ = NULL; } ...@@ -502,6 +521,7 @@ word_opt: /* empty */ { $$ = NULL; }
void conf_parse(const char *name) void conf_parse(const char *name)
{ {
const char *tmp;
struct symbol *sym; struct symbol *sym;
int i; int i;
...@@ -509,25 +529,26 @@ void conf_parse(const char *name) ...@@ -509,25 +529,26 @@ void conf_parse(const char *name)
sym_init(); sym_init();
_menu_init(); _menu_init();
rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
if (getenv("ZCONF_DEBUG")) if (getenv("ZCONF_DEBUG"))
zconfdebug = 1; yydebug = 1;
zconfparse(); yyparse();
if (zconfnerrs) if (yynerrs)
exit(1); exit(1);
if (!modules_sym) if (!modules_sym)
modules_sym = sym_find( "n" ); modules_sym = sym_find( "n" );
tmp = rootmenu.prompt->text;
rootmenu.prompt->text = _(rootmenu.prompt->text); rootmenu.prompt->text = _(rootmenu.prompt->text);
rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text); rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
free((char*)tmp);
menu_finalize(&rootmenu); menu_finalize(&rootmenu);
for_all_symbols(i, sym) { for_all_symbols(i, sym) {
if (sym_check_deps(sym)) if (sym_check_deps(sym))
zconfnerrs++; yynerrs++;
} }
if (zconfnerrs) if (yynerrs)
exit(1); exit(1);
sym_set_change_count(1); sym_set_change_count(1);
} }
...@@ -552,7 +573,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok ...@@ -552,7 +573,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok
if (id->token != endtoken) { if (id->token != endtoken) {
zconf_error("unexpected '%s' within %s block", zconf_error("unexpected '%s' within %s block",
id->name, zconf_tokenname(starttoken)); id->name, zconf_tokenname(starttoken));
zconfnerrs++; yynerrs++;
return false; return false;
} }
if (current_menu->file != current_file) { if (current_menu->file != current_file) {
...@@ -561,7 +582,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok ...@@ -561,7 +582,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok
fprintf(stderr, "%s:%d: location of the '%s'\n", fprintf(stderr, "%s:%d: location of the '%s'\n",
current_menu->file->name, current_menu->lineno, current_menu->file->name, current_menu->lineno,
zconf_tokenname(starttoken)); zconf_tokenname(starttoken));
zconfnerrs++; yynerrs++;
return false; return false;
} }
return true; return true;
...@@ -582,7 +603,7 @@ static void zconf_error(const char *err, ...) ...@@ -582,7 +603,7 @@ static void zconf_error(const char *err, ...)
{ {
va_list ap; va_list ap;
zconfnerrs++; yynerrs++;
fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
va_start(ap, err); va_start(ap, err);
vfprintf(stderr, err, ap); vfprintf(stderr, err, ap);
...@@ -590,7 +611,7 @@ static void zconf_error(const char *err, ...) ...@@ -590,7 +611,7 @@ static void zconf_error(const char *err, ...)
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
static void zconferror(const char *err) static void yyerror(const char *err)
{ {
fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
} }
...@@ -623,7 +644,7 @@ static void print_symbol(FILE *out, struct menu *menu) ...@@ -623,7 +644,7 @@ static void print_symbol(FILE *out, struct menu *menu)
fprintf(out, "\nconfig %s\n", sym->name); fprintf(out, "\nconfig %s\n", sym->name);
switch (sym->type) { switch (sym->type) {
case S_BOOLEAN: case S_BOOLEAN:
fputs(" boolean\n", out); fputs(" bool\n", out);
break; break;
case S_TRISTATE: case S_TRISTATE:
fputs(" tristate\n", out); fputs(" tristate\n", out);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment