Skip to content

Commit

Permalink
dist/tools/headerguards: ignore if #include_next is used
Browse files Browse the repository at this point in the history
We can't use the same header guard if we include two files with the same name.
  • Loading branch information
benpicco committed Dec 22, 2024
1 parent f044f3a commit 3cd06eb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions dist/tools/headerguards/headerguards.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def fix_headerguard(filename):
tmp.seek(0)

guard_found = 0
include_next_found = 0
guard_name = ""
ifstack = 0
for line in inlines:
Expand All @@ -66,14 +67,17 @@ def fix_headerguard(filename):
else:
guard_found += 1
line = "#endif /* %s */\n" % supposed
elif line.startswith("#include_next"):
include_next_found = 1

tmp.write(line)

tmp.seek(0)
if guard_found == 3:
for line in difflib.unified_diff(inlines, tmp.readlines(),
"%s" % filename, "%s" % filename):
sys.stdout.write(line)
if include_next_found == 0:
for line in difflib.unified_diff(inlines, tmp.readlines(),
"%s" % filename, "%s" % filename):
sys.stdout.write(line)
else:
print("%s: no / broken header guard" % filename, file=sys.stderr)
return False
Expand Down

0 comments on commit 3cd06eb

Please sign in to comment.