OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # | 2 # |
3 #===- clang-format-diff.py - ClangFormat Diff Reformatter ----*- python -*--===# | 3 #===- clang-format-diff.py - ClangFormat Diff Reformatter ----*- python -*--===# |
4 # | 4 # |
5 # The LLVM Compiler Infrastructure | 5 # The LLVM Compiler Infrastructure |
6 # | 6 # |
7 # This file is distributed under the University of Illinois Open Source | 7 # This file is distributed under the University of Illinois Open Source |
8 # License. See LICENSE.TXT for details. | 8 # License. See LICENSE.TXT for details. |
9 # | 9 # |
10 #===------------------------------------------------------------------------===# | 10 #===------------------------------------------------------------------------===# |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 formatted_code = StringIO.StringIO(stdout).readlines() | 105 formatted_code = StringIO.StringIO(stdout).readlines() |
106 diff = difflib.unified_diff(code, formatted_code, | 106 diff = difflib.unified_diff(code, formatted_code, |
107 filename, filename, | 107 filename, filename, |
108 '(before formatting)', '(after formatting)') | 108 '(before formatting)', '(after formatting)') |
109 diff_string = string.join(diff, '') | 109 diff_string = string.join(diff, '') |
110 if len(diff_string) > 0: | 110 if len(diff_string) > 0: |
111 sys.stdout.write(diff_string) | 111 sys.stdout.write(diff_string) |
112 | 112 |
113 if __name__ == '__main__': | 113 if __name__ == '__main__': |
114 main() | 114 main() |
OLD | NEW |