| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2012 the V8 project authors. All rights reserved. | 3 # Copyright 2012 the V8 project authors. All rights reserved. |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 parts.pop() | 355 parts.pop() |
| 356 for part in parts: | 356 for part in parts: |
| 357 line += part.count('\n') + 1 | 357 line += part.count('\n') + 1 |
| 358 lines.append(str(line)) | 358 lines.append(str(line)) |
| 359 linenumbers = ', '.join(lines) | 359 linenumbers = ', '.join(lines) |
| 360 if len(lines) > 1: | 360 if len(lines) > 1: |
| 361 print "%s has trailing whitespaces in lines %s." % (name, linenumbers) | 361 print "%s has trailing whitespaces in lines %s." % (name, linenumbers) |
| 362 else: | 362 else: |
| 363 print "%s has trailing whitespaces in line %s." % (name, linenumbers) | 363 print "%s has trailing whitespaces in line %s." % (name, linenumbers) |
| 364 result = False | 364 result = False |
| 365 if not contents.endswith('\n') or contents.endswith('\n\n'): |
| 366 print "%s does not end with a single new line." % name |
| 367 result = False |
| 365 # Check two empty lines between declarations. | 368 # Check two empty lines between declarations. |
| 366 if name.endswith(".cc"): | 369 if name.endswith(".cc"): |
| 367 line = 0 | 370 line = 0 |
| 368 lines = [] | 371 lines = [] |
| 369 parts = contents.split('\n') | 372 parts = contents.split('\n') |
| 370 while line < len(parts) - 2: | 373 while line < len(parts) - 2: |
| 371 if self.EndOfDeclaration(parts[line]): | 374 if self.EndOfDeclaration(parts[line]): |
| 372 if self.StartOfDeclaration(parts[line + 1]): | 375 if self.StartOfDeclaration(parts[line + 1]): |
| 373 lines.append(str(line + 1)) | 376 lines.append(str(line + 1)) |
| 374 line += 1 | 377 line += 1 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 "two empty lines between declarations check..." | 426 "two empty lines between declarations check..." |
| 424 success = SourceProcessor().Run(workspace) and success | 427 success = SourceProcessor().Run(workspace) and success |
| 425 if success: | 428 if success: |
| 426 return 0 | 429 return 0 |
| 427 else: | 430 else: |
| 428 return 1 | 431 return 1 |
| 429 | 432 |
| 430 | 433 |
| 431 if __name__ == '__main__': | 434 if __name__ == '__main__': |
| 432 sys.exit(Main()) | 435 sys.exit(Main()) |
| OLD | NEW |