History log of /linux-master/scripts/kconfig/lexer.l
Revision Date Author Comments
# 5b058034 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: change file_lookup() to return the file name

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>


# 8facc5f3 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: move the file and lineno in struct file to struct buffer

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>


# 4ff7ceae 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: replace remaining current_file->name with cur_filename

Replace the remaining current_file->name in the lexer context.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# d3e4a68f 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: do not delay the cur_filename update

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>


# fe273c6f 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: replace file->name with name in zconf_nextfile()

The 'file->name' and 'name' are the same in this function.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 1d7c4f10 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove zconf_curname() and zconf_lineno()

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>


# 52907c07 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: replace current_pos with separate cur_{filename,lineno}

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>


# d3d16228 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: split preprocessor prototypes into preprocess.h

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>


# af8bbce9 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: fix infinite loop when expanding a macro at the end of file

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>


# 93c432e8 07-Jan-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: fix line number in recursive inclusion detection

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>


# 12e3342f 07-Jan-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove unneeded buffer allocation in zconf_initscan()

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>


# 6988f70c 27-Sep-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: rename a variable in the lexer to a clearer name

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>


# 65017d83 27-Sep-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: narrow the scope of variables in the lexer

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>


# 6dd85ff1 13-Mar-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: change "modules" from sub-option to first-level attribute

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>


# ab838577 13-Mar-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove allnoconfig_y option

Now that the only user, CONFIG_EMBEDDED has stopped using this option,
remove it entirely.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# b75b0a81 13-Mar-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: change defconfig_list option to environment variable

"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>


# 78cb0907 23-Nov-2020 Boris Kolpackov <boris@codesynthesis.com>

kconfig: clean up header inclusion

- Add missing includes.
- Remove no longer necessary includes.

Signed-off-by: Boris Kolpackov <boris@codesynthesis.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# d41809ff 28-Jul-2020 Masahiro Yamada <masahiroy@kernel.org>

kconfig: add 'static' to some file-local data

Fix some warnings from sparce like follows:

warning: symbol '...' was not declared. Should it be static?

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# f70f74d1 16-Jun-2020 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove '---help---' support

The conversion is done. No more user of '---help---'.

Cc: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# b9d1a8e9 10-May-2019 Jacob Garber <jgarber1@ualberta.ca>

kconfig: use snprintf for formatting pathnames

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>


# 769a1c02 24-Jan-2019 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: rename zconf.y to parser.y

Use a more logical name.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 981e545a 24-Jan-2019 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: rename zconf.l to lexer.l

Use a more logical name.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>