From 7e9800b36e37f57787adc21c93eca19b23a82cbd Mon Sep 17 00:00:00 2001 From: Juerg Haefliger Date: Tue, 7 Feb 2023 08:36:05 +0100 Subject: [PATCH] UBUNTU: [Packaging] annotations: Handle tabs in annotations file Handle tabs in the annotations file by replacing them with spaces. While at make the parsing more robust by removing leading and trailing whitespaces and ignoring empty lines. Signed-off-by: Juerg Haefliger Signed-off-by: Andrea Righi --- debian/scripts/misc/kconfig/annotations.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/debian/scripts/misc/kconfig/annotations.py b/debian/scripts/misc/kconfig/annotations.py index ee679903d9da..766405c48ec1 100644 --- a/debian/scripts/misc/kconfig/annotations.py +++ b/debian/scripts/misc/kconfig/annotations.py @@ -50,13 +50,17 @@ class Annotation(Config): Parse body of annotations file """ def _parse_body(self, data: str): - # Skip comments - data = re.sub(r'(?m)^\s*#.*\n?', '', data) - - # Convert multiple spaces to single space to simplifly parsing - data = re.sub(r' *', ' ', data) - for line in data.splitlines(): + # Replace tabs with spaces, squeeze multiple into singles and + # remove leading and trailing spaces + line = line.replace('\t', ' ') + line = re.sub(r' +', ' ', line) + line = line.strip() + + # Ignore empty lines and comments + if not line or line.startswith('#'): + continue + # Handle includes (recursively) m = re.match(r'^include\s+"?([^"]*)"?', line) if m: