2015-07-03 12:47:27

by Andreas Ruprecht

[permalink] [raw]
Subject: [PATCH 0/2] kconfig: warn of unhandled characters in statements

This patchset changes the lexer file to emit a warning if any unhandled
characters are found in the input. So far, Kconfig options like

+config FOO
bool
[...]

(note the wrong '+'!) were parsed without a warning. As simply adding a
warning for '.' produces lots of warnings as occasionally '---help---'
is used instead of 'help' (and thus '-' is recognized as an unhandled
character), we need to handle the former separately.

Andreas Ruprecht (2):
kconfig: also warn of unhandled characters in statements
kconfig: Regenerate shipped zconf.lex.c file

scripts/kconfig/zconf.l | 11 +-
scripts/kconfig/zconf.lex.c_shipped | 453 +++++++++++++++++++++++++-----------
2 files changed, 322 insertions(+), 142 deletions(-)

--
1.9.1


2015-07-03 12:47:20

by Andreas Ruprecht

[permalink] [raw]
Subject: [PATCH 1/2] kconfig: also warn of unhandled characters in statements

While commit 2e0d737fc76f ("kconfig: don't silently ignore unhandled
characters") introduced a warning for unsupported characters inside
parameters, it does not cover situations where a statement
has additional characters around it.

This change introduces a warning if superfluous characters are found
around statements. As the 'help' statement sometimes is written as
'---help---', the '-' character would now also be regarded as
unhandled, this change also adds a special rule for this case.

Reported-by: Valentin Rothberg <[email protected]>
Signed-off-by: Andreas Ruprecht <[email protected]>
---
scripts/kconfig/zconf.l | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index 200a3fe..84a5d05 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -106,7 +106,15 @@ n [A-Za-z0-9_]
zconflval.string = text;
return T_WORD;
}
- .
+ "---help---" {
+ /* Support old syntax for help statement */
+ return T_HELP;
+ }
+ . {
+ fprintf(stderr,
+ "%s:%d:warning: ignoring unsupported character '%c'\n",
+ zconf_curname(), zconf_lineno(), *yytext);
+ }
\n {
BEGIN(INITIAL);
current_file->lineno++;
@@ -132,7 +140,6 @@ n [A-Za-z0-9_]
BEGIN(STRING);
}
\n BEGIN(INITIAL); current_file->lineno++; return T_EOL;
- --- /* ignore */
({n}|[-/.])+ {
const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
if (id && id->flags & TF_PARAM) {
--
1.9.1

2015-07-03 12:48:08

by Andreas Ruprecht

[permalink] [raw]
Subject: [PATCH 2/2] kconfig: Regenerate shipped zconf.lex.c file

This updates the shipped file generated by flex to support the
explicit use of "---help---" and to emit warnings for unsupported
characters on top level statements.

As I could not find out which flex version was used to generate
the previous version, I used flex 2.5.35 from Ubuntu 14.04 - this
also leads to the big number of changed lines in this patch.

Signed-off-by: Andreas Ruprecht <[email protected]>
---
scripts/kconfig/zconf.lex.c_shipped | 453 +++++++++++++++++++++++++-----------
1 file changed, 313 insertions(+), 140 deletions(-)

diff --git a/scripts/kconfig/zconf.lex.c_shipped b/scripts/kconfig/zconf.lex.c_shipped
index dd4e86c..34232d3 100644
--- a/scripts/kconfig/zconf.lex.c_shipped
+++ b/scripts/kconfig/zconf.lex.c_shipped
@@ -72,7 +72,6 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */

/* Limits of integral types. */
#ifndef INT8_MIN
@@ -103,6 +102,8 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif

+#endif /* ! C99 */
+
#endif /* ! FLEXINT_H */

#ifdef __cplusplus
@@ -159,7 +160,15 @@ typedef unsigned int flex_uint32_t;

/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
#endif

/* The state buf must be large enough to hold one state per character in the main buffer.
@@ -365,354 +374,472 @@ int zconflineno = 1;

extern char *zconftext;
#define yytext_ptr zconftext
-static yyconst flex_int16_t yy_nxt[][19] =
+static yyconst flex_int16_t yy_nxt[][23] =
{
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0
},

{
11, 12, 13, 14, 12, 12, 15, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12
},

{
11, 12, 13, 14, 12, 12, 15, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12
},

{
11, 16, 16, 17, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 18, 16, 16, 16, 16, 16
+
+ 16, 18, 16, 19, 16, 16, 16, 16, 19, 19,
+ 19, 19, 16
},

{
11, 16, 16, 17, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 18, 16, 16, 16, 16, 16
-
+ 16, 18, 16, 19, 16, 16, 16, 16, 19, 19,
+ 19, 19, 16
},

{
- 11, 19, 20, 21, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19
+ 11, 20, 21, 22, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20
},

{
- 11, 19, 20, 21, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19
+ 11, 20, 21, 22, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+
+ 20, 20, 20
},

{
- 11, 22, 22, 23, 22, 24, 22, 22, 24, 22,
- 22, 22, 22, 22, 22, 22, 22, 25, 22
+ 11, 23, 23, 24, 23, 25, 23, 23, 25, 23,
+ 23, 23, 23, 23, 23, 23, 23, 26, 23, 23,
+ 23, 23, 23
},

{
- 11, 22, 22, 23, 22, 24, 22, 22, 24, 22,
- 22, 22, 22, 22, 22, 22, 22, 25, 22
+ 11, 23, 23, 24, 23, 25, 23, 23, 25, 23,
+ 23, 23, 23, 23, 23, 23, 23, 26, 23, 23,
+ 23, 23, 23
},

{
- 11, 26, 27, 28, 29, 30, 31, 32, 30, 33,
- 34, 35, 36, 36, 37, 38, 39, 40, 41
+ 11, 27, 28, 29, 30, 31, 32, 33, 31, 34,
+ 35, 36, 36, 36, 37, 38, 39, 40, 36, 36,
+ 36, 36, 41

},

{
- 11, 26, 27, 28, 29, 30, 31, 32, 30, 33,
- 34, 35, 36, 36, 37, 38, 39, 40, 41
+ 11, 27, 28, 29, 30, 31, 32, 33, 31, 34,
+ 35, 36, 36, 36, 37, 38, 39, 40, 36, 36,
+ 36, 36, 41
},

{
-11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
- -11, -11, -11, -11, -11, -11, -11, -11, -11
+ -11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
+ -11, -11, -11
},

{
11, -12, -12, -12, -12, -12, -12, -12, -12, -12,
- -12, -12, -12, -12, -12, -12, -12, -12, -12
+ -12, -12, -12, -12, -12, -12, -12, -12, -12, -12,
+ -12, -12, -12
},

{
11, -13, 42, 43, -13, -13, 44, -13, -13, -13,
- -13, -13, -13, -13, -13, -13, -13, -13, -13
+
+ -13, -13, -13, -13, -13, -13, -13, -13, -13, -13,
+ -13, -13, -13
},

{
11, -14, -14, -14, -14, -14, -14, -14, -14, -14,
- -14, -14, -14, -14, -14, -14, -14, -14, -14
-
+ -14, -14, -14, -14, -14, -14, -14, -14, -14, -14,
+ -14, -14, -14
},

{
11, 45, 45, 46, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45
+ 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+ 45, 45, 45
},

{
11, -16, -16, -16, -16, -16, -16, -16, -16, -16,
- -16, -16, -16, -16, -16, -16, -16, -16, -16
+ -16, -16, -16, -16, -16, -16, -16, -16, -16, -16,
+
+ -16, -16, -16
},

{
11, -17, -17, -17, -17, -17, -17, -17, -17, -17,
- -17, -17, -17, -17, -17, -17, -17, -17, -17
+ -17, -17, -17, -17, -17, -17, -17, -17, -17, -17,
+ -17, -17, -17
},

{
11, -18, -18, -18, -18, -18, -18, -18, -18, -18,
- -18, -18, -18, 47, -18, -18, -18, -18, -18
+ -18, 47, -18, -18, -18, -18, -18, -18, -18, -18,
+ -18, -18, -18
},

{
- 11, 48, 48, -19, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48
+ 11, -19, -19, -19, -19, -19, -19, -19, -19, -19,
+ -19, -19, -19, 48, -19, -19, -19, -19, 48, 48,
+ 48, 48, -19

},

{
- 11, -20, 49, 50, -20, -20, -20, -20, -20, -20,
- -20, -20, -20, -20, -20, -20, -20, -20, -20
+ 11, 49, 49, -20, 49, 49, 49, 49, 49, 49,
+ 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+ 49, 49, 49
},

{
- 11, 51, -21, -21, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51
+ 11, -21, 50, 51, -21, -21, -21, -21, -21, -21,
+ -21, -21, -21, -21, -21, -21, -21, -21, -21, -21,
+ -21, -21, -21
},

{
- 11, 52, 52, 53, 52, -22, 52, 52, -22, 52,
- 52, 52, 52, 52, 52, 52, 52, -22, 52
+ 11, 52, -22, -22, 52, 52, 52, 52, 52, 52,
+ 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
+ 52, 52, 52
},

{
- 11, -23, -23, -23, -23, -23, -23, -23, -23, -23,
- -23, -23, -23, -23, -23, -23, -23, -23, -23
+ 11, 53, 53, 54, 53, -23, 53, 53, -23, 53,
+
+ 53, 53, 53, 53, 53, 53, 53, -23, 53, 53,
+ 53, 53, 53
},

{
11, -24, -24, -24, -24, -24, -24, -24, -24, -24,
- -24, -24, -24, -24, -24, -24, -24, -24, -24
-
+ -24, -24, -24, -24, -24, -24, -24, -24, -24, -24,
+ -24, -24, -24
},

{
- 11, 54, 54, 55, 54, 54, 54, 54, 54, 54,
- 54, 54, 54, 54, 54, 54, 54, 54, 54
+ 11, -25, -25, -25, -25, -25, -25, -25, -25, -25,
+ -25, -25, -25, -25, -25, -25, -25, -25, -25, -25,
+ -25, -25, -25
},

{
- 11, -26, -26, -26, -26, -26, -26, -26, -26, -26,
- -26, -26, -26, -26, -26, -26, -26, -26, -26
+ 11, 55, 55, 56, 55, 55, 55, 55, 55, 55,
+ 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
+
+ 55, 55, 55
},

{
- 11, -27, 56, -27, -27, -27, -27, -27, -27, -27,
- -27, -27, -27, -27, -27, -27, -27, -27, -27
+ 11, -27, -27, -27, -27, -27, -27, -27, -27, -27,
+ -27, -27, -27, -27, -27, -27, -27, -27, -27, -27,
+ -27, -27, -27
},

{
- 11, -28, -28, -28, -28, -28, -28, -28, -28, -28,
- -28, -28, -28, -28, -28, -28, -28, -28, -28
+ 11, -28, 57, -28, -28, -28, -28, -28, -28, -28,
+ -28, -28, -28, -28, -28, -28, -28, -28, -28, -28,
+ -28, -28, -28
},

{
11, -29, -29, -29, -29, -29, -29, -29, -29, -29,
- -29, -29, -29, -29, -29, 57, -29, -29, -29
+ -29, -29, -29, -29, -29, -29, -29, -29, -29, -29,
+ -29, -29, -29

},

{
11, -30, -30, -30, -30, -30, -30, -30, -30, -30,
- -30, -30, -30, -30, -30, -30, -30, -30, -30
+ -30, -30, -30, -30, -30, 58, -30, -30, -30, -30,
+ -30, -30, -30
},

{
- 11, 58, 58, -31, 58, 58, 58, 58, 58, 58,
- 58, 58, 58, 58, 58, 58, 58, 58, 58
+ 11, -31, -31, -31, -31, -31, -31, -31, -31, -31,
+ -31, -31, -31, -31, -31, -31, -31, -31, -31, -31,
+ -31, -31, -31
},

{
- 11, -32, -32, -32, -32, -32, -32, 59, -32, -32,
- -32, -32, -32, -32, -32, -32, -32, -32, -32
+ 11, 59, 59, -32, 59, 59, 59, 59, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
+ 59, 59, 59
},

{
- 11, -33, -33, -33, -33, -33, -33, -33, -33, -33,
- -33, -33, -33, -33, -33, -33, -33, -33, -33
+ 11, -33, -33, -33, -33, -33, -33, 60, -33, -33,
+
+ -33, -33, -33, -33, -33, -33, -33, -33, -33, -33,
+ -33, -33, -33
},

{
11, -34, -34, -34, -34, -34, -34, -34, -34, -34,
- -34, -34, -34, -34, -34, -34, -34, -34, -34
-
+ -34, -34, -34, -34, -34, -34, -34, -34, -34, -34,
+ -34, -34, -34
},

{
11, -35, -35, -35, -35, -35, -35, -35, -35, -35,
- -35, 60, 61, 61, -35, -35, -35, -35, -35
+ -35, -35, -35, -35, -35, -35, -35, -35, -35, -35,
+ -35, -35, -35
},

{
11, -36, -36, -36, -36, -36, -36, -36, -36, -36,
- -36, 61, 61, 61, -36, -36, -36, -36, -36
+ -36, 61, 61, 61, -36, -36, -36, -36, 61, 61,
+
+ 61, 61, -36
},

{
11, -37, -37, -37, -37, -37, -37, -37, -37, -37,
- -37, -37, -37, -37, -37, 62, -37, -37, -37
+ -37, -37, -37, -37, -37, 62, -37, -37, -37, -37,
+ -37, -37, -37
},

{
11, -38, -38, -38, -38, -38, -38, -38, -38, -38,
- -38, -38, -38, -38, -38, -38, -38, -38, -38
+ -38, -38, -38, -38, -38, -38, -38, -38, -38, -38,
+ -38, -38, -38
},

{
11, -39, -39, -39, -39, -39, -39, -39, -39, -39,
- -39, -39, -39, -39, -39, 63, -39, -39, -39
+ -39, -39, -39, -39, -39, 63, -39, -39, -39, -39,
+ -39, -39, -39

},

{
11, -40, -40, 64, -40, -40, -40, -40, -40, -40,
- -40, -40, -40, -40, -40, -40, -40, -40, -40
+ -40, -40, -40, -40, -40, -40, -40, -40, -40, -40,
+ -40, -40, -40
},

{
11, -41, -41, -41, -41, -41, -41, -41, -41, -41,
- -41, -41, -41, -41, -41, -41, -41, -41, 65
+ -41, -41, -41, -41, -41, -41, -41, -41, -41, -41,
+ -41, -41, 65
},

{
11, -42, 42, 43, -42, -42, 44, -42, -42, -42,
- -42, -42, -42, -42, -42, -42, -42, -42, -42
+ -42, -42, -42, -42, -42, -42, -42, -42, -42, -42,
+ -42, -42, -42
},

{
11, -43, -43, -43, -43, -43, -43, -43, -43, -43,
- -43, -43, -43, -43, -43, -43, -43, -43, -43
+
+ -43, -43, -43, -43, -43, -43, -43, -43, -43, -43,
+ -43, -43, -43
},

{
11, 45, 45, 46, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45
-
+ 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+ 45, 45, 45
},

{
11, 45, 45, 46, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45
+ 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+ 45, 45, 45
},

{
11, -46, -46, -46, -46, -46, -46, -46, -46, -46,
- -46, -46, -46, -46, -46, -46, -46, -46, -46
+ -46, -46, -46, -46, -46, -46, -46, -46, -46, -46,
+
+ -46, -46, -46
},

{
11, -47, -47, -47, -47, -47, -47, -47, -47, -47,
- -47, -47, -47, 47, -47, -47, -47, -47, -47
+ -47, 66, -47, -47, -47, -47, -47, -47, -47, -47,
+ -47, -47, -47
},

{
- 11, 48, 48, -48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48
+ 11, -48, -48, -48, -48, -48, -48, -48, -48, -48,
+ -48, -48, -48, 48, -48, -48, -48, -48, 48, 48,
+ 48, 48, -48
},

{
- 11, -49, 49, 50, -49, -49, -49, -49, -49, -49,
- -49, -49, -49, -49, -49, -49, -49, -49, -49
+ 11, 49, 49, -49, 49, 49, 49, 49, 49, 49,
+ 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
+ 49, 49, 49

},

{
- 11, 51, -50, -50, 51, 51, 51, 51, 51, 51,
- 51, 51, 51, 51, 51, 51, 51, 51, 51
+ 11, -50, 50, 51, -50, -50, -50, -50, -50, -50,
+ -50, -50, -50, -50, -50, -50, -50, -50, -50, -50,
+ -50, -50, -50
},

{
- 11, -51, -51, -51, -51, -51, -51, -51, -51, -51,
- -51, -51, -51, -51, -51, -51, -51, -51, -51
+ 11, 52, -51, -51, 52, 52, 52, 52, 52, 52,
+ 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
+ 52, 52, 52
},

{
- 11, 52, 52, 53, 52, -52, 52, 52, -52, 52,
- 52, 52, 52, 52, 52, 52, 52, -52, 52
+ 11, -52, -52, -52, -52, -52, -52, -52, -52, -52,
+ -52, -52, -52, -52, -52, -52, -52, -52, -52, -52,
+ -52, -52, -52
},

{
- 11, -53, -53, -53, -53, -53, -53, -53, -53, -53,
- -53, -53, -53, -53, -53, -53, -53, -53, -53
+ 11, 53, 53, 54, 53, -53, 53, 53, -53, 53,
+
+ 53, 53, 53, 53, 53, 53, 53, -53, 53, 53,
+ 53, 53, 53
},

{
- 11, -54, -54, 55, -54, -54, -54, -54, -54, -54,
- -54, -54, -54, -54, -54, -54, -54, -54, -54
-
+ 11, -54, -54, -54, -54, -54, -54, -54, -54, -54,
+ -54, -54, -54, -54, -54, -54, -54, -54, -54, -54,
+ -54, -54, -54
},

{
- 11, -55, -55, -55, -55, -55, -55, -55, -55, -55,
- -55, -55, -55, -55, -55, -55, -55, -55, -55
+ 11, -55, -55, 56, -55, -55, -55, -55, -55, -55,
+ -55, -55, -55, -55, -55, -55, -55, -55, -55, -55,
+ -55, -55, -55
},

{
- 11, -56, 56, -56, -56, -56, -56, -56, -56, -56,
- -56, -56, -56, -56, -56, -56, -56, -56, -56
+ 11, -56, -56, -56, -56, -56, -56, -56, -56, -56,
+ -56, -56, -56, -56, -56, -56, -56, -56, -56, -56,
+
+ -56, -56, -56
},

{
- 11, -57, -57, -57, -57, -57, -57, -57, -57, -57,
- -57, -57, -57, -57, -57, -57, -57, -57, -57
+ 11, -57, 57, -57, -57, -57, -57, -57, -57, -57,
+ -57, -57, -57, -57, -57, -57, -57, -57, -57, -57,
+ -57, -57, -57
},

{
- 11, 58, 58, -58, 58, 58, 58, 58, 58, 58,
- 58, 58, 58, 58, 58, 58, 58, 58, 58
+ 11, -58, -58, -58, -58, -58, -58, -58, -58, -58,
+ -58, -58, -58, -58, -58, -58, -58, -58, -58, -58,
+ -58, -58, -58
},

{
- 11, -59, -59, -59, -59, -59, -59, -59, -59, -59,
- -59, -59, -59, -59, -59, -59, -59, -59, -59
+ 11, 59, 59, -59, 59, 59, 59, 59, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
+ 59, 59, 59

},

{
11, -60, -60, -60, -60, -60, -60, -60, -60, -60,
- -60, 66, 61, 61, -60, -60, -60, -60, -60
+ -60, -60, -60, -60, -60, -60, -60, -60, -60, -60,
+ -60, -60, -60
},

{
11, -61, -61, -61, -61, -61, -61, -61, -61, -61,
- -61, 61, 61, 61, -61, -61, -61, -61, -61
+ -61, 61, 61, 61, -61, -61, -61, -61, 61, 61,
+ 61, 61, -61
},

{
11, -62, -62, -62, -62, -62, -62, -62, -62, -62,
- -62, -62, -62, -62, -62, -62, -62, -62, -62
+ -62, -62, -62, -62, -62, -62, -62, -62, -62, -62,
+ -62, -62, -62
},

{
11, -63, -63, -63, -63, -63, -63, -63, -63, -63,
- -63, -63, -63, -63, -63, -63, -63, -63, -63
+
+ -63, -63, -63, -63, -63, -63, -63, -63, -63, -63,
+ -63, -63, -63
},

{
11, -64, -64, -64, -64, -64, -64, -64, -64, -64,
- -64, -64, -64, -64, -64, -64, -64, -64, -64
-
+ -64, -64, -64, -64, -64, -64, -64, -64, -64, -64,
+ -64, -64, -64
},

{
11, -65, -65, -65, -65, -65, -65, -65, -65, -65,
- -65, -65, -65, -65, -65, -65, -65, -65, -65
+ -65, -65, -65, -65, -65, -65, -65, -65, -65, -65,
+ -65, -65, -65
},

{
11, -66, -66, -66, -66, -66, -66, -66, -66, -66,
- -66, 61, 61, 61, -66, -66, -66, -66, -66
+ -66, -66, -66, -66, -66, -66, -66, -66, -66, 67,
+
+ -66, -66, -66
+ },
+
+ {
+ 11, -67, -67, -67, -67, -67, -67, -67, -67, -67,
+ -67, -67, -67, -67, -67, -67, -67, -67, 68, -67,
+ -67, -67, -67
+ },
+
+ {
+ 11, -68, -68, -68, -68, -68, -68, -68, -68, -68,
+ -68, -68, -68, -68, -68, -68, -68, -68, -68, -68,
+ 69, -68, -68
+ },
+
+ {
+ 11, -69, -69, -69, -69, -69, -69, -69, -69, -69,
+ -69, -69, -69, -69, -69, -69, -69, -69, -69, -69,
+ -69, 70, -69
+
+ },
+
+ {
+ 11, -70, -70, -70, -70, -70, -70, -70, -70, -70,
+ -70, 71, -70, -70, -70, -70, -70, -70, -70, -70,
+ -70, -70, -70
+ },
+
+ {
+ 11, -71, -71, -71, -71, -71, -71, -71, -71, -71,
+ -71, 72, -71, -71, -71, -71, -71, -71, -71, -71,
+ -71, -71, -71
+ },
+
+ {
+ 11, -72, -72, -72, -72, -72, -72, -72, -72, -72,
+ -72, 73, -72, -72, -72, -72, -72, -72, -72, -72,
+ -72, -72, -72
+ },
+
+ {
+ 11, -73, -73, -73, -73, -73, -73, -73, -73, -73,
+
+ -73, -73, -73, -73, -73, -73, -73, -73, -73, -73,
+ -73, -73, -73
},

} ;
@@ -741,15 +868,16 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[67] =
+static yyconst flex_int16_t yy_accept[74] =
{ 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 39, 5, 4, 2, 3, 7, 8, 6, 37, 34,
- 36, 29, 33, 32, 31, 27, 26, 21, 13, 20,
- 24, 27, 11, 12, 23, 23, 18, 14, 19, 27,
- 27, 4, 2, 3, 3, 1, 6, 37, 34, 36,
- 35, 29, 28, 31, 30, 26, 15, 24, 9, 23,
- 23, 16, 17, 25, 10, 22
+ 39, 5, 4, 2, 3, 8, 9, 8, 6, 37,
+ 34, 36, 29, 33, 32, 31, 27, 26, 22, 14,
+ 21, 24, 27, 12, 13, 23, 19, 15, 20, 27,
+ 27, 4, 2, 3, 3, 1, 0, 6, 37, 34,
+ 36, 35, 29, 28, 31, 30, 26, 16, 24, 10,
+ 23, 17, 18, 25, 11, 0, 0, 0, 0, 0,
+ 0, 0, 7
} ;

static yyconst flex_int32_t yy_ec[256] =
@@ -765,9 +893,9 @@ static yyconst flex_int32_t yy_ec[256] =
13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
1, 17, 1, 1, 13, 1, 13, 13, 13, 13,

- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 1, 18, 1, 1, 1, 1, 1, 1,
+ 18, 13, 13, 19, 13, 13, 13, 20, 13, 13,
+ 13, 21, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 1, 22, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -784,6 +912,9 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1
} ;

+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
extern int zconf_flex_debug;
int zconf_flex_debug = 0;

@@ -944,7 +1075,12 @@ static int input (void );

/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
#endif

/* Copy whatever the last rule matched to the standard output. */
@@ -952,7 +1088,7 @@ static int input (void );
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO fwrite( zconftext, zconfleng, 1, zconfout )
+#define ECHO do { if (fwrite( zconftext, zconfleng, 1, zconfout )) {} } while (0)
#endif

/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -1073,7 +1209,15 @@ YY_DECL
yy_current_state = (yy_start);
yy_match:
while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 )
+ {
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+
++yy_cp;
+ }

yy_current_state = -yy_current_state;

@@ -1086,6 +1230,13 @@ do_action: /* This label is used only to access EOF actions. */

switch ( yy_act )
{ /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = (yy_hold_char);
+ yy_cp = (yy_last_accepting_cpos) + 1;
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+
case 1:
/* rule 1 can match eol */
case 2:
@@ -1132,10 +1283,21 @@ YY_RULE_SETUP
YY_BREAK
case 7:
YY_RULE_SETUP
-
+{
+ /* Support old syntax for help statement */
+ return T_HELP;
+ }
YY_BREAK
case 8:
-/* rule 8 can match eol */
+YY_RULE_SETUP
+{
+ fprintf(stderr,
+ "%s:%d:warning: ignoring unsupported character '%c'\n",
+ zconf_curname(), zconf_lineno(), *zconftext);
+ }
+ YY_BREAK
+case 9:
+/* rule 9 can match eol */
YY_RULE_SETUP
{
BEGIN(INITIAL);
@@ -1144,51 +1306,51 @@ YY_RULE_SETUP
}
YY_BREAK

-case 9:
+case 10:
YY_RULE_SETUP
return T_AND;
YY_BREAK
-case 10:
+case 11:
YY_RULE_SETUP
return T_OR;
YY_BREAK
-case 11:
+case 12:
YY_RULE_SETUP
return T_OPEN_PAREN;
YY_BREAK
-case 12:
+case 13:
YY_RULE_SETUP
return T_CLOSE_PAREN;
YY_BREAK
-case 13:
+case 14:
YY_RULE_SETUP
return T_NOT;
YY_BREAK
-case 14:
+case 15:
YY_RULE_SETUP
return T_EQUAL;
YY_BREAK
-case 15:
+case 16:
YY_RULE_SETUP
return T_UNEQUAL;
YY_BREAK
-case 16:
+case 17:
YY_RULE_SETUP
return T_LESS_EQUAL;
YY_BREAK
-case 17:
+case 18:
YY_RULE_SETUP
return T_GREATER_EQUAL;
YY_BREAK
-case 18:
+case 19:
YY_RULE_SETUP
return T_LESS;
YY_BREAK
-case 19:
+case 20:
YY_RULE_SETUP
return T_GREATER;
YY_BREAK
-case 20:
+case 21:
YY_RULE_SETUP
{
str = zconftext[0];
@@ -1196,14 +1358,10 @@ YY_RULE_SETUP
BEGIN(STRING);
}
YY_BREAK
-case 21:
-/* rule 21 can match eol */
-YY_RULE_SETUP
-BEGIN(INITIAL); current_file->lineno++; return T_EOL;
- YY_BREAK
case 22:
+/* rule 22 can match eol */
YY_RULE_SETUP
-/* ignore */
+BEGIN(INITIAL); current_file->lineno++; return T_EOL;
YY_BREAK
case 23:
YY_RULE_SETUP
@@ -1669,6 +1827,11 @@ static int yy_get_next_buffer (void)
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
{
yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)];
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
}

return yy_current_state;
@@ -1682,10 +1845,20 @@ static int yy_get_next_buffer (void)
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
{
register int yy_is_jam;
-
+ register char *yy_cp = (yy_c_buf_p);
+
yy_current_state = yy_nxt[yy_current_state][1];
yy_is_jam = (yy_current_state <= 0);

+ if ( ! yy_is_jam )
+ {
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ }
+
return yy_is_jam ? 0 : yy_current_state;
}

@@ -2114,8 +2287,8 @@ YY_BUFFER_STATE zconf_scan_string (yyconst char * yystr )

/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will
* scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
*
* @return the newly allocated buffer state object.
*/
--
1.9.1

2015-07-05 10:00:52

by Paul Bolle

[permalink] [raw]
Subject: Re: [PATCH 1/2] kconfig: also warn of unhandled characters in statements

On vr, 2015-07-03 at 14:46 +0200, Andreas Ruprecht wrote:
> While commit 2e0d737fc76f ("kconfig: don't silently ignore unhandled
> characters") introduced a warning for unsupported characters inside
> parameters,

What are "parameters"? The term doesn't show up in Documentation/kbuild.

There's TF_PARAM in zconf.gperf, but that's some odd category that
apparently only includes "on" and "if". zconf.l only has the
undocumented PARAM state.

> it does not cover situations where a statement
> has additional characters around it.
>
> This change introduces a warning if superfluous characters are found
> around statements. As the 'help' statement sometimes is written as
> '---help---', the '-' character would now also be regarded as
> unhandled, this change also adds a special rule for this case.

[...], but '-' characters will now also generate a warning,
add a special rule for that case.

or something along those lines.

Should we elaborate here that currently "---help---" only is an alias
for "help" because we simply skip "---" when parsing Kconfig files? Or
is that trick so obscure that nobody else will care about it?

> Reported-by: Valentin Rothberg <[email protected]>
> Signed-off-by: Andreas Ruprecht <[email protected]>
> ---
> scripts/kconfig/zconf.l | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
> index 200a3fe..84a5d05 100644
> --- a/scripts/kconfig/zconf.l
> +++ b/scripts/kconfig/zconf.l
> @@ -106,7 +106,15 @@ n [A-Za-z0-9_]
> zconflval.string = text;
> return T_WORD;
> }
> - .
> + "---help---" {
> + /* Support old syntax for help statement */

s/old/alternative/?

> + return T_HELP;
> + }
> + . {
> + fprintf(stderr,
> + "%s:%d:warning: ignoring unsupported character '%c'\n",
> + zconf_curname(), zconf_lineno(), *yytext);
> + }

Could you add and use a small helper function for this warning and the
identical warning that was added in commit 2e0d737fc76f?

> \n {
> BEGIN(INITIAL);
> current_file->lineno++;
> @@ -132,7 +140,6 @@ n [A-Za-z0-9_]
> BEGIN(STRING);
> }
> \n BEGIN(INITIAL); current_file->lineno++; return T_EOL;
> - --- /* ignore */
> ({n}|[-/.])+ {
> const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
> if (id && id->flags & TF_PARAM) {

Thanks,


Paul Bolle

2015-07-05 08:45:09

by Ulf Magnusson

[permalink] [raw]
Subject: Re: [PATCH 1/2] kconfig: also warn of unhandled characters in statements

A more exact commit title would be something like "warn for unhandled
characters before the initial token on a line".

On Fri, Jul 3, 2015 at 2:46 PM, Andreas Ruprecht
<[email protected]> wrote:
> While commit 2e0d737fc76f ("kconfig: don't silently ignore unhandled
> characters") introduced a warning for unsupported characters inside
> parameters, it does not cover situations where a statement
> has additional characters around it.

This could say something like "...introduces a warning for unhandled characters
after the initial token on a line, but does not cover unhandled characters
before the initial token, which are ignored using a different mechanism."

>
> This change introduces a warning if superfluous characters are found
> around statements. As the 'help' statement sometimes is written as
> '---help---', the '-' character would now also be regarded as
> unhandled, this change also adds a special rule for this case.

Similarly above.

>
> Reported-by: Valentin Rothberg <[email protected]>
> Signed-off-by: Andreas Ruprecht <[email protected]>
> ---
> scripts/kconfig/zconf.l | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
> index 200a3fe..84a5d05 100644
> --- a/scripts/kconfig/zconf.l
> +++ b/scripts/kconfig/zconf.l
> @@ -106,7 +106,15 @@ n [A-Za-z0-9_]
> zconflval.string = text;
> return T_WORD;
> }
> - .
> + "---help---" {
> + /* Support old syntax for help statement */
> + return T_HELP;
> + }

I haven't tried it out to see if there would be problems, but adding '-' to the

n [A-Za-z0-9_]

definition in zconf.l and adding '---help---' to zconf.gperf seems cleaner than
special-casing it in zconf.l. If '---help---' is treated as a token, then it
makes sense to include '-' among the token characters.

(I also rambled a bit in
http://www.spinics.net/lists/linux-kbuild/msg11393.html.)

With that change, '-' could be removed from the parameter regex ({n}|[-/.])+ in
zconf.l too.

> + . {
> + fprintf(stderr,
> + "%s:%d:warning: ignoring unsupported character '%c'\n",
> + zconf_curname(), zconf_lineno(), *yytext);
> + }
> \n {
> BEGIN(INITIAL);
> current_file->lineno++;
> @@ -132,7 +140,6 @@ n [A-Za-z0-9_]
> BEGIN(STRING);
> }
> \n BEGIN(INITIAL); current_file->lineno++; return T_EOL;
> - --- /* ignore */
> ({n}|[-/.])+ {
> const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
> if (id && id->flags & TF_PARAM) {
> --
> 1.9.1
>

Cheers,
Ulf

2015-07-05 08:42:11

by Ulf Magnusson

[permalink] [raw]
Subject: Re: [PATCH 1/2] kconfig: also warn of unhandled characters in statements

On Sat, Jul 4, 2015 at 11:33 AM, Paul Bolle <[email protected]> wrote:
> On vr, 2015-07-03 at 14:46 +0200, Andreas Ruprecht wrote:
>> While commit 2e0d737fc76f ("kconfig: don't silently ignore unhandled
>> characters") introduced a warning for unsupported characters inside
>> parameters,
>
> What are "parameters"? The term doesn't show up in Documentation/kbuild.
>

zconf.l parses each line like "<COMMAND> <PARAM> <PARAM> ...", with a slightly
different set of characters allowed for <COMMAND> and <PARAM> (for whatever
reason). I agree that that's not clear from the commit message alone though.

(As a side note, that Flex/gperf split seems kinda odd to me. Does anyone know
of a good reason why more lexing wasn't done in zconf.l? Is it an optimization
attempt?)

Cheers,
Ulf

2015-07-08 10:17:37

by Andreas Ruprecht

[permalink] [raw]
Subject: Re: [PATCH 1/2] kconfig: also warn of unhandled characters in statements

Hi,

On 07/07/2015 16:45, Ulf Magnusson wrote:
>
> Did you use the (undocumented, obviously :) REGENERATE_PARSERS option,
> like 'make menuconfig REGENERATE_PARSERS=1'? It's from
> scripts/Makefile.lib.
>
> The following patch works fine for me from some quick experimentation.
> It's against the mainline kernel, as for some reason I can't clone
> git://gitorious.org/linux-kconfig/linux-kconfig at the moment.

yep, I used that. After some playing around with it, I also submitted a
v2 of the patch (although with the '-' still included in the regex for
PARAMs), didn't you receive that? (Message-Id:
<[email protected]>) and the two patches as
replies to the cover letter. They are against yesterday's linux-next.

Regards,

Andreas

2015-07-08 20:18:33

by Ulf Magnusson

[permalink] [raw]
Subject: Re: [PATCH 1/2] kconfig: also warn of unhandled characters in statements

On Wed, Jul 8, 2015 at 12:17 PM, Andreas Ruprecht
<[email protected]> wrote:
> Hi,
>
> On 07/07/2015 16:45, Ulf Magnusson wrote:
>>
>> Did you use the (undocumented, obviously :) REGENERATE_PARSERS option,
>> like 'make menuconfig REGENERATE_PARSERS=1'? It's from
>> scripts/Makefile.lib.
>>
>> The following patch works fine for me from some quick experimentation.
>> It's against the mainline kernel, as for some reason I can't clone
>> git://gitorious.org/linux-kconfig/linux-kconfig at the moment.
>
> yep, I used that. After some playing around with it, I also submitted a
> v2 of the patch (although with the '-' still included in the regex for
> PARAMs)

I was only referring to the redunant-'-'-in-PARAM-regex part. Could've made
that clearer. Might be a bit nitpicky I guess.

> , didn't you receive that? (Message-Id:
> <[email protected]>) and the two patches as
> replies to the cover letter. They are against yesterday's linux-next.
>
> Regards,
>
> Andreas

Cheers,
Ulf