summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdeheader18
1 files changed, 17 insertions, 1 deletions
diff --git a/deheader b/deheader
index 857ed0e..35e0ffb 100755
--- a/deheader
+++ b/deheader
@@ -1277,10 +1277,12 @@ class InclusionMap:
seen = []
conditions = []
allow_parse_includes = True
+ cnt = -1
for line in open(sourcefile):
+ cnt = cnt + 1
c = match_preproc(["ifndef", "ifdef", "if"], line)
if c is not False:
- allow_parse_includes = False
+ allow_parse_includes = self.check_block(sourcefile, cnt)
conditions.append((c, allow_parse_includes))
elif match_preproc("else", line) is not False:
allow_parse_includes = not allow_parse_includes
@@ -1325,6 +1327,20 @@ class InclusionMap:
def remember(self, sourcefile, header):
"Undo forgetting of a dependency."
self.depends_on[sourcefile].append(header)
+ def check_block(self, sourcefile, cnt):
+ try:
+ with open(sourcefile, "r") as r:
+ with open(sourcefile + ".tmp", "wt") as w:
+ cnt2 = 0
+ for line in r:
+ w.write(line)
+ if cnt2 == cnt:
+ w.write("#error deheader\n")
+ cnt2 = cnt2 + 1
+ # here need try compile this file
+ finally:
+ os.remove(sourcefile + ".tmp")
+ return False
class SaveForModification:
"Prepare a file to be temporarily modified, with guaranteed reversion."