diff options
author | Andreas Ruprecht <andreas.ruprecht@fau.de> | 2015-07-12 03:41:50 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.com> | 2015-08-19 11:05:39 -0400 |
commit | c2264564df3d70723c6d6eb96c18b99698c112fd (patch) | |
tree | 92846df16c80a4b8f85666bbfb953ed959ca75fc /scripts/kconfig | |
parent | 35ffd08d9bc92b5d56f6536406c379d82a757e7a (diff) |
kconfig: warn of unhandled characters in Kconfig commands
In Kconfig, definitions of options take the following form:
"<COMMAND> <PARAM> <PARAM> ...". COMMANDs and PARAMs are treated
slightly different by the underlying parser.
While commit 2e0d737fc76f ("kconfig: don't silently ignore unhandled
characters") introduced a warning for unsupported characters around
PARAMs, it does not cover situations where a COMMAND has additional
characters before it.
This change makes Kconfig emit a warning if superfluous characters
are found before COMMANDs. As the 'help' statement sometimes is
written as '---help---', the '-' character would now also be regarded
as unhandled and generate a warning. To avoid that, '-' is added to
the list of allowed characters, and the token '---help---' is included
in the zconf.gperf file.
Reported-by: Valentin Rothberg <valentinrothberg@gmail.com>
Signed-off-by: Andreas Ruprecht <andreas.ruprecht@fau.de>
Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>
Tested-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.com>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r-- | scripts/kconfig/zconf.gperf | 1 | ||||
-rw-r--r-- | scripts/kconfig/zconf.l | 20 |
2 files changed, 12 insertions, 9 deletions
diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf index b6ac02d604f1..ac498f01b449 100644 --- a/scripts/kconfig/zconf.gperf +++ b/scripts/kconfig/zconf.gperf | |||
@@ -22,6 +22,7 @@ comment, T_COMMENT, TF_COMMAND | |||
22 | config, T_CONFIG, TF_COMMAND | 22 | config, T_CONFIG, TF_COMMAND |
23 | menuconfig, T_MENUCONFIG, TF_COMMAND | 23 | menuconfig, T_MENUCONFIG, TF_COMMAND |
24 | help, T_HELP, TF_COMMAND | 24 | help, T_HELP, TF_COMMAND |
25 | ---help---, T_HELP, TF_COMMAND | ||
25 | if, T_IF, TF_COMMAND|TF_PARAM | 26 | if, T_IF, TF_COMMAND|TF_PARAM |
26 | endif, T_ENDIF, TF_COMMAND | 27 | endif, T_ENDIF, TF_COMMAND |
27 | depends, T_DEPENDS, TF_COMMAND | 28 | depends, T_DEPENDS, TF_COMMAND |
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 200a3fe30091..c410d257da06 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -66,9 +66,16 @@ static void alloc_string(const char *str, int size) | |||
66 | memcpy(text, str, size); | 66 | memcpy(text, str, size); |
67 | text[size] = 0; | 67 | text[size] = 0; |
68 | } | 68 | } |
69 | |||
70 | static void warn_ignored_character(char chr) | ||
71 | { | ||
72 | fprintf(stderr, | ||
73 | "%s:%d:warning: ignoring unsupported character '%c'\n", | ||
74 | zconf_curname(), zconf_lineno(), chr); | ||
75 | } | ||
69 | %} | 76 | %} |
70 | 77 | ||
71 | n [A-Za-z0-9_] | 78 | n [A-Za-z0-9_-] |
72 | 79 | ||
73 | %% | 80 | %% |
74 | int str = 0; | 81 | int str = 0; |
@@ -106,7 +113,7 @@ n [A-Za-z0-9_] | |||
106 | zconflval.string = text; | 113 | zconflval.string = text; |
107 | return T_WORD; | 114 | return T_WORD; |
108 | } | 115 | } |
109 | . | 116 | . warn_ignored_character(*yytext); |
110 | \n { | 117 | \n { |
111 | BEGIN(INITIAL); | 118 | BEGIN(INITIAL); |
112 | current_file->lineno++; | 119 | current_file->lineno++; |
@@ -132,8 +139,7 @@ n [A-Za-z0-9_] | |||
132 | BEGIN(STRING); | 139 | BEGIN(STRING); |
133 | } | 140 | } |
134 | \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; | 141 | \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; |
135 | --- /* ignore */ | 142 | ({n}|[/.])+ { |
136 | ({n}|[-/.])+ { | ||
137 | const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); | 143 | const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); |
138 | if (id && id->flags & TF_PARAM) { | 144 | if (id && id->flags & TF_PARAM) { |
139 | zconflval.id = id; | 145 | zconflval.id = id; |
@@ -146,11 +152,7 @@ n [A-Za-z0-9_] | |||
146 | #.* /* comment */ | 152 | #.* /* comment */ |
147 | \\\n current_file->lineno++; | 153 | \\\n current_file->lineno++; |
148 | [[:blank:]]+ | 154 | [[:blank:]]+ |
149 | . { | 155 | . warn_ignored_character(*yytext); |
150 | fprintf(stderr, | ||
151 | "%s:%d:warning: ignoring unsupported character '%c'\n", | ||
152 | zconf_curname(), zconf_lineno(), *yytext); | ||
153 | } | ||
154 | <<EOF>> { | 156 | <<EOF>> { |
155 | BEGIN(INITIAL); | 157 | BEGIN(INITIAL); |
156 | } | 158 | } |