Modify style checker for PKCS style types
PKCS types may follow the format CK_TYPE_PTR or CK_TYPE_PTR_PTR.
This change updates the style checker to recognize _PTR and _PTR_PTR
line endings as pointer types.
This change also allows variables to start with a number.
@@ -182,9 +182,20 @@ def get_prefix(line):
prefix = "p" * indirection + "u" * unsigned + base_prefix
return prefix
+# PKCS #11 types may have the format
+# CK_TYPE_PTR or CK_TYPE_PTR_PTR
+def count_pkcs11_indirection(line):
+ base_prefix = get_base_type(line)
+ if (re.search("_PTR_PTR$", base_prefix)):
+ return 2
+ elif (re.search("_PTR$", base_prefix)):
+ return 1
+ else:
+ return 0
def count_indirection(line):
pointer_count = line.count('*')
+ pointer_count += count_pkcs11_indirection(line)
return pointer_count
@@ -224,7 +235,7 @@ def get_identifier_prefix(identifier):
indirection = "p" * (len(identifier) - len(direct_identifier))
for key in TYPE_PREFIXES:
prefix = TYPE_PREFIXES[key]
- if re.match(r"^" + prefix + r"[A-Z]", direct_identifier):
+ if re.match(r"^" + prefix + r"[0-9,A-Z]", direct_identifier):
return indirection + prefix
return ''
