| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Given a filename as an argument, sort the #include/#imports in that file. | 6 """Given a filename as an argument, sort the #include/#imports in that file. |
| 7 | 7 |
| 8 Shows a diff and prompts for confirmation before doing the deed. | 8 Shows a diff and prompts for confirmation before doing the deed. |
| 9 Works great with tools/git/for-all-touched-files.py. | 9 Works great with tools/git/for-all-touched-files.py. |
| 10 """ | 10 """ |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 line = line[len(prefix):] | 46 line = line[len(prefix):] |
| 47 break | 47 break |
| 48 | 48 |
| 49 # The win32 api has all sorts of implicit include order dependencies :-/ | 49 # The win32 api has all sorts of implicit include order dependencies :-/ |
| 50 # Give a few headers special sort keys that make sure they appear before all | 50 # Give a few headers special sort keys that make sure they appear before all |
| 51 # other headers. | 51 # other headers. |
| 52 if line.startswith('<windows.h>'): # Must be before e.g. shellapi.h | 52 if line.startswith('<windows.h>'): # Must be before e.g. shellapi.h |
| 53 return '0' | 53 return '0' |
| 54 if line.startswith('<atlbase.h>'): # Must be before atlapp.h. | 54 if line.startswith('<atlbase.h>'): # Must be before atlapp.h. |
| 55 return '1' + line | 55 return '1' + line |
| 56 if line.startswith('<ole2.h>'): # Must be before e.g. intshcut.h |
| 57 return '1' + line |
| 56 if line.startswith('<unknwn.h>'): # Must be before e.g. intshcut.h | 58 if line.startswith('<unknwn.h>'): # Must be before e.g. intshcut.h |
| 57 return '1' + line | 59 return '1' + line |
| 58 | 60 |
| 59 # C++ system headers should come after C system headers. | 61 # C++ system headers should come after C system headers. |
| 60 if line.startswith('<'): | 62 if line.startswith('<'): |
| 61 if line.find('.h>') != -1: | 63 if line.find('.h>') != -1: |
| 62 return '2' + line.lower() | 64 return '2' + line.lower() |
| 63 else: | 65 else: |
| 64 return '3' + line.lower() | 66 return '3' + line.lower() |
| 65 | 67 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 if len(filenames) < 1: | 179 if len(filenames) < 1: |
| 178 parser.print_help() | 180 parser.print_help() |
| 179 return 1 | 181 return 1 |
| 180 | 182 |
| 181 for filename in filenames: | 183 for filename in filenames: |
| 182 DiffAndConfirm(filename, opts.should_confirm, opts.perform_safety_checks) | 184 DiffAndConfirm(filename, opts.should_confirm, opts.perform_safety_checks) |
| 183 | 185 |
| 184 | 186 |
| 185 if __name__ == '__main__': | 187 if __name__ == '__main__': |
| 186 sys.exit(main()) | 188 sys.exit(main()) |
| OLD | NEW |