mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 15:43:32 +01:00
practracker: Be more careful about excluding "confusing terms"
Previously we excluded any line containing one of these terms from consideration as the start or end of a function. Now we're more careful, and we only ignore these terms when they appear to be starting a function definition.
This commit is contained in:
parent
ec8c5b3fea
commit
f0302d51ab
@ -25,20 +25,20 @@ def get_function_lines(f):
|
|||||||
Return iterator which iterates over functions and returns (function name, function lines)
|
Return iterator which iterates over functions and returns (function name, function lines)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Skip lines with these terms since they confuse our regexp
|
# Skip lines that look like they are defining functions with these
|
||||||
|
# names: they aren't real function definitions.
|
||||||
REGEXP_CONFUSE_TERMS = {"MOCK_IMPL", "ENABLE_GCC_WARNINGS", "ENABLE_GCC_WARNING", "DUMMY_TYPECHECK_INSTANCE",
|
REGEXP_CONFUSE_TERMS = {"MOCK_IMPL", "ENABLE_GCC_WARNINGS", "ENABLE_GCC_WARNING", "DUMMY_TYPECHECK_INSTANCE",
|
||||||
"DISABLE_GCC_WARNING", "DISABLE_GCC_WARNINGS"}
|
"DISABLE_GCC_WARNING", "DISABLE_GCC_WARNINGS"}
|
||||||
|
|
||||||
in_function = False
|
in_function = False
|
||||||
for lineno, line in enumerate(f):
|
for lineno, line in enumerate(f):
|
||||||
if any(x in line for x in REGEXP_CONFUSE_TERMS):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not in_function:
|
if not in_function:
|
||||||
# find the start of a function
|
# find the start of a function
|
||||||
m = re.match(r'^([a-zA-Z_][a-zA-Z_0-9]*),?\(', line)
|
m = re.match(r'^([a-zA-Z_][a-zA-Z_0-9]*),?\(', line)
|
||||||
if m:
|
if m:
|
||||||
func_name = m.group(1)
|
func_name = m.group(1)
|
||||||
|
if func_name in REGEXP_CONFUSE_TERMS:
|
||||||
|
continue
|
||||||
func_start = lineno
|
func_start = lineno
|
||||||
in_function = True
|
in_function = True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user