From 1754c5fa399dc4ae477fce3d74bb6fba564c709f Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Fri, 30 Sep 2016 14:30:33 -0700 Subject: [PATCH] Reapply patches Reapply parts of 232428752251de61e84ef013bcd643e35eb9038d that are still relevant. --- ament_cpplint/ament_cpplint/cpplint.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ament_cpplint/ament_cpplint/cpplint.py b/ament_cpplint/ament_cpplint/cpplint.py index 1737509b..3f3623cc 100644 --- a/ament_cpplint/ament_cpplint/cpplint.py +++ b/ament_cpplint/ament_cpplint/cpplint.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2009 Google Inc. All rights reserved. # @@ -69,7 +69,6 @@ # -- pylint: disable=redefined-builtin xrange = range # Python 3 - _USAGE = """ Syntax: cpplint.py [--verbose=#] [--output=emacs|eclipse|vs7|junit|sed|gsed] [--filter=-x,+y,...] @@ -1612,6 +1611,7 @@ def RepositoryName(self): os.path.exists(os.path.join(current_dir, ".hg")) or os.path.exists(os.path.join(current_dir, ".svn"))): root_dir = current_dir + break current_dir = os.path.dirname(current_dir) if (os.path.exists(os.path.join(root_dir, ".git")) or @@ -2845,7 +2845,7 @@ def CheckEnd(self, filename, clean_lines, linenum, error): # deciding what these nontrivial things are, so this check is # triggered by namespace size only, which works most of the time. if (linenum - self.starting_linenum < 10 - and not Match(r'^\s*};*\s*(//|/\*).*\bnamespace\b', line)): + and not Match(r'^\s*};*\s*(//).*\bnamespace\b', line)): return # Look for matching comment at end of namespace. @@ -2862,7 +2862,7 @@ def CheckEnd(self, filename, clean_lines, linenum, error): # expected namespace. if self.name: # Named namespace - if not Match((r'^\s*};*\s*(//|/\*).*\bnamespace\s+' + + if not Match((r'^\s*};*\s*(//).*\bnamespace\s+' + re.escape(self.name) + r'[\*/\.\\\s]*$'), line): error(filename, linenum, 'readability/namespace', 5, @@ -5856,6 +5856,10 @@ def CheckCStyleCast(filename, clean_lines, linenum, cast_type, pattern, error): remainder): return False + # Don't warn in C files about C-style casts + if os.path.splitext(filename)[1] in ['.c', '.h']: + return False + # At this point, all that should be left is actual casts. error(filename, linenum, 'readability/casting', 4, 'Using C-style cast. Use %s<%s>(...) instead' %