@@ -177,15 +177,18 @@ def __init__(self):
177
177
self .key_usages = set ()
178
178
179
179
# "#define" followed by a macro name with either no parameters
180
- # or a single parameter. Grab the macro name in group 1, the
181
- # parameter name if any in group 2 and the definition in group 3.
182
- definition_re = re .compile (r'\s*#\s*define\s+(\w+)(?:\s+|\((\w+)\)\s*)(.+)(?:/[*/])?' )
180
+ # or a single parameter and a non-empty expansion.
181
+ # Grab the macro name in group 1, the parameter name if any in group 2
182
+ # and the expansion in group 3.
183
+ _define_directive_re = re .compile (r'\s*#\s*define\s+(\w+)' +
184
+ r'(?:\s+|\((\w+)\)\s*)' +
185
+ r'(.+)(?:/[*/])?' )
183
186
184
187
def read_line (self , line ):
185
- m = re .match (self .definition_re , line )
188
+ m = re .match (self ._define_directive_re , line )
186
189
if not m :
187
190
return
188
- name , parameter , definition = m .groups ()
191
+ name , parameter , expansion = m .groups ()
189
192
if name .endswith ('_FLAG' ) or name .endswith ('MASK' ):
190
193
# Macro only to build actual values
191
194
return
@@ -215,10 +218,10 @@ def read_line(self, line):
215
218
return
216
219
self .algorithms .add (name )
217
220
# Ad hoc detection of hash algorithms
218
- if re .search (r'0x010000[0-9A-Fa-f]{2}' , definition ):
221
+ if re .search (r'0x010000[0-9A-Fa-f]{2}' , expansion ):
219
222
self .hash_algorithms .add (name )
220
223
# Ad hoc detection of key agreement algorithms
221
- if re .search (r'0x30[0-9A-Fa-f]{2}0000' , definition ):
224
+ if re .search (r'0x30[0-9A-Fa-f]{2}0000' , expansion ):
222
225
self .ka_algorithms .add (name )
223
226
elif name .startswith ('PSA_ALG_' ) and parameter == 'hash_alg' :
224
227
if name in ['PSA_ALG_DSA' , 'PSA_ALG_ECDSA' ]:
0 commit comments