diff -r 7e2ce7c38e0d -r ee0feec345c0 util/sort_includes.py --- a/util/sort_includes.py Wed Mar 16 11:37:13 2016 +0000 +++ b/util/sort_includes.py Wed Mar 16 11:37:23 2016 +0000 @@ -163,17 +163,15 @@ return sorted(set(includes)) def dump_includes(self): - blocks = [] - # Create a list of blocks in the prescribed include - # order. Each entry in the list is a multi-line string with - # multiple includes. + includes = [] for types in self.block_order: - block = "\n".join(self.dump_blocks(types)) - if block: - blocks.append(block) + block = self.dump_blocks(types) + if includes and block: + includes.append("") + includes += block self.reset() - return "\n\n".join(blocks) + return includes def __call__(self, lines, filename, language): self.reset() @@ -222,7 +220,8 @@ # Output pending includes, a new line between, and the # current l. - yield self.dump_includes() + for include in self.dump_includes(): + yield include yield '' yield line else: @@ -231,9 +230,8 @@ # We've reached EOF, so dump any pending includes if processing_includes: - yield self.dump_includes() - - + for include in self.dump_includes(): + yield include # default language types to try to apply our sorting rules to default_languages = frozenset(('C', 'C++', 'isa', 'python', 'scons', 'swig'))