diff --git a/libc/kernel/tools/cpp.py b/libc/kernel/tools/cpp.py index c0b379b9e..6939bdafa 100755 --- a/libc/kernel/tools/cpp.py +++ b/libc/kernel/tools/cpp.py @@ -1202,7 +1202,7 @@ class BlockList(object): def removeStructs(self, structs): """Remove structs.""" - extra_includes = [] + extra_includes = set() block_num = 0 num_blocks = len(self.blocks) while block_num < num_blocks: @@ -1248,7 +1248,7 @@ class BlockList(object): # #include struct_token = b.tokens[i + 1] if not structs[struct_token.id]: - extra_includes.append("" % struct_token.id) + extra_includes.add("" % struct_token.id) # Search forward for the end of the structure. # Very simple search, look for } and ; tokens. @@ -1292,7 +1292,7 @@ class BlockList(object): continue i += 1 - for extra_include in extra_includes: + for extra_include in sorted(extra_includes): replacement = CppStringTokenizer(extra_include) self.blocks.insert(2, Block(replacement.tokens, directive='include'))