practracker/includes.py: Don't read editor temp files

(Or any files that start with "." or "#".)

Obviously correct changes to already-reviewed code.
This commit is contained in:
teor 2019-11-26 17:50:56 +10:00
parent 3669a2f827
commit fadd292bf0
No known key found for this signature in database
GPG Key ID: 10FEAA0E7075672A

View File

@ -36,7 +36,11 @@ def warn(msg):
def fname_is_c(fname):
""" Return true iff 'fname' is the name of a file that we should
search for possibly disallowed #include directives. """
return fname.endswith(".h") or fname.endswith(".c")
if fname.endswith(".h") or fname.endswith(".c"):
bname = os.path.basename(fname)
return not (bname.startswith(".") or bname.startswith("#"))
else:
return False
INCLUDE_PATTERN = re.compile(r'\s*#\s*include\s+"([^"]*)"')
RULES_FNAME = ".may_include"