summaryrefslogtreecommitdiff
path: root/kconfig
diff options
context:
space:
mode:
authorChris Packham <judge.packham@gmail.com>2020-12-09 09:13:29 (GMT)
committerChris Packham <judge.packham@gmail.com>2021-02-02 07:06:32 (GMT)
commit21095fab6712d3a082936b14b93cb6ff29c02872 (patch)
tree287fba5c166e21ee2e2d8183a1a189f708b86858 /kconfig
parentb16baed494d3c3fb66eeaaf9d8c1dbc7c6c0479f (diff)
kconfig: Sync with upstream v5.0
This commit introduces the following upstream changes: 2648ca1859bb kconfig: clean generated *conf-cfg files d86271af6460 kconfig: rename generated .*conf-cfg to *conf-cfg ba97df45581f kbuild: use assignment instead of define ... endef for filechk_* rules a5003571e627 kconfig: remove unused "file" field of yylval union f222b7f43661 kconfig: surround dbg_sym_flags with #ifdef DEBUG to fix gconf warning 3b541978562a kconfig: split images.c out of qconf.cc/gconf.c to fix gconf warnings 9abe42371b44 kconfig: add static qualifiers to fix gconf warnings cbafbf7f551c kconfig: split the lexer out of zconf.y 558e78e3ce84 kconfig: split some C files out of zconf.y 0c874100108f kconfig: convert to SPDX License Identifier 979f2b2f7936 kconfig: remove keyword lookup table entirely 4b31a32caf0a kconfig: update current_pos in the second lexer 824fa3b3b5e3 kconfig: switch to ASSIGN_VAL state in the second lexer b3d1d9d3c362 kconfig: stop associating kconf_id with yylval caaebb3c6de3 kconfig: refactor end token rules f5451582c4e2 kconfig: stop supporting '.' and '/' in unquoted words 171a515d0803 kconfig: use T_WORD instead of T_VARIABLE for variables c3d228713b10 kconfig: use specific tokens instead of T_ASSIGN for assignments ce2164ab5831 kconfig: refactor scanning and parsing "option" properties 3c8f317d4cf1 kconfig: use distinct tokens for type and default properties a01e5d242d93 kconfig: remove redundant token defines 4b5ec81bfeda kconfig: rename depends_list to comment_option_list 1f31be9ec0a9 kconfig: loosen the order of "visible" and "depends on" in menu entry 94d4e1b6021b kconfig: remove redundant menu_block rule 4891796c6f83 kconfig: remove redundant if_block rule 2f60e46e605a kconfig: remove grammatically ambiguous option_error 6900ae9eeee3 kconfig: remove grammatically ambiguous "unexpected option" diagnostic 723679339d08 kconfig: warn no new line at end of file 0bcc547ec4b0 kconfig: clean up EOF handling in the lexer cc66bca775ee kconfig: fix ambiguous grammar in terms of new lines 21c5ecf60472 kconfig: refactor pattern matching in STRING state be3c8075978a kconfig: remove unneeded pattern matching to whitespaces 413cd19d81fd kconfig: require T_EOL to reduce visible statement fbac5977d81c kconfig: fix memory leak when EOF is encountered in quotation 77c1c0fa8b14 kconfig: fix file name and line number of warn_ignored_character() 0cbe3ac439bf kconfig: remove k_invalid from expr_parse_string() return type 2aabbed6774f kconfig: remove S_OTHER symbol type and correct dependency tracking 1508fec82e39 kconfig: split out code touching a file to conf_touch_dep() 0849d212e395 kconfig: rename conf_split_config() to conf_touch_deps() 75889e9be78f kconfig: remove unneeded setsym label in conf_read_simple() a9b722847872 scripts/kconfig/merge_config: don't redefine 'y' to 'm' Signed-off-by: Chris Packham <judge.packham@gmail.com>
Diffstat (limited to 'kconfig')
-rw-r--r--kconfig/Makefile.am19
-rw-r--r--kconfig/conf.c2
-rw-r--r--kconfig/confdata.c136
-rw-r--r--kconfig/expr.c18
-rw-r--r--kconfig/expr.h6
-rw-r--r--kconfig/kconf_id.c52
-rw-r--r--kconfig/lkc.h25
-rw-r--r--kconfig/lxdialog/checklist.c15
-rw-r--r--kconfig/lxdialog/dialog.h15
-rw-r--r--kconfig/lxdialog/inputbox.c15
-rw-r--r--kconfig/lxdialog/menubox.c15
-rw-r--r--kconfig/lxdialog/textbox.c15
-rw-r--r--kconfig/lxdialog/util.c15
-rw-r--r--kconfig/lxdialog/yesno.c15
-rw-r--r--kconfig/mconf.c2
-rw-r--r--kconfig/menu.c43
-rw-r--r--kconfig/nconf.c5
-rw-r--r--kconfig/nconf.gui.c5
-rw-r--r--kconfig/nconf.h5
-rw-r--r--kconfig/preprocess.c5
-rw-r--r--kconfig/symbol.c7
-rw-r--r--kconfig/util.c3
-rw-r--r--kconfig/zconf.l235
-rw-r--r--kconfig/zconf.y294
24 files changed, 378 insertions, 589 deletions
diff --git a/kconfig/Makefile.am b/kconfig/Makefile.am
index 0523ea9..8245606 100644
--- a/kconfig/Makefile.am
+++ b/kconfig/Makefile.am
@@ -9,22 +9,23 @@ EXTRA_DIST = zconf.y zconf.l \
expr.h list.h lkc.h lkc_proto.h nconf.h lxdialog/dialog.h \
confdata.c expr.c kconf_id.c menu.c symbol.c util.c
-CLEANFILES = zconf.lex.c zconf.c
-BUILT_SOURCES = zconf.c zconf.lex.c
+CLEANFILES = zconf.lex.c zconf.tab.c
+BUILT_SOURCES = zconf.lex.c zconf.tab.c
-AM_LFLAGS = -L -Pzconf
-AM_YFLAGS = -l -b zconf -p zconf
+AM_LFLAGS = -L
+AM_YFLAGS = -t -l
AM_CPPFLAGS = -include config.h -DCONFIG_=\"CT_\"
AM_LIBTOOLFLAGS = --tag CC
-conf_SOURCES = conf.c zconf.c
+conf_SOURCES = conf.c confdata.c expr.c symbol.c preprocess.c zconf.lex.c zconf.tab.c
conf_LDADD = $(LIBINTL)
-nconf_SOURCES = nconf.c nconf.gui.c zconf.c
+nconf_SOURCES = nconf.c nconf.gui.c confdata.c expr.c symbol.c preprocess.c zconf.lex.c zconf.tab.c
nconf_CFLAGS = $(CURSES_CFLAGS)
nconf_LDADD = $(MENU_LIBS) $(PANEL_LIBS) $(CURSES_LIBS) $(LIBINTL)
-mconf_SOURCES = mconf.c zconf.c lxdialog/checklist.c lxdialog/inputbox.c \
+mconf_SOURCES = mconf.c confdata.c expr.c symbol.c preprocess.c zconf.lex.c zconf.tab.c \
+ lxdialog/checklist.c lxdialog/inputbox.c \
lxdialog/menubox.c lxdialog/textbox.c lxdialog/util.c \
lxdialog/yesno.c
mconf_LDADD = $(CURSES_LIBS) $(LIBINTL)
@@ -42,8 +43,8 @@ AM_V_LEX = $(am__v_LEX_@AM_V@)
am__v_LEX_ = $(am__v_LEX_@AM_DEFAULT_V@)
am__v_LEX_0 = @echo " LEX " $@;
-zconf.c: zconf.y
- $(AM_V_YACC)$(YACCCOMPILE) -o$@ $<
+zconf.tab.c: zconf.y
+ $(AM_V_YACC)$(YACCCOMPILE) -o$@ --defines=zconf.tab.h $<
zconf.lex.c: zconf.l
$(AM_V_LEX)$(LEXCOMPILE) -o$@ $<
diff --git a/kconfig/conf.c b/kconfig/conf.c
index 5a795c5..b86c7de 100644
--- a/kconfig/conf.c
+++ b/kconfig/conf.c
@@ -1,6 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
*/
#include <ctype.h>
diff --git a/kconfig/confdata.c b/kconfig/confdata.c
index 91d0a5c..08ba146 100644
--- a/kconfig/confdata.c
+++ b/kconfig/confdata.c
@@ -1,12 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
*/
#include <sys/stat.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
+#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -74,6 +75,47 @@ static int make_parent_dir(const char *path)
return 0;
}
+static char depfile_path[PATH_MAX];
+static size_t depfile_prefix_len;
+
+/* touch depfile for symbol 'name' */
+static int conf_touch_dep(const char *name)
+{
+ int fd, ret;
+ const char *s;
+ char *d, c;
+
+ /* check overflow: prefix + name + ".h" + '\0' must fit in buffer. */
+ if (depfile_prefix_len + strlen(name) + 3 > sizeof(depfile_path))
+ return -1;
+
+ d = depfile_path + depfile_prefix_len;
+ s = name;
+
+ while ((c = *s++))
+ *d++ = (c == '_') ? '/' : tolower(c);
+ strcpy(d, ".h");
+
+ /* Assume directory path already exists. */
+ fd = open(depfile_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ if (fd == -1) {
+ if (errno != ENOENT)
+ return -1;
+
+ ret = make_parent_dir(depfile_path);
+ if (ret)
+ return ret;
+
+ /* Try it again. */
+ fd = open(depfile_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+ if (fd == -1)
+ return -1;
+ }
+ close(fd);
+
+ return 0;
+}
+
struct conf_printer {
void (*print_symbol)(FILE *, struct symbol *, const char *, void *);
void (*print_comment)(FILE *, const char *, void *);
@@ -186,14 +228,6 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
conf_warning("symbol value '%s' invalid for %s",
p, sym->name);
return 1;
- case S_OTHER:
- if (*p != '"') {
- for (p2 = p; *p2 && !isspace(*p2); p2++)
- ;
- sym->type = S_STRING;
- goto done;
- }
- /* fall through */
case S_STRING:
if (*p++ != '"')
break;
@@ -212,7 +246,6 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
/* fall through */
case S_INT:
case S_HEX:
- done:
if (sym_string_valid(sym, p)) {
sym->def[def].val = xstrdup(p);
sym->flags |= def_flags;
@@ -363,7 +396,7 @@ load:
sym = sym_find(line + 2 + strlen(CONFIG_));
if (!sym) {
sym_add_change_count(1);
- goto setsym;
+ continue;
}
} else {
sym = sym_lookup(line + 2 + strlen(CONFIG_), 0);
@@ -393,17 +426,22 @@ load:
if (*p2 == '\r')
*p2 = 0;
}
- if (def == S_DEF_USER) {
- sym = sym_find(line + strlen(CONFIG_));
- if (!sym) {
+
+ sym = sym_find(line + strlen(CONFIG_));
+ if (!sym) {
+ if (def == S_DEF_AUTO)
+ /*
+ * Reading from include/config/auto.conf
+ * If CONFIG_FOO previously existed in
+ * auto.conf but it is missing now,
+ * include/config/foo.h must be touched.
+ */
+ conf_touch_dep(line + strlen(CONFIG_));
+ else
sym_add_change_count(1);
- goto setsym;
- }
- } else {
- sym = sym_lookup(line + strlen(CONFIG_), 0);
- if (sym->type == S_UNKNOWN)
- sym->type = S_OTHER;
+ continue;
}
+
if (sym->flags & def_flags) {
conf_warning("override: reassigning to symbol %s", sym->name);
}
@@ -416,7 +454,7 @@ load:
continue;
}
-setsym:
+
if (sym && sym_is_choice_value(sym)) {
struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
switch (sym->def[def].tri) {
@@ -669,7 +707,6 @@ static void conf_write_symbol(FILE *fp, struct symbol *sym,
const char *str;
switch (sym->type) {
- case S_OTHER:
case S_UNKNOWN:
break;
case S_STRING:
@@ -906,24 +943,19 @@ static int conf_write_dep(const char *name)
return 0;
}
-static int conf_split_config(void)
+static int conf_touch_deps(void)
{
const char *name;
- char path[PATH_MAX+1];
- char *s, *d, c;
struct symbol *sym;
- int res, i, fd;
+ int res, i;
+
+ strcpy(depfile_path, "include/config/");
+ depfile_prefix_len = strlen(depfile_path);
name = conf_get_autoconfig_name();
conf_read_simple(name, S_DEF_AUTO);
sym_calc_value(modules_sym);
- if (make_parent_dir("include/config/foo.h"))
- return 1;
- if (chdir("include/config"))
- return 1;
-
- res = 0;
for_all_symbols(i, sym) {
sym_calc_value(sym);
if ((sym->flags & SYMBOL_NO_WRITE) || !sym->name)
@@ -975,42 +1007,12 @@ static int conf_split_config(void)
* different from 'no').
*/
- /* Replace all '_' and append ".h" */
- s = sym->name;
- d = path;
- while ((c = *s++)) {
- c = tolower(c);
- *d++ = (c == '_') ? '/' : c;
- }
- strcpy(d, ".h");
-
- /* Assume directory path already exists. */
- fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
- if (fd == -1) {
- if (errno != ENOENT) {
- res = 1;
- break;
- }
-
- if (make_parent_dir(path)) {
- res = 1;
- goto out;
- }
-
- /* Try it again. */
- fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
- if (fd == -1) {
- res = 1;
- break;
- }
- }
- close(fd);
+ res = conf_touch_dep(sym->name);
+ if (res)
+ return res;
}
-out:
- if (chdir("../.."))
- return 1;
- return res;
+ return 0;
}
int conf_write_autoconf(int overwrite)
@@ -1028,7 +1030,7 @@ int conf_write_autoconf(int overwrite)
conf_write_dep("include/config/auto.conf.cmd");
- if (conf_split_config())
+ if (conf_touch_deps())
return 1;
out = fopen(".tmpconfig", "w");
diff --git a/kconfig/expr.c b/kconfig/expr.c
index e1a39e9..77ffff3 100644
--- a/kconfig/expr.c
+++ b/kconfig/expr.c
@@ -1,8 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
*/
+#include <ctype.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -980,7 +982,6 @@ enum string_value_kind {
k_string,
k_signed,
k_unsigned,
- k_invalid
};
union string_value {
@@ -1011,13 +1012,10 @@ static enum string_value_kind expr_parse_string(const char *str,
val->u = strtoull(str, &tail, 16);
kind = k_unsigned;
break;
- case S_STRING:
- case S_UNKNOWN:
+ default:
val->s = strtoll(str, &tail, 0);
kind = k_signed;
break;
- default:
- return k_invalid;
}
return !errno && !*tail && tail > str && isxdigit(tail[-1])
? kind : k_string;
@@ -1073,13 +1071,7 @@ tristate expr_calc_value(struct expr *e)
if (k1 == k_string || k2 == k_string)
res = strcmp(str1, str2);
- else if (k1 == k_invalid || k2 == k_invalid) {
- if (e->type != E_EQUAL && e->type != E_UNEQUAL) {
- printf("Cannot compare \"%s\" and \"%s\"\n", str1, str2);
- return no;
- }
- res = strcmp(str1, str2);
- } else if (k1 == k_unsigned || k2 == k_unsigned)
+ else if (k1 == k_unsigned || k2 == k_unsigned)
res = (lval.u > rval.u) - (lval.u < rval.u);
else /* if (k1 == k_signed && k2 == k_signed) */
res = (lval.s > rval.s) - (lval.s < rval.s);
diff --git a/kconfig/expr.h b/kconfig/expr.h
index 7c329e1..999edb6 100644
--- a/kconfig/expr.h
+++ b/kconfig/expr.h
@@ -1,6 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
*/
#ifndef EXPR_H
@@ -62,7 +62,7 @@ struct symbol_value {
};
enum symbol_type {
- S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER
+ S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING
};
/* enum values are used as index to symbol.def[] */
@@ -131,7 +131,7 @@ struct symbol {
struct expr_value implied;
};
-#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
+#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next)
#define SYMBOL_CONST 0x0001 /* symbol is const */
#define SYMBOL_CHECK 0x0008 /* used during dependency checking */
diff --git a/kconfig/kconf_id.c b/kconfig/kconf_id.c
deleted file mode 100644
index b3e0ea0..0000000
--- a/kconfig/kconf_id.c
+++ /dev/null
@@ -1,52 +0,0 @@
-
-static struct kconf_id kconf_id_array[] = {
- { "mainmenu", T_MAINMENU, TF_COMMAND },
- { "menu", T_MENU, TF_COMMAND },
- { "endmenu", T_ENDMENU, TF_COMMAND },
- { "source", T_SOURCE, TF_COMMAND },
- { "choice", T_CHOICE, TF_COMMAND },
- { "endchoice", T_ENDCHOICE, TF_COMMAND },
- { "comment", T_COMMENT, TF_COMMAND },
- { "config", T_CONFIG, TF_COMMAND },
- { "menuconfig", T_MENUCONFIG, TF_COMMAND },
- { "help", T_HELP, TF_COMMAND },
- { "---help---", T_HELP, TF_COMMAND },
- { "if", T_IF, TF_COMMAND|TF_PARAM },
- { "endif", T_ENDIF, TF_COMMAND },
- { "depends", T_DEPENDS, TF_COMMAND },
- { "optional", T_OPTIONAL, TF_COMMAND },
- { "default", T_DEFAULT, TF_COMMAND, S_UNKNOWN },
- { "prompt", T_PROMPT, TF_COMMAND },
- { "tristate", T_TYPE, TF_COMMAND, S_TRISTATE },
- { "def_tristate", T_DEFAULT, TF_COMMAND, S_TRISTATE },
- { "bool", T_TYPE, TF_COMMAND, S_BOOLEAN },
- { "def_bool", T_DEFAULT, TF_COMMAND, S_BOOLEAN },
- { "int", T_TYPE, TF_COMMAND, S_INT },
- { "hex", T_TYPE, TF_COMMAND, S_HEX },
- { "string", T_TYPE, TF_COMMAND, S_STRING },
- { "select", T_SELECT, TF_COMMAND },
- { "imply", T_IMPLY, TF_COMMAND },
- { "range", T_RANGE, TF_COMMAND },
- { "visible", T_VISIBLE, TF_COMMAND },
- { "option", T_OPTION, TF_COMMAND },
- { "on", T_ON, TF_PARAM },
- { "modules", T_OPT_MODULES, TF_OPTION },
- { "defconfig_list", T_OPT_DEFCONFIG_LIST, TF_OPTION },
- { "allnoconfig_y", T_OPT_ALLNOCONFIG_Y, TF_OPTION },
-};
-
-#define KCONF_ID_ARRAY_SIZE (sizeof(kconf_id_array)/sizeof(struct kconf_id))
-
-static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len)
-{
- int i;
-
- for (i = 0; i < KCONF_ID_ARRAY_SIZE; i++) {
- struct kconf_id *id = kconf_id_array+i;
- int l = strlen(id->name);
-
- if (len == l && !memcmp(str, id->name, len))
- return id;
- }
- return NULL;
-}
diff --git a/kconfig/lkc.h b/kconfig/lkc.h
index 9eb7c83..531ff7c 100644
--- a/kconfig/lkc.h
+++ b/kconfig/lkc.h
@@ -1,6 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
*/
#ifndef LKC_H
@@ -30,10 +30,6 @@ static inline const char *CONFIG_prefix(void)
#undef CONFIG_
#define CONFIG_ CONFIG_prefix()
-#define TF_COMMAND 0x0001
-#define TF_PARAM 0x0002
-#define TF_OPTION 0x0004
-
enum conf_def_mode {
def_default,
def_yes,
@@ -42,17 +38,6 @@ enum conf_def_mode {
def_random
};
-#define T_OPT_MODULES 1
-#define T_OPT_DEFCONFIG_LIST 2
-#define T_OPT_ALLNOCONFIG_Y 4
-
-struct kconf_id {
- const char *name;
- int token;
- unsigned int flags;
- enum symbol_type stype;
-};
-
extern int yylineno;
void zconfdump(FILE *out);
void zconf_starthelp(void);
@@ -91,7 +76,9 @@ void menu_add_visibility(struct expr *dep);
struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
-void menu_add_option(int token, char *arg);
+void menu_add_option_modules(void);
+void menu_add_option_defconfig_list(void);
+void menu_add_option_allnoconfig_y(void);
void menu_finalize(struct menu *parent);
void menu_set_type(int type);
@@ -103,6 +90,9 @@ void *xrealloc(void *p, size_t size);
char *xstrdup(const char *s);
char *xstrndup(const char *s, size_t n);
+/* zconf.l */
+int yylex(void);
+
struct gstr {
size_t len;
char *s;
@@ -121,6 +111,7 @@ const char *str_get(struct gstr *gs);
/* symbol.c */
void sym_clear_all_valid(void);
struct symbol *sym_choice_default(struct symbol *sym);
+struct property *sym_get_range_prop(struct symbol *sym);
const char *sym_get_string_default(struct symbol *sym);
struct symbol *sym_check_deps(struct symbol *sym);
struct property *prop_alloc(enum prop_type type, struct symbol *sym);
diff --git a/kconfig/lxdialog/checklist.c b/kconfig/lxdialog/checklist.c
index 2e96323..fd161cf 100644
--- a/kconfig/lxdialog/checklist.c
+++ b/kconfig/lxdialog/checklist.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
/*
* checklist.c -- implements the checklist box
*
@@ -5,20 +6,6 @@
* Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension
* Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two
* MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "dialog.h"
diff --git a/kconfig/lxdialog/dialog.h b/kconfig/lxdialog/dialog.h
index 0b00be5..68b565e 100644
--- a/kconfig/lxdialog/dialog.h
+++ b/kconfig/lxdialog/dialog.h
@@ -1,21 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
/*
* dialog.h -- common declarations for all dialog modules
*
* AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <sys/types.h>
diff --git a/kconfig/lxdialog/inputbox.c b/kconfig/lxdialog/inputbox.c
index fe82ff6..6119456 100644
--- a/kconfig/lxdialog/inputbox.c
+++ b/kconfig/lxdialog/inputbox.c
@@ -1,22 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
/*
* inputbox.c -- implements the input box
*
* ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
* MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "dialog.h"
diff --git a/kconfig/lxdialog/menubox.c b/kconfig/lxdialog/menubox.c
index d70cab3..58c2f8a 100644
--- a/kconfig/lxdialog/menubox.c
+++ b/kconfig/lxdialog/menubox.c
@@ -1,22 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
/*
* menubox.c -- implements the menu box
*
* ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
* MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
diff --git a/kconfig/lxdialog/textbox.c b/kconfig/lxdialog/textbox.c
index 88d2818..4e339b1 100644
--- a/kconfig/lxdialog/textbox.c
+++ b/kconfig/lxdialog/textbox.c
@@ -1,22 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
/*
* textbox.c -- implements the text box
*
* ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
* MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "dialog.h"
diff --git a/kconfig/lxdialog/util.c b/kconfig/lxdialog/util.c
index f7abdeb..1b490d4 100644
--- a/kconfig/lxdialog/util.c
+++ b/kconfig/lxdialog/util.c
@@ -1,22 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
/*
* util.c
*
* ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
* MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdarg.h>
diff --git a/kconfig/lxdialog/yesno.c b/kconfig/lxdialog/yesno.c
index cd1223c..bcaac9b 100644
--- a/kconfig/lxdialog/yesno.c
+++ b/kconfig/lxdialog/yesno.c
@@ -1,22 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
/*
* yesno.c -- implements the yes/no box
*
* ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
* MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "dialog.h"
diff --git a/kconfig/mconf.c b/kconfig/mconf.c
index c719f60..3d4bd5e 100644
--- a/kconfig/mconf.c
+++ b/kconfig/mconf.c
@@ -1,6 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
*
* Introduced single menu mode (show all sub-menus in one large tree).
* 2002-11-06 Petr Baudis <pasky@ucw.cz>
diff --git a/kconfig/menu.c b/kconfig/menu.c
index 539ff57..264ba29 100644
--- a/kconfig/menu.c
+++ b/kconfig/menu.c
@@ -1,6 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
*/
#include <ctype.h>
@@ -201,29 +201,26 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep);
}
-void menu_add_option(int token, char *arg)
+void menu_add_option_modules(void)
{
- switch (token) {
- case T_OPT_MODULES:
- if (modules_sym)
- zconf_error("symbol '%s' redefines option 'modules'"
- " already defined by symbol '%s'",
- current_entry->sym->name,
- modules_sym->name
- );
- modules_sym = current_entry->sym;
- break;
- case T_OPT_DEFCONFIG_LIST:
- if (!sym_defconfig_list)
- sym_defconfig_list = current_entry->sym;
- else if (sym_defconfig_list != current_entry->sym)
- zconf_error("trying to redefine defconfig symbol");
- sym_defconfig_list->flags |= SYMBOL_NO_WRITE;
- break;
- case T_OPT_ALLNOCONFIG_Y:
- current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y;
- break;
- }
+ if (modules_sym)
+ zconf_error("symbol '%s' redefines option 'modules' already defined by symbol '%s'",
+ current_entry->sym->name, modules_sym->name);
+ modules_sym = current_entry->sym;
+}
+
+void menu_add_option_defconfig_list(void)
+{
+ if (!sym_defconfig_list)
+ sym_defconfig_list = current_entry->sym;
+ else if (sym_defconfig_list != current_entry->sym)
+ zconf_error("trying to redefine defconfig symbol");
+ sym_defconfig_list->flags |= SYMBOL_NO_WRITE;
+}
+
+void menu_add_option_allnoconfig_y(void)
+{
+ current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y;
}
static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
diff --git a/kconfig/nconf.c b/kconfig/nconf.c
index 93d186e..fb6027a 100644
--- a/kconfig/nconf.c
+++ b/kconfig/nconf.c
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/*
- * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
- * Released under the terms of the GNU GPL v2.0.
+ * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com>
*
* Derived from menuconfig.
- *
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
diff --git a/kconfig/nconf.gui.c b/kconfig/nconf.gui.c
index 88874ac..7be620a 100644
--- a/kconfig/nconf.gui.c
+++ b/kconfig/nconf.gui.c
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
/*
- * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
- * Released under the terms of the GNU GPL v2.0.
+ * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com>
*
* Derived from menuconfig.
- *
*/
#include "nconf.h"
#include "lkc.h"
diff --git a/kconfig/nconf.h b/kconfig/nconf.h
index 2b9e19f..fa5245e 100644
--- a/kconfig/nconf.h
+++ b/kconfig/nconf.h
@@ -1,9 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/*
- * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
- * Released under the terms of the GNU GPL v2.0.
+ * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com>
*
* Derived from menuconfig.
- *
*/
#include <ctype.h>
diff --git a/kconfig/preprocess.c b/kconfig/preprocess.c
index 5ca2df7..592dfbf 100644
--- a/kconfig/preprocess.c
+++ b/kconfig/preprocess.c
@@ -2,6 +2,7 @@
//
// Copyright (C) 2018 Masahiro Yamada <yamada.masahiro@socionext.com>
+#include <ctype.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
@@ -9,6 +10,7 @@
#include <string.h>
#include "list.h"
+#include "lkc.h"
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
@@ -555,8 +557,7 @@ char *expand_string(const char *in)
static bool is_end_of_token(char c)
{
- /* Why are '.' and '/' valid characters for symbols? */
- return !(isalnum(c) || c == '_' || c == '-' || c == '.' || c == '/');
+ return !(isalnum(c) || c == '_' || c == '-');
}
/*
diff --git a/kconfig/symbol.c b/kconfig/symbol.c
index 703b9b8..1f9266d 100644
--- a/kconfig/symbol.c
+++ b/kconfig/symbol.c
@@ -1,6 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
*/
#include <ctype.h>
@@ -61,8 +61,6 @@ const char *sym_type_name(enum symbol_type type)
return "string";
case S_UNKNOWN:
return "unknown";
- case S_OTHER:
- break;
}
return "???";
}
@@ -88,7 +86,7 @@ static struct property *sym_get_default_prop(struct symbol *sym)
return NULL;
}
-static struct property *sym_get_range_prop(struct symbol *sym)
+struct property *sym_get_range_prop(struct symbol *sym)
{
struct property *prop;
@@ -757,7 +755,6 @@ const char *sym_get_string_default(struct symbol *sym)
return str;
case S_STRING:
return str;
- case S_OTHER:
case S_UNKNOWN:
break;
}
diff --git a/kconfig/util.c b/kconfig/util.c
index d999683..2958539 100644
--- a/kconfig/util.c
+++ b/kconfig/util.c
@@ -1,8 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2002-2005 Roman Zippel <zippel@linux-m68k.org>
* Copyright (C) 2002-2005 Sam Ravnborg <sam@ravnborg.org>
- *
- * Released under the terms of the GNU GPL v2.0.
*/
#include <stdarg.h>
diff --git a/kconfig/zconf.l b/kconfig/zconf.l
index 25bd2b8..b2d0a3b 100644
--- a/kconfig/zconf.l
+++ b/kconfig/zconf.l
@@ -1,11 +1,11 @@
-%option nostdinit noyywrap never-interactive full ecs
-%option 8bit nodefault yylineno
-%x COMMAND HELP STRING PARAM ASSIGN_VAL
-%{
+/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
*/
+%option nostdinit noyywrap never-interactive full ecs
+%option 8bit nodefault yylineno
+%x ASSIGN_VAL HELP STRING
+%{
#include <assert.h>
#include <limits.h>
@@ -15,6 +15,9 @@
#include <unistd.h>
#include "lkc.h"
+#include "zconf.tab.h"
+
+#define YY_DECL static int yylex1(void)
#define START_STRSIZE 16
@@ -23,6 +26,8 @@ static struct {
int lineno;
} current_pos;
+static int prev_prev_token = T_EOL;
+static int prev_token = T_EOL;
static char *text;
static int text_size, text_asize;
@@ -73,7 +78,7 @@ static void warn_ignored_character(char chr)
{
fprintf(stderr,
"%s:%d:warning: ignoring unsupported character '%c'\n",
- zconf_curname(), zconf_lineno(), chr);
+ current_file->name, yylineno, chr);
}
%}
@@ -83,54 +88,73 @@ n [A-Za-z0-9_-]
int str = 0;
int ts, i;
-[ \t]*#.*\n |
-[ \t]*\n {
- return T_EOL;
-}
-[ \t]*#.*
-
-
-[ \t]+ {
- BEGIN(COMMAND);
-}
-
-. {
- unput(yytext[0]);
- BEGIN(COMMAND);
-}
-
-
-<COMMAND>{
- {n}+ {
- const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
- current_pos.file = current_file;
- current_pos.lineno = yylineno;
- if (id && id->flags & TF_COMMAND) {
- BEGIN(PARAM);
- yylval.id = id;
- return id->token;
- }
- alloc_string(yytext, yyleng);
- yylval.string = text;
- return T_VARIABLE;
- }
- ({n}|$)+ {
- /* this token includes at least one '$' */
- yylval.string = expand_token(yytext, yyleng);
- if (strlen(yylval.string))
- return T_VARIABLE;
- free(yylval.string);
- }
- "=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_RECURSIVE; return T_ASSIGN; }
- ":=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_SIMPLE; return T_ASSIGN; }
- "+=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_APPEND; return T_ASSIGN; }
- [[:blank:]]+
- . warn_ignored_character(*yytext);
- \n {
- BEGIN(INITIAL);
- return T_EOL;
- }
-}
+#.* /* ignore comment */
+[ \t]* /* whitespaces */
+\\\n /* escaped new line */
+\n return T_EOL;
+"allnoconfig_y" return T_ALLNOCONFIG_Y;
+"bool" return T_BOOL;
+"choice" return T_CHOICE;
+"comment" return T_COMMENT;
+"config" return T_CONFIG;
+"def_bool" return T_DEF_BOOL;
+"def_tristate" return T_DEF_TRISTATE;
+"default" return T_DEFAULT;
+"defconfig_list" return T_DEFCONFIG_LIST;
+"depends" return T_DEPENDS;
+"endchoice" return T_ENDCHOICE;
+"endif" return T_ENDIF;
+"endmenu" return T_ENDMENU;
+"help"|"---help---" return T_HELP;
+"hex" return T_HEX;
+"if" return T_IF;
+"imply" return T_IMPLY;
+"int" return T_INT;
+"mainmenu" return T_MAINMENU;
+"menu" return T_MENU;
+"menuconfig" return T_MENUCONFIG;
+"modules" return T_MODULES;
+"on" return T_ON;
+"option" return T_OPTION;
+"optional" return T_OPTIONAL;
+"prompt" return T_PROMPT;
+"range" return T_RANGE;
+"select" return T_SELECT;
+"source" return T_SOURCE;
+"string" return T_STRING;
+"tristate" return T_TRISTATE;
+"visible" return T_VISIBLE;
+"||" return T_OR;
+"&&" return T_AND;
+"=" return T_EQUAL;
+"!=" return T_UNEQUAL;
+"<" return T_LESS;
+"<=" return T_LESS_EQUAL;
+">" return T_GREATER;
+">=" return T_GREATER_EQUAL;
+"!" return T_NOT;
+"(" return T_OPEN_PAREN;
+")" return T_CLOSE_PAREN;
+":=" return T_COLON_EQUAL;
+"+=" return T_PLUS_EQUAL;
+\"|\' {
+ str = yytext[0];
+ new_string();
+ BEGIN(STRING);
+ }
+{n}+ {
+ alloc_string(yytext, yyleng);
+ yylval.string = text;
+ return T_WORD;
+ }
+({n}|$)+ {
+ /* this token includes at least one '$' */
+ yylval.string = expand_token(yytext, yyleng);
+ if (strlen(yylval.string))
+ return T_WORD;
+ free(yylval.string);
+ }
+. warn_ignored_character(*yytext);
<ASSIGN_VAL>{
[^[:blank:]\n]+.* {
@@ -142,71 +166,17 @@ n [A-Za-z0-9_-]
.
}
-<PARAM>{
- "&&" return T_AND;
- "||" return T_OR;
- "(" return T_OPEN_PAREN;
- ")" return T_CLOSE_PAREN;
- "!" return T_NOT;
- "=" return T_EQUAL;
- "!=" return T_UNEQUAL;
- "<=" return T_LESS_EQUAL;
- ">=" return T_GREATER_EQUAL;
- "<" return T_LESS;
- ">" return T_GREATER;
- \"|\' {
- str = yytext[0];
- new_string();
- BEGIN(STRING);
- }
- \n BEGIN(INITIAL); return T_EOL;
- ({n}|[/.])+ {
- const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
- if (id && id->flags & TF_PARAM) {
- yylval.id = id;
- return id->token;
- }
- alloc_string(yytext, yyleng);
- yylval.string = text;
- return T_WORD;
- }
- ({n}|[/.$])+ {
- /* this token includes at least one '$' */
- yylval.string = expand_token(yytext, yyleng);
- if (strlen(yylval.string))
- return T_WORD;
- free(yylval.string);
- }
- #.* /* comment */
- \\\n ;
- [[:blank:]]+
- . warn_ignored_character(*yytext);
- <<EOF>> {
- BEGIN(INITIAL);
- }
-}
-
<STRING>{
"$".* append_expanded_string(yytext);
- [^$'"\\\n]+/\n {
- append_string(yytext, yyleng);
- yylval.string = text;
- return T_WORD_QUOTE;
- }
[^$'"\\\n]+ {
append_string(yytext, yyleng);
}
- \\.?/\n {
- append_string(yytext + 1, yyleng - 1);
- yylval.string = text;
- return T_WORD_QUOTE;
- }
\\.? {
append_string(yytext + 1, yyleng - 1);
}
\'|\" {
if (str == yytext[0]) {
- BEGIN(PARAM);
+ BEGIN(INITIAL);
yylval.string = text;
return T_WORD_QUOTE;
} else
@@ -216,11 +186,15 @@ n [A-Za-z0-9_-]
fprintf(stderr,
"%s:%d:warning: multi-line strings not supported\n",
zconf_curname(), zconf_lineno());
+ unput('\n');
BEGIN(INITIAL);
- return T_EOL;
+ yylval.string = text;
+ return T_WORD_QUOTE;
}
<<EOF>> {
BEGIN(INITIAL);
+ yylval.string = text;
+ return T_WORD_QUOTE;
}
}
@@ -271,6 +245,12 @@ n [A-Za-z0-9_-]
}
<<EOF>> {
+ BEGIN(INITIAL);
+
+ if (prev_token != T_EOL && prev_token != T_HELPTEXT)
+ fprintf(stderr, "%s:%d:warning: no new line at end of file\n",
+ current_file->name, yylineno);
+
if (current_file) {
zconf_endfile();
return T_EOL;
@@ -280,6 +260,41 @@ n [A-Za-z0-9_-]
}
%%
+
+/* second stage lexer */
+int yylex(void)
+{
+ int token;
+
+repeat:
+ token = yylex1();
+
+ if (prev_token == T_EOL || prev_token == T_HELPTEXT) {
+ if (token == T_EOL) {
+ /* Do not pass unneeded T_EOL to the parser. */
+ goto repeat;
+ } else {
+ /*
+ * For the parser, update file/lineno at the first token
+ * of each statement. Generally, \n is a statement
+ * terminator in Kconfig, but it is not always true
+ * because \n could be escaped by a backslash.
+ */
+ current_pos.file = current_file;
+ current_pos.lineno = yylineno;
+ }
+ }
+
+ if (prev_prev_token == T_EOL && prev_token == T_WORD &&
+ (token == T_EQUAL || token == T_COLON_EQUAL || token == T_PLUS_EQUAL))
+ BEGIN(ASSIGN_VAL);
+
+ prev_prev_token = prev_token;
+ prev_token = token;
+
+ return token;
+}
+
static char *expand_token(const char *in, size_t n)
{
char *out;
diff --git a/kconfig/zconf.y b/kconfig/zconf.y
index 9d331da..60936c7 100644
--- a/kconfig/zconf.y
+++ b/kconfig/zconf.y
@@ -1,8 +1,8 @@
-%{
+/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
- * Released under the terms of the GNU GPL v2.0.
*/
+%{
#include <ctype.h>
#include <stdarg.h>
@@ -20,66 +20,68 @@
int cdebug = PRINTD;
-int yylex(void);
static void yyerror(const char *err);
static void zconfprint(const char *err, ...);
static void zconf_error(const char *err, ...);
-static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken);
+static bool zconf_endtoken(const char *tokenname,
+ const char *expected_tokenname);
struct symbol *symbol_hash[SYMBOL_HASHSIZE];
static struct menu *current_menu, *current_entry;
%}
-%expect 30
%union
{
char *string;
- struct file *file;
struct symbol *symbol;
struct expr *expr;
struct menu *menu;
- const struct kconf_id *id;
+ enum symbol_type type;
enum variable_flavor flavor;
}
-%token <id>T_MAINMENU
-%token <id>T_MENU
-%token <id>T_ENDMENU
-%token <id>T_SOURCE
-%token <id>T_CHOICE
-%token <id>T_ENDCHOICE
-%token <id>T_COMMENT
-%token <id>T_CONFIG
-%token <id>T_MENUCONFIG
-%token <id>T_HELP
%token <string> T_HELPTEXT
-%token <id>T_IF
-%token <id>T_ENDIF
-%token <id>T_DEPENDS
-%token <id>T_OPTIONAL
-%token <id>T_PROMPT
-%token <id>T_TYPE
-%token <id>T_DEFAULT
-%token <id>T_SELECT
-%token <id>T_IMPLY
-%token <id>T_RANGE
-%token <id>T_VISIBLE
-%token <id>T_OPTION
-%token <id>T_ON
%token <string> T_WORD
%token <string> T_WORD_QUOTE
-%token T_UNEQUAL
-%token T_LESS
-%token T_LESS_EQUAL
-%token T_GREATER
-%token T_GREATER_EQUAL
+%token T_ALLNOCONFIG_Y
+%token T_BOOL
+%token T_CHOICE
%token T_CLOSE_PAREN
+%token T_COLON_EQUAL
+%token T_COMMENT
+%token T_CONFIG
+%token T_DEFAULT
+%token T_DEFCONFIG_LIST
+%token T_DEF_BOOL
+%token T_DEF_TRISTATE
+%token T_DEPENDS
+%token T_ENDCHOICE
+%token T_ENDIF
+%token T_ENDMENU
+%token T_HELP
+%token T_HEX
+%token T_IF
+%token T_IMPLY
+%token T_INT
+%token T_MAINMENU
+%token T_MENU
+%token T_MENUCONFIG
+%token T_MODULES
+%token T_ON
%token T_OPEN_PAREN
+%token T_OPTION
+%token T_OPTIONAL
+%token T_PLUS_EQUAL
+%token T_PROMPT
+%token T_RANGE
+%token T_SELECT
+%token T_SOURCE
+%token T_STRING
+%token T_TRISTATE
+%token T_VISIBLE
%token T_EOL
-%token <string> T_VARIABLE
-%token <flavor> T_ASSIGN
%token <string> T_ASSIGN_VAL
%left T_OR
@@ -91,12 +93,13 @@ static struct menu *current_menu, *current_entry;
%type <string> prompt
%type <symbol> nonconst_symbol
%type <symbol> symbol
+%type <type> type logic_type default
%type <expr> expr
%type <expr> if_expr
-%type <id> end
-%type <id> option_name
+%type <string> end
%type <menu> if_entry menu_entry choice_entry
-%type <string> symbol_option_arg word_opt assign_val
+%type <string> word_opt assign_val
+%type <flavor> assign_op
%destructor {
fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -105,15 +108,8 @@ static struct menu *current_menu, *current_entry;
menu_end_menu();
} if_entry menu_entry choice_entry
-%{
-/* Include kconf_id.c here so it can see the token constants. */
-#include "kconf_id.c"
-%}
-
%%
-input: nl start | start;
-
-start: mainmenu_stmt stmt_list | stmt_list;
+input: mainmenu_stmt stmt_list | stmt_list;
/* mainmenu entry */
@@ -127,22 +123,12 @@ stmt_list:
| stmt_list common_stmt
| stmt_list choice_stmt
| stmt_list menu_stmt
- | stmt_list end { zconf_error("unexpected end statement"); }
| stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); }
- | stmt_list option_name error T_EOL
-{
- zconf_error("unexpected option \"%s\"", $2->name);
-}
| stmt_list error T_EOL { zconf_error("invalid statement"); }
;
-option_name:
- T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_IMPLY | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE
-;
-
common_stmt:
- T_EOL
- | if_stmt
+ if_stmt
| comment_stmt
| config_stmt
| menuconfig_stmt
@@ -150,12 +136,6 @@ common_stmt:
| assignment_stmt
;
-option_error:
- T_WORD error T_EOL { zconf_error("unknown option \"%s\"", $1); }
- | error T_EOL { zconf_error("invalid option"); }
-;
-
-
/* config/menuconfig entry */
config_entry_start: T_CONFIG nonconst_symbol T_EOL
@@ -189,19 +169,16 @@ menuconfig_stmt: menuconfig_entry_start config_option_list
config_option_list:
/* empty */
| config_option_list config_option
- | config_option_list symbol_option
| config_option_list depends
| config_option_list help
- | config_option_list option_error
- | config_option_list T_EOL
;
-config_option: T_TYPE prompt_stmt_opt T_EOL
+config_option: type prompt_stmt_opt T_EOL
{
- menu_set_type($1->stype);
+ menu_set_type($1);
printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
zconf_curname(), zconf_lineno(),
- $1->stype);
+ $1);
};
config_option: T_PROMPT prompt if_expr T_EOL
@@ -210,14 +187,14 @@ config_option: T_PROMPT prompt if_expr T_EOL
printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
};
-config_option: T_DEFAULT expr if_expr T_EOL
+config_option: default expr if_expr T_EOL
{
menu_add_expr(P_DEFAULT, $2, $3);
- if ($1->stype != S_UNKNOWN)
- menu_set_type($1->stype);
+ if ($1 != S_UNKNOWN)
+ menu_set_type($1);
printd(DEBUG_PARSE, "%s:%d:default(%u)\n",
zconf_curname(), zconf_lineno(),
- $1->stype);
+ $1);
};
config_option: T_SELECT nonconst_symbol if_expr T_EOL
@@ -238,27 +215,20 @@ config_option: T_RANGE symbol symbol if_expr T_EOL
printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
};
-symbol_option: T_OPTION symbol_option_list T_EOL
-;
+config_option: T_OPTION T_MODULES T_EOL
+{
+ menu_add_option_modules();
+};
-symbol_option_list:
- /* empty */
- | symbol_option_list T_WORD symbol_option_arg
+config_option: T_OPTION T_DEFCONFIG_LIST T_EOL
{
- const struct kconf_id *id = kconf_id_lookup($2, strlen($2));
- if (id && id->flags & TF_OPTION) {
- menu_add_option(id->token, $3);
- free($3);
- }
- else
- zconfprint("warning: ignoring unknown option %s", $2);
- free($2);
+ menu_add_option_defconfig_list();
};
-symbol_option_arg:
- /* empty */ { $$ = NULL; }
- | T_EQUAL prompt { $$ = $2; }
-;
+config_option: T_OPTION T_ALLNOCONFIG_Y T_EOL
+{
+ menu_add_option_allnoconfig_y();
+};
/* choice entry */
@@ -279,7 +249,7 @@ choice_entry: choice choice_option_list
choice_end: end
{
- if (zconf_endtoken($1, T_CHOICE, T_ENDCHOICE)) {
+ if (zconf_endtoken($1, "choice")) {
menu_end_menu();
printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
}
@@ -293,8 +263,6 @@ choice_option_list:
| choice_option_list choice_option
| choice_option_list depends
| choice_option_list help
- | choice_option_list T_EOL
- | choice_option_list option_error
;
choice_option: T_PROMPT prompt if_expr T_EOL
@@ -303,15 +271,11 @@ choice_option: T_PROMPT prompt if_expr T_EOL
printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
};
-choice_option: T_TYPE prompt_stmt_opt T_EOL
+choice_option: logic_type prompt_stmt_opt T_EOL
{
- if ($1->stype == S_BOOLEAN || $1->stype == S_TRISTATE) {
- menu_set_type($1->stype);
- printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
- zconf_curname(), zconf_lineno(),
- $1->stype);
- } else
- YYERROR;
+ menu_set_type($1);
+ printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
+ zconf_curname(), zconf_lineno(), $1);
};
choice_option: T_OPTIONAL T_EOL
@@ -322,14 +286,26 @@ choice_option: T_OPTIONAL T_EOL
choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL
{
- if ($1->stype == S_UNKNOWN) {
- menu_add_symbol(P_DEFAULT, $2, $3);
- printd(DEBUG_PARSE, "%s:%d:default\n",
- zconf_curname(), zconf_lineno());
- } else
- YYERROR;
+ menu_add_symbol(P_DEFAULT, $2, $3);
+ printd(DEBUG_PARSE, "%s:%d:default\n",
+ zconf_curname(), zconf_lineno());
};
+type:
+ logic_type
+ | T_INT { $$ = S_INT; }
+ | T_HEX { $$ = S_HEX; }
+ | T_STRING { $$ = S_STRING; }
+
+logic_type:
+ T_BOOL { $$ = S_BOOLEAN; }
+ | T_TRISTATE { $$ = S_TRISTATE; }
+
+default:
+ T_DEFAULT { $$ = S_UNKNOWN; }
+ | T_DEF_BOOL { $$ = S_BOOLEAN; }
+ | T_DEF_TRISTATE { $$ = S_TRISTATE; }
+
choice_block:
/* empty */
| choice_block common_stmt
@@ -347,20 +323,13 @@ if_entry: T_IF expr T_EOL
if_end: end
{
- if (zconf_endtoken($1, T_IF, T_ENDIF)) {
+ if (zconf_endtoken($1, "if")) {
menu_end_menu();
printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
}
};
-if_stmt: if_entry if_block if_end
-;
-
-if_block:
- /* empty */
- | if_block common_stmt
- | if_block menu_stmt
- | if_block choice_stmt
+if_stmt: if_entry stmt_list if_end
;
/* menu entry */
@@ -372,27 +341,26 @@ menu: T_MENU prompt T_EOL
printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
};
-menu_entry: menu visibility_list depends_list
+menu_entry: menu menu_option_list
{
$$ = menu_add_menu();
};
menu_end: end
{
- if (zconf_endtoken($1, T_MENU, T_ENDMENU)) {
+ if (zconf_endtoken($1, "menu")) {
menu_end_menu();
printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
}
};
-menu_stmt: menu_entry menu_block menu_end
+menu_stmt: menu_entry stmt_list menu_end
;
-menu_block:
+menu_option_list:
/* empty */
- | menu_block common_stmt
- | menu_block menu_stmt
- | menu_block choice_stmt
+ | menu_option_list visible
+ | menu_option_list depends
;
source_stmt: T_SOURCE prompt T_EOL
@@ -411,7 +379,12 @@ comment: T_COMMENT prompt T_EOL
printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
};
-comment_stmt: comment depends_list
+comment_stmt: comment comment_option_list
+;
+
+comment_option_list:
+ /* empty */
+ | comment_option_list depends
;
/* help option */
@@ -440,13 +413,6 @@ help: help_start T_HELPTEXT
/* depends option */
-depends_list:
- /* empty */
- | depends_list depends
- | depends_list T_EOL
- | depends_list option_error
-;
-
depends: T_DEPENDS T_ON expr T_EOL
{
menu_add_dep($3);
@@ -454,14 +420,7 @@ depends: T_DEPENDS T_ON expr T_EOL
};
/* visibility option */
-
-visibility_list:
- /* empty */
- | visibility_list visible
- | visibility_list T_EOL
-;
-
-visible: T_VISIBLE if_expr
+visible: T_VISIBLE if_expr T_EOL
{
menu_add_visibility($2);
};
@@ -479,14 +438,9 @@ prompt: T_WORD
| T_WORD_QUOTE
;
-end: T_ENDMENU T_EOL { $$ = $1; }
- | T_ENDCHOICE T_EOL { $$ = $1; }
- | T_ENDIF T_EOL { $$ = $1; }
-;
-
-nl:
- T_EOL
- | nl T_EOL
+end: T_ENDMENU T_EOL { $$ = "menu"; }
+ | T_ENDCHOICE T_EOL { $$ = "choice"; }
+ | T_ENDIF T_EOL { $$ = "if"; }
;
if_expr: /* empty */ { $$ = NULL; }
@@ -518,7 +472,13 @@ word_opt: /* empty */ { $$ = NULL; }
/* assignment statement */
-assignment_stmt: T_VARIABLE T_ASSIGN assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); }
+assignment_stmt: T_WORD assign_op assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); }
+
+assign_op:
+ T_EQUAL { $$ = VAR_RECURSIVE; }
+ | T_COLON_EQUAL { $$ = VAR_SIMPLE; }
+ | T_PLUS_EQUAL { $$ = VAR_APPEND; }
+;
assign_val:
/* empty */ { $$ = xstrdup(""); };
@@ -535,10 +495,9 @@ void conf_parse(const char *name)
zconf_initscan(name);
_menu_init();
-#if YYDEBUG
+
if (getenv("ZCONF_DEBUG"))
yydebug = 1;
-#endif
yyparse();
/* Variables are expanded in the parse phase. We can free them here. */
@@ -564,35 +523,21 @@ void conf_parse(const char *name)
sym_set_change_count(1);
}
-static const char *zconf_tokenname(int token)
-{
- switch (token) {
- case T_MENU: return "menu";
- case T_ENDMENU: return "endmenu";
- case T_CHOICE: return "choice";
- case T_ENDCHOICE: return "endchoice";
- case T_IF: return "if";
- case T_ENDIF: return "endif";
- case T_DEPENDS: return "depends";
- case T_VISIBLE: return "visible";
- }
- return "<token>";
-}
-
-static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken)
+static bool zconf_endtoken(const char *tokenname,
+ const char *expected_tokenname)
{
- if (id->token != endtoken) {
+ if (strcmp(tokenname, expected_tokenname)) {
zconf_error("unexpected '%s' within %s block",
- id->name, zconf_tokenname(starttoken));
+ tokenname, expected_tokenname);
yynerrs++;
return false;
}
if (current_menu->file != current_file) {
zconf_error("'%s' in different file than '%s'",
- id->name, zconf_tokenname(starttoken));
+ tokenname, expected_tokenname);
fprintf(stderr, "%s:%d: location of the '%s'\n",
current_menu->file->name, current_menu->lineno,
- zconf_tokenname(starttoken));
+ expected_tokenname);
yynerrs++;
return false;
}
@@ -782,10 +727,5 @@ void zconfdump(FILE *out)
}
}
-#include "zconf.lex.c"
#include "util.c"
-#include "confdata.c"
-#include "expr.c"
-#include "symbol.c"
#include "menu.c"
-#include "preprocess.c"