108 body = re.sub(
r"^\s*#\s*include.*$",
" ", body, flags=re.M)
109 words = set(re.findall(
r"\b[A-Za-z_]\w*\b", body))
111 rel = os.path.relpath(header, REPO)
112 unused, used = [], []
113 for inc
in INCLUDE_LINE.findall(text):
114 target =
resolve(inc, os.path.dirname(header))
118 (used
if hit
else unused).append((inc, hit))
122 for inc
in INCLUDE_LINE.findall(text):
123 target =
resolve(inc, os.path.dirname(header))
129 missing.append((sym, os.path.relpath(dep, SRC)))
131 if not unused
and not missing:
133 print(f
"--- {rel} ---")
134 for inc, _
in unused:
135 print(f
" UNUSED {inc} (no declaration here references it)")
136 for sym, owner
in sorted(set(missing)):
137 print(f
" MISSING {sym} -- reached transitively; {owner} defines it")
138 for inc, hit
in used:
139 print(f
" ok {inc} <- {', '.join(hit[:6])}")
141 return len(unused) + len(set(missing))