| 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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 the name so that we get header guards that don't include things like | 583 the name so that we get header guards that don't include things like |
| 584 "C:\Documents and Settings\..." or "/home/username/..." in them and thus | 584 "C:\Documents and Settings\..." or "/home/username/..." in them and thus |
| 585 people on different computers who have checked the source out to differe
nt | 585 people on different computers who have checked the source out to differe
nt |
| 586 locations won't see bogus errors. | 586 locations won't see bogus errors. |
| 587 """ | 587 """ |
| 588 fullname = self.full_name() | 588 fullname = self.full_name() |
| 589 | 589 |
| 590 if os.path.exists(fullname): | 590 if os.path.exists(fullname): |
| 591 project_dir = os.path.dirname(fullname) | 591 project_dir = os.path.dirname(fullname) |
| 592 | 592 |
| 593 if os.path.exists(os.path.join(project_dir, '.svn')): | 593 # Try to find a git top level directory by searching up from the cur
rent path. |
| 594 # If there's a .svn file in the current directory, we | |
| 595 # recursively look up the directory tree for the top | |
| 596 # of the SVN checkout | |
| 597 root_dir = project_dir | |
| 598 one_up_dir = os.path.dirname(root_dir) | |
| 599 while os.path.exists(os.path.join(one_up_dir, '.svn')): | |
| 600 root_dir = os.path.dirname(root_dir) | |
| 601 one_up_dir = os.path.dirname(one_up_dir) | |
| 602 | |
| 603 prefix = os.path.commonprefix([root_dir, project_dir]) | |
| 604 return fullname[len(prefix) + 1:] | |
| 605 | |
| 606 # Not SVN? Try to find a git top level directory by | |
| 607 # searching up from the current path. | |
| 608 root_dir = os.path.dirname(fullname) | 594 root_dir = os.path.dirname(fullname) |
| 609 while (root_dir != os.path.dirname(root_dir) | 595 while (root_dir != os.path.dirname(root_dir) |
| 610 and not os.path.exists(os.path.join(root_dir, '.git'))): | 596 and not os.path.exists(os.path.join(root_dir, '.git'))): |
| 611 root_dir = os.path.dirname(root_dir) | 597 root_dir = os.path.dirname(root_dir) |
| 612 if os.path.exists(os.path.join(root_dir, '.git')): | 598 if os.path.exists(os.path.join(root_dir, '.git')): |
| 613 prefix = os.path.commonprefix([root_dir, project_dir]) | 599 prefix = os.path.commonprefix([root_dir, project_dir]) |
| 614 return fullname[len(prefix) + 1:] | 600 return fullname[len(prefix) + 1:] |
| 615 | 601 |
| 616 # Don't know what to do; header guard warnings may be wrong... | 602 # Don't know what to do; header guard warnings may be wrong... |
| 617 return fullname | 603 return fullname |
| (...skipping 2848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3466 | 3452 |
| 3467 def check(self, lines): | 3453 def check(self, lines): |
| 3468 _process_lines(self.file_path, self.file_extension, lines, | 3454 _process_lines(self.file_path, self.file_extension, lines, |
| 3469 self.handle_style_error, self.min_confidence) | 3455 self.handle_style_error, self.min_confidence) |
| 3470 | 3456 |
| 3471 | 3457 |
| 3472 # FIXME: Remove this function (requires refactoring unit tests). | 3458 # FIXME: Remove this function (requires refactoring unit tests). |
| 3473 def process_file_data(filename, file_extension, lines, error, min_confidence, fs
=None): | 3459 def process_file_data(filename, file_extension, lines, error, min_confidence, fs
=None): |
| 3474 checker = CppChecker(filename, file_extension, error, min_confidence, fs) | 3460 checker = CppChecker(filename, file_extension, error, min_confidence, fs) |
| 3475 checker.check(lines) | 3461 checker.check(lines) |
| OLD | NEW |