From 6f38ab3bcac69624ad78ab152d0fd0dbe52662fb Mon Sep 17 00:00:00 2001 From: Yuto Takano Date: Thu, 5 Aug 2021 21:07:14 +0100 Subject: [PATCH] Fix legacy troublesome regex Signed-off-by: Yuto Takano --- tests/scripts/check-names.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/scripts/check-names.py b/tests/scripts/check-names.py index 531ff3508f..0d14429f23 100755 --- a/tests/scripts/check-names.py +++ b/tests/scripts/check-names.py @@ -237,7 +237,7 @@ class NameCheck(object): A list of (identifier, containing filename) """ EXCLUDED_DECLARATIONS = ( - r"^(extern \"C\"|(typedef )?(struct|enum)( {)?$|};?$|$)" + r"^(extern \"C\"|(typedef )?(struct|union|enum)( {)?$|};?$|$)" ) identifiers = [] @@ -258,19 +258,15 @@ class NameCheck(object): # Skip parsing this line if it's a line comment, or if it # begins with a preprocessor directive - if in_block_comment or re.match(r"(//|#)", line): + if in_block_comment or re.match(r"^(//|#)", line): continue if re.match(EXCLUDED_DECLARATIONS, line): continue - + identifier = re.search( # Matches: "mbedtls_aes_init(" - r"([a-zA-Z_][a-zA-Z0-9_]*)\(|" - # Matches: "(*f_rng)(" - r"\(\*(.+)\)\(|" - # TODO: unknown purpose - r"(\w+)\W*$", + r"([a-zA-Z_][a-zA-Z0-9_]*)\(", line ) @@ -281,7 +277,7 @@ class NameCheck(object): header_file, line, (identifier.start(), identifier.end()), - identifier.group(0))) + identifier.group(1))) return identifiers