Commit a702a617 authored by Masahiro Yamada's avatar Masahiro Yamada

kconfig: add 'filename' and 'lineno' built-in variables

The special variables, $(filename) and $(lineno), are expanded to a
file name and its line number being parsed, respectively.
Suggested-by: default avatarRandy Dunlap <rdunlap@infradead.org>
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
parent 1d6272e6
......@@ -114,6 +114,11 @@ static char *do_error_if(int argc, char *argv[])
return NULL;
}
static char *do_filename(int argc, char *argv[])
{
return xstrdup(current_file->name);
}
static char *do_info(int argc, char *argv[])
{
printf("%s\n", argv[0]);
......@@ -121,6 +126,15 @@ static char *do_info(int argc, char *argv[])
return xstrdup("");
}
static char *do_lineno(int argc, char *argv[])
{
char buf[16];
sprintf(buf, "%d", yylineno);
return xstrdup(buf);
}
static char *do_shell(int argc, char *argv[])
{
FILE *p;
......@@ -173,7 +187,9 @@ static char *do_warning_if(int argc, char *argv[])
static const struct function function_table[] = {
/* Name MIN MAX Function */
{ "error-if", 2, 2, do_error_if },
{ "filename", 0, 0, do_filename },
{ "info", 1, 1, do_info },
{ "lineno", 0, 0, do_lineno },
{ "shell", 1, 1, do_shell },
{ "warning-if", 2, 2, do_warning_if },
};
......
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