summaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/lexer.l
Commit message (Collapse)AuthorAgeFilesLines
* kconfig: remove 'optional' property supportMasahiro Yamada2024-05-021-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'choice' statement is primarily used to exclusively select one option, but the 'optional' property allows all entries to be disabled. In the following example, both A and B can be disabled simultaneously: choice prompt "choose A, B, or nothing" optional config A bool "A" config B bool "B" endchoice You can achieve the equivalent outcome by other means. A common solution is to add another option to guard the choice block. In the following example, you can set ENABLE_A_B_CHOICE=n to disable the entire choice block: choice prompt "choose A or B" depends on ENABLE_A_B_CHOICE config A bool "A" config B bool "B" endchoice Another approach is to insert one more entry: choice prompt "choose A, B, or disable both" config A bool "A" config B bool "B" config DISABLE_A_AND_B bool "choose this to disable both A and B" endchoice Some real examples are DEBUG_INFO_NONE, INITRAMFS_COMPRESSION_NONE, LTO_NONE, etc. The 'optional' property is even more unnecessary for a tristate choice. Without the 'optional' property, you can disable A and B; you can set 'm' in the choice prompt, and disable A and B individually: choice prompt "choose one built-in or make them modular" config A tristate "A" config B tristate "B" endchoice In conclusion, the 'optional' property was unneeded. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <n.schier@avm.de>
* kconfig: change file_lookup() to return the file nameMasahiro Yamada2024-02-191-3/+2
| | | | | | | | | | | | Currently, file_lookup() returns a pointer to (struct file), but the callers use only file->name. Make it return the ->name member directly. This adjustment encapsulates struct file and file_list as internal implementation. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: move the file and lineno in struct file to struct bufferMasahiro Yamada2024-02-191-29/+23
| | | | | | | | | | | | | | struct file has two link nodes, 'next' and 'parent'. The former is used to link files in the 'file_list' linked list, which manages the list of Kconfig files seen so far. The latter is used to link files in the 'current_file' linked list, which manages the inclusion ("source") tree. The latter should be tracked together with the lexer state. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: replace remaining current_file->name with cur_filenameMasahiro Yamada2024-02-191-2/+2
| | | | | | Replace the remaining current_file->name in the lexer context. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: do not delay the cur_filename updateMasahiro Yamada2024-02-191-10/+7
| | | | | | | | Currently, cur_filename is updated at the first token of each statement. However, this seems unnecessary based on my understanding; the parser can use the same variable as the lexer tracks. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: replace file->name with name in zconf_nextfile()Masahiro Yamada2024-02-191-5/+5
| | | | | | The 'file->name' and 'name' are the same in this function. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: remove zconf_curname() and zconf_lineno()Masahiro Yamada2024-02-191-15/+5
| | | | | | | | | | Now zconf_curname() and zconf_lineno() are so simple that they just return cur_filename, cur_lineno, respectively. Remove these functions, and then use cur_filename and cur_lineno directly. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: replace current_pos with separate cur_{filename,lineno}Masahiro Yamada2024-02-191-8/+17
| | | | | | | | | | | | | | | | Replace current_pos with separate variables representing the file name and the line number, respectively. No functional change is intended. By the way, you might wonder why the "<none>" fallback exists in zconf_curname(). menu_add_symbol() saves the current file and the line number. It is intended to be called only during the yyparse() time. However, menu_finalize() calls it, where there is no file being parsed. This is a long-standing hack that should be fixed later. I left a FIXME comment. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: split preprocessor prototypes into preprocess.hMasahiro Yamada2024-02-191-0/+2
| | | | | | | These are needed only for the parse stage. Move the prototypes into a separate header to make sure they are not used after that. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: fix infinite loop when expanding a macro at the end of fileMasahiro Yamada2024-02-191-2/+5
| | | | | | | | | | | | | | | A macro placed at the end of a file with no newline causes an infinite loop. [Test Kconfig] $(info,hello) \ No newline at end of file I realized that flex-provided input() returns 0 instead of EOF when it reaches the end of a file. Fixes: 104daea149c4 ("kconfig: reference environment variables directly and remove 'option env='") Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: fix line number in recursive inclusion detectionMasahiro Yamada2024-02-191-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | The error message shows a wrong line number if the 'source' directive is wrapped to the following line. [Test Code] source \ "Kconfig" This results in the following error message: Recursive inclusion detected. Inclusion path: current file : Kconfig included from: Kconfig:2 The correct message should be as follows: Recursive inclusion detected. Inclusion path: current file : Kconfig included from: Kconfig:1 Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: remove unneeded buffer allocation in zconf_initscan()Masahiro Yamada2024-02-191-16/+13
| | | | | | | | | | | In Kconfig, there is a stack to save the lexer state for each inclusion level. Currently, it operates as an empty stack, with the 'current_buf' always pointing to an empty buffer. There is no need to preallocate the buffer. Change it to a full stack. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: rename a variable in the lexer to a clearer nameMasahiro Yamada2021-09-301-3/+3
| | | | | | | | | | | | | | | In Kconfig, like Python, you can enclose a string by double-quotes or single-quotes. So, both "foo" and 'foo' are allowed. The variable, "str", is used to remember whether the string started with a double-quote or a single-quote because open/closing quotation marks must match. The name "str" is too generic to understand the intent. Rename it to "open_quote", which is easier to understand. The type should be 'char'. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Boris Kolpackov <boris@codesynthesis.com>
* kconfig: narrow the scope of variables in the lexerMasahiro Yamada2021-09-301-1/+2
| | | | | | | | | The variables, "ts" and "i", are used locally in the action of the [ \t]+ pattern in the <HELP> start state. Define them where they are used. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: change "modules" from sub-option to first-level attributeMasahiro Yamada2021-04-141-1/+0
| | | | | | | | Now "modules" is the only member of the "option" property. Remove "option", and move "modules" to the top level property. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: remove allnoconfig_y optionMasahiro Yamada2021-04-141-1/+0
| | | | | | | Now that the only user, CONFIG_EMBEDDED has stopped using this option, remove it entirely. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: change defconfig_list option to environment variableMasahiro Yamada2021-04-141-1/+0
| | | | | | | | | | | | | | | | "defconfig_list" is a weird option that defines a static symbol that declares the list of base config files in case the .config does not exist yet. This is quite different from other normal symbols; we just abused the "string" type and the "default" properties to list out the input files. They must be fixed values since these are searched for and loaded in the parse stage. It is an ugly hack, and should not exist in the first place. Providing this feature as an environment variable is a saner approach. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: clean up header inclusionBoris Kolpackov2020-12-081-1/+0
| | | | | | | | - Add missing includes. - Remove no longer necessary includes. Signed-off-by: Boris Kolpackov <boris@codesynthesis.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: add 'static' to some file-local dataMasahiro Yamada2020-08-141-1/+1
| | | | | | | | Fix some warnings from sparce like follows: warning: symbol '...' was not declared. Should it be static? Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: remove '---help---' supportMasahiro Yamada2020-08-141-1/+1
| | | | | | | The conversion is done. No more user of '---help---'. Cc: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
* kconfig: use snprintf for formatting pathnamesJacob Garber2019-05-141-1/+2
| | | | | | | | | | Valid pathnames will never exceed PATH_MAX, but these file names are unsanitized and can cause buffer overflow if set incorrectly. Use snprintf to avoid this. This was flagged during a Coverity scan of the coreboot project, which also uses kconfig for its build system. Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
* kconfig: rename zconf.y to parser.yMasahiro Yamada2019-02-131-1/+1
| | | | | | Use a more logical name. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
* kconfig: rename zconf.l to lexer.lMasahiro Yamada2019-02-131-0/+470
Use a more logical name. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>