diff options
Diffstat (limited to 'src/clint.py')
| -rwxr-xr-x | src/clint.py | 10 | 
1 files changed, 7 insertions, 3 deletions
diff --git a/src/clint.py b/src/clint.py index 675b67ccef..8dc41fdb93 100755 --- a/src/clint.py +++ b/src/clint.py @@ -270,6 +270,8 @@ _line_length = 80  # This is set by --extensions flag.  _valid_extensions = set(['c', 'h']) +_RE_COMMENTLINE = re.compile(r'^\s*//') +  def ParseNolintSuppressions(filename, raw_line, linenum, error):      """Updates the global list of error-suppressions. @@ -1358,7 +1360,9 @@ def CheckForOldStyleComments(filename, line, linenum, error):        linenum: The number of the line to check.        error: The function to call with any errors found.      """ -    if line.find('/*') >= 0 and line[-1] != '\\': +    # hack: allow /* inside comment line. Could be extended to allow them inside +    # any // comment. +    if line.find('/*') >= 0 and line[-1] != '\\' and not _RE_COMMENTLINE.match(line):          error(filename, linenum, 'readability/old_style_comment', 5,                '/*-style comment found, it should be replaced with //-style.  '                '/*-style comments are only allowed inside macros.  ' @@ -1769,7 +1773,7 @@ def CheckSpacingForFunctionCall(filename, line, linenum, error):              fncall = match.group(1)              break -    # Except in if/for/while/switch, there should never be space +    # Except in if/for/while/switch/case, there should never be space      # immediately inside parens (eg "f( 3, 4 )").  We make an exception      # for nested parens ( (a+b) + c ).  Likewise, there should never be      # a space before a ( when it's a function argument.  I assume it's a @@ -1783,7 +1787,7 @@ def CheckSpacingForFunctionCall(filename, line, linenum, error):      # Note that we assume the contents of [] to be short enough that      # they'll never need to wrap.      if (  # Ignore control structures. -            not Search(r'\b(if|for|while|switch|return|sizeof)\b', fncall) and +            not Search(r'\b(if|for|while|switch|case|return|sizeof)\b', fncall) and              # Ignore pointers/references to functions.              not Search(r' \([^)]+\)\([^)]*(\)|,$)', fncall) and              # Ignore pointers/references to arrays.  | 
