Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python2.4 | |
|
M-A Ruel
2011/09/07 19:18:29
Ugh? Why this copyright? Where did you copy that f
Alexei Svitkine (slow)
2011/09/07 19:46:06
Sorry, should have included the context:
This is
M-A Ruel
2011/09/07 19:52:07
Ok, but remove the shebang.
Alexei Svitkine (slow)
2011/09/07 20:27:57
Done.
| |
| 2 # | |
| 3 # Copyright (c) 2011 Google Inc. All rights reserved. | |
| 4 # Copyright (c) 2009 Torch Mobile Inc. | |
| 5 # | |
| 6 # Redistribution and use in source and binary forms, with or without | |
| 7 # modification, are permitted provided that the following conditions are | |
| 8 # met: | |
| 9 # | |
| 10 # * Redistributions of source code must retain the above copyright | |
| 11 # notice, this list of conditions and the following disclaimer. | |
| 12 # * Redistributions in binary form must reproduce the above | |
| 13 # copyright notice, this list of conditions and the following disclaimer | |
| 14 # in the documentation and/or other materials provided with the | |
| 15 # distribution. | |
| 16 # * Neither the name of Google Inc. nor the names of its | |
| 17 # contributors may be used to endorse or promote products derived from | |
| 18 # this software without specific prior written permission. | |
| 19 # | |
| 20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 23 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 24 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 31 | |
| 32 import re | |
| 33 | |
| 34 # Matches Foo *foo declarations. | |
| 35 _RE_PATTERN_POINTER_DECLARATION_WHITESPACE = re.compile( | |
| 36 r'\s*\w+(?<!\breturn|\bdelete)\s+(?P<pointer_operator>\*|\&)\w+') | |
| 37 | |
| 38 def CheckPointerDeclarationWhitespace(filename, clean_lines, linenum, error): | |
| 39 """Checks for Foo *foo declarations. | |
| 40 | |
| 41 Args: | |
| 42 filename: The name of the current file. | |
| 43 clean_lines: A CleansedLines instance containing the file. | |
| 44 linenum: The number of the line to check. | |
| 45 error: The function to call with any errors found. | |
| 46 """ | |
| 47 line = clean_lines.elided[linenum] | |
| 48 matched = _RE_PATTERN_POINTER_DECLARATION_WHITESPACE.match(line) | |
| 49 if matched: | |
| 50 error(filename, linenum, 'whitespace/declaration', 3, | |
| 51 'Declaration has space between type name and %s in %s' % | |
| 52 (matched.group('pointer_operator'), matched.group(0).strip())) | |
| OLD | NEW |