[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

levin at chromium.org levin at chromium.org
Wed Dec 22 15:47:11 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 4dfe19795626e325c072aca744fb485a72502eb0
Author: levin at chromium.org <levin at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Nov 12 07:39:25 2010 +0000

    check-webkit-style function detection doesn't handle templates with spaces.
    https://bugs.webkit.org/show_bug.cgi?id=49427
    
    Reviewed by Shinichiro Hamaji.
    
    * Scripts/webkitpy/style/checkers/cpp.py: Stripped out templates when
      finding the function name.
    * Scripts/webkitpy/style/checkers/cpp_unittest.py: Made the test have a
      template with a space.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71896 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index ae8eb27..37de9de 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,15 @@
+2010-11-11  David Levin  <levin at chromium.org>
+
+        Reviewed by Shinichiro Hamaji.
+
+        check-webkit-style function detection doesn't handle templates with spaces.
+        https://bugs.webkit.org/show_bug.cgi?id=49427
+
+        * Scripts/webkitpy/style/checkers/cpp.py: Stripped out templates when
+          finding the function name.
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py: Made the test have a
+          template with a space.
+
 2010-11-11  Ademar de Souza Reis Jr  <ademar.reis at openbossa.org>
 
         Reviewed by Shinichiro Hamaji.
diff --git a/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py b/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py
index 91e2c1e..be63d7f 100644
--- a/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py
+++ b/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py
@@ -152,6 +152,37 @@ def subn(pattern, replacement, s):
     return _regexp_compile_cache[pattern].subn(replacement, s)
 
 
+def iteratively_replace_matches_with_char(pattern, s, char):
+    """Returns the string with replacements.
+
+    Every character in the match is replaced with char.
+    Due to the iterative nature, pattern should not match char or
+    there will be an infinite loop.
+
+    Example:
+      pattern = r'<[^>]>' # template parameters
+      s =     'A<B<C, D>>'
+      char =  '_'
+      Returns 'A_________'
+
+    Args:
+      pattern: the regex to match
+      s: the string on which to do the replacements.
+      char: the character to put in the place of the match
+
+    Returns:
+      True, if the given line is blank.
+    """
+    while True:
+        matched = search(pattern, s)
+        if not matched:
+            return s
+        start_match_index = matched.start(0)
+        end_match_index = matched.end(0)
+        match_length = end_match_index - start_match_index
+        s = s[:start_match_index] + char * match_length + s[end_match_index:]
+
+
 def up_to_unmatched_closing_paren(s):
     """Splits a string into two parts up to first unmatched ')'.
 
@@ -1156,7 +1187,15 @@ def check_for_function_lengths(clean_lines, line_number, function_state, error):
                 break                              # ... ignore
             if search(r'{', start_line):
                 body_found = True
-                function = search(r'((\w|:|<|>|,|~)*)\(', line).group(1)
+                # Replace template constructs with _ so that no spaces remain in the function name,
+                # while keeping the column numbers of other characters the same as "line".
+                line_with_no_templates = iteratively_replace_matches_with_char(r'<[^<>]*>', line, "_")
+                match_function = search(r'((\w|:|<|>|,|~)*)\(', line_with_no_templates)
+
+                # Use the column numbers from the modified line to find the
+                # function name in the original line.
+                function = line[match_function.start(1):match_function.end(1)]
+
                 if match(r'TEST', function):    # Handle TEST... macros
                     parameter_regexp = search(r'(\(.*\))', joined_line)
                     if parameter_regexp:             # Ignore bad syntax
diff --git a/WebKitTools/Scripts/webkitpy/style/checkers/cpp_unittest.py b/WebKitTools/Scripts/webkitpy/style/checkers/cpp_unittest.py
index 6b42ffa..9b4de27 100644
--- a/WebKitTools/Scripts/webkitpy/style/checkers/cpp_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/style/checkers/cpp_unittest.py
@@ -2448,13 +2448,12 @@ class CheckForFunctionLengthsTest(CppStyleTestBase):
         error_level = 1
         error_lines = self.trigger_lines(error_level) + 1
         trigger_level = self.trigger_lines(self.min_confidence)
-        # FIXME: handle spaces in the template parameters
         self.assert_function_lengths_check(
-            ('my_namespace::my_other_namespace::MyVeryLongTypeName<Type1>*\n'
-             'my_namespace::my_other_namespace<Type2,Type3>::~MyFunction<Type4>(int arg1, char* arg2)'
+            ('my_namespace::my_other_namespace::MyVeryLongTypeName<Type1, Type2>*\n'
+             'my_namespace::my_other_namespace<Type3, Type4>::~MyFunction<Type5<Type6, Type7> >(int arg1, char* arg2)'
              + self.function_body(error_lines)),
             ('Small and focused functions are preferred: '
-             'my_namespace::my_other_namespace<Type2,Type3>::~MyFunction<Type4>()'
+             'my_namespace::my_other_namespace<Type3, Type4>::~MyFunction<Type5<Type6, Type7> >()'
              ' has %d non-comment lines '
              '(error triggered by exceeding %d lines).'
              '  [readability/fn_size] [%d]')

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list