OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 # | 2 # |
3 # Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved. | 3 # Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved. |
4 # Copyright (C) 2009 Torch Mobile Inc. | 4 # Copyright (C) 2009 Torch Mobile Inc. |
5 # Copyright (C) 2009 Apple Inc. All rights reserved. | 5 # Copyright (C) 2009 Apple Inc. All rights reserved. |
6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) | 6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) |
7 # | 7 # |
8 # Redistribution and use in source and binary forms, with or without | 8 # Redistribution and use in source and binary forms, with or without |
9 # modification, are permitted provided that the following conditions are | 9 # modification, are permitted provided that the following conditions are |
10 # met: | 10 # met: |
(...skipping 3349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3360 line = sub(r'new\s*(\([^)]*\))?', '', line) | 3360 line = sub(r'new\s*(\([^)]*\))?', '', line) |
3361 | 3361 |
3362 # Remove all template parameters by removing matching < and >. | 3362 # Remove all template parameters by removing matching < and >. |
3363 # Loop until no templates are removed to remove nested templates. | 3363 # Loop until no templates are removed to remove nested templates. |
3364 while True: | 3364 while True: |
3365 line, number_of_replacements = subn(r'<([\w\s:]|::)+\s*[*&]*\s*>', '', l
ine) | 3365 line, number_of_replacements = subn(r'<([\w\s:]|::)+\s*[*&]*\s*>', '', l
ine) |
3366 if not number_of_replacements: | 3366 if not number_of_replacements: |
3367 break | 3367 break |
3368 | 3368 |
3369 # Declarations of local variables can be in condition expressions | 3369 # Declarations of local variables can be in condition expressions |
3370 # of control flow statements (e.g., "if (RenderObject* p = o->parent())"). | 3370 # of control flow statements (e.g., "if (LayoutObject* p = o->parent())"). |
3371 # We remove the keywords and the first parenthesis. | 3371 # We remove the keywords and the first parenthesis. |
3372 # | 3372 # |
3373 # Declarations in "while", "if", and "switch" are different from | 3373 # Declarations in "while", "if", and "switch" are different from |
3374 # other declarations in two aspects: | 3374 # other declarations in two aspects: |
3375 # | 3375 # |
3376 # - There can be only one declaration between the parentheses. | 3376 # - There can be only one declaration between the parentheses. |
3377 # (i.e., you cannot write "if (int i = 0, j = 1) {}") | 3377 # (i.e., you cannot write "if (int i = 0, j = 1) {}") |
3378 # - The variable must be initialized. | 3378 # - The variable must be initialized. |
3379 # (i.e., you cannot write "if (int i) {}") | 3379 # (i.e., you cannot write "if (int i) {}") |
3380 # | 3380 # |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4086 | 4086 |
4087 def check(self, lines): | 4087 def check(self, lines): |
4088 _process_lines(self.file_path, self.file_extension, lines, | 4088 _process_lines(self.file_path, self.file_extension, lines, |
4089 self.handle_style_error, self.min_confidence) | 4089 self.handle_style_error, self.min_confidence) |
4090 | 4090 |
4091 | 4091 |
4092 # FIXME: Remove this function (requires refactoring unit tests). | 4092 # FIXME: Remove this function (requires refactoring unit tests). |
4093 def process_file_data(filename, file_extension, lines, error, min_confidence, fs
=None): | 4093 def process_file_data(filename, file_extension, lines, error, min_confidence, fs
=None): |
4094 checker = CppChecker(filename, file_extension, error, min_confidence, fs) | 4094 checker = CppChecker(filename, file_extension, error, min_confidence, fs) |
4095 checker.check(lines) | 4095 checker.check(lines) |
OLD | NEW |