From 6899f91867ecd1df50620499db7a64f9d5c1397b Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Tue, 24 Jul 2018 22:13:43 +0200 Subject: Restore compatibility with old kernels Add a small hack to restore compatibility with older (2015-) versions of the Linux kernel. Weird help tokens like -help- and --help--- are now accepted again. Compatibility was originally dropped by commit c19fc11 ("Drop some compatibility and tighten up lexing"), but it turns that people are still using Kconfiglib with older kernels. The new compatibility hack has pretty minimal impact at least. --- kconfiglib.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'kconfiglib.py') diff --git a/kconfiglib.py b/kconfiglib.py index 18baa83..cc5141d 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -1646,8 +1646,17 @@ class Kconfig(object): # to the previous token. See _STRING_LEX for why this is needed. token = _get_keyword(match.group(1)) if not token: - # If the first token is not a keyword, we have a preprocessor - # variable assignment (or a bare macro on a line) + # Backwards compatibility with old versions of the C tools, which + # (accidentally) accepted stuff like "--help--" and "-help---". + # This was fixed in the C tools by commit c2264564 ("kconfig: warn + # of unhandled characters in Kconfig commands"), committed in July + # 2015, but it seems people still run Kconfiglib on older kernels. + if s.strip(" \t\n-") == "help": + return (_T_HELP, None) + + # If the first token is not a keyword (and not a weird help token), + # we have a preprocessor variable assignment (or a bare macro on a + # line) self._parse_assignment(s) return (None,) -- cgit v1.2.3