Merge pull request #44 from myersg86/master

Track curly brace level in extract_c_parameters
This commit is contained in:
David A. Wheeler 2021-05-19 10:17:15 -04:00 committed by GitHub
commit 1a225623ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -529,6 +529,7 @@ def extract_c_parameters(text, pos=0):
parameters = [""] # Insert 0th entry, so 1st parameter is parameter[1].
currentstart = i
parenlevel = 1
curlylevel = 0
instring = 0 # 1=in double-quote, 2=in single-quote
incomment = 0
while i < len(text):
@ -579,7 +580,11 @@ def extract_c_parameters(text, pos=0):
# print " EXTRACT_C_PARAMETERS: ", text[pos:pos+80]
# print " RESULTS: ", parameters
return parameters
elif c == ';':
elif c == '{':
curlylevel += 1
elif c == '}':
curlylevel -= 1
elif c == ';' and curlylevel < 1:
internal_warn(
"Parsing failed to find end of parameter list; "
"semicolon terminated it in %s" % text[pos:pos + 200])