bpo-36876: Add a tool that identifies unsupported global C variables. (#15877)

This commit is contained in:
Eric Snow 2019-09-11 19:49:45 +01:00 committed by GitHub
parent 9936371af2
commit ee536b2020
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 9467 additions and 19 deletions

View file

@ -0,0 +1,34 @@
from . import preprocessor
def iter_clean_lines(lines):
incomment = False
for line in lines:
# Deal with comments.
if incomment:
_, sep, line = line.partition('*/')
if sep:
incomment = False
continue
line, _, _ = line.partition('//')
line, sep, remainder = line.partition('/*')
if sep:
_, sep, after = remainder.partition('*/')
if not sep:
incomment = True
continue
line += ' ' + after
# Ignore blank lines and leading/trailing whitespace.
line = line.strip()
if not line:
continue
yield line
def iter_lines(filename, *,
preprocess=preprocessor.run,
):
content = preprocess(filename)
return iter(content.splitlines())