conform/conformtest.py: Extend tokenizer to cover character constants
authorFlorian Weimer <fweimer@redhat.com>
Mon, 17 Feb 2020 16:18:49 +0000 (17:18 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 17 Feb 2020 19:32:28 +0000 (20:32 +0100)
Such constants are used in __USE_EXTERN_INLINES blocks.

conform/conformtest.py

index 951e3b2..cb2bd97 100644 (file)
@@ -633,12 +633,11 @@ class HeaderTests(object):
                     bad_tokens.discard(match.group(1))
                     continue
                 # Tokenize the line and check identifiers found.  The
-                # handling of strings does not allow for escaped
-                # quotes, no allowance is made for character
-                # constants, and hex floats may be wrongly split into
-                # tokens including identifiers, but this is sufficient
-                # in practice and matches the old perl script.
-                line = re.sub(r'"[^"]*"', '', line)
+                # handling of strings and character constants does not
+                # allow for escaped quotes, and hex floats may be
+                # wrongly split into tokens including identifiers, but
+                # this is sufficient in practice.
+                line = re.sub(r'(?:\bL)?(?:"[^"]*"|\'[^\']*\')', '', line)
                 line = line.strip()
                 for token in re.split(r'[^A-Za-z0-9_]+', line):
                     if re.match(r'[A-Za-z_]', token):