[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:48:15 UTC 2010


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

    cpp.py needs some tidying.
    https://bugs.webkit.org/show_bug.cgi?id=49443
    
    Reviewed by Adam Barth.
    
    * Scripts/webkitpy/style/checkers/cpp.py:
      Fix parameter ordering for iteratively_replace_matches_with_char
      to mirror other similar functions (and improved comments, etc.)
      Also, use a python-ism (for/else) to get rid of a variable that
      was there to determine if something had been found in the loop.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71926 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 6cc11b4..d06818a 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,16 @@
+2010-11-12  David Levin  <levin at chromium.org>
+
+        Reviewed by Adam Barth.
+
+        cpp.py needs some tidying.
+        https://bugs.webkit.org/show_bug.cgi?id=49443
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+          Fix parameter ordering for iteratively_replace_matches_with_char
+          to mirror other similar functions (and improved comments, etc.)
+          Also, use a python-ism (for/else) to get rid of a variable that
+          was there to determine if something had been found in the loop.
+
 2010-11-12  Robert Kroeger  <rjkroege at chromium.org>
 
         Reviewed by James Robinson.
diff --git a/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py b/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py
index be63d7f..1dcc047 100644
--- a/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py
+++ b/WebKitTools/Scripts/webkitpy/style/checkers/cpp.py
@@ -152,8 +152,8 @@ 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.
+def iteratively_replace_matches_with_char(pattern, char_replacement, s):
+    """Returns the string with replacement done.
 
     Every character in the match is replaced with char.
     Due to the iterative nature, pattern should not match char or
@@ -161,14 +161,15 @@ def iteratively_replace_matches_with_char(pattern, s, char):
 
     Example:
       pattern = r'<[^>]>' # template parameters
+      char_replacement =  '_'
       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
+      pattern: The regex to match.
+      char_replacement: The character to put in place of every
+                        character of the match.
+      s: The string on which to do the replacements.
 
     Returns:
       True, if the given line is blank.
@@ -180,7 +181,7 @@ def iteratively_replace_matches_with_char(pattern, s, char):
         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:]
+        s = s[:start_match_index] + char_replacement * match_length + s[end_match_index:]
 
 
 def up_to_unmatched_closing_paren(s):
@@ -1178,18 +1179,15 @@ def check_for_function_lengths(clean_lines, line_number, function_state, error):
             starting_func = True
 
     if starting_func:
-        body_found = False
         for start_line_number in xrange(line_number, clean_lines.num_lines()):
             start_line = lines[start_line_number]
             joined_line += ' ' + start_line.lstrip()
             if search(r'(;|})', start_line):  # Declarations and trivial functions
-                body_found = True
                 break                              # ... ignore
             if search(r'{', start_line):
-                body_found = True
                 # 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, "_")
+                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
@@ -1204,7 +1202,7 @@ def check_for_function_lengths(clean_lines, line_number, function_state, error):
                     function += '()'
                 function_state.begin(function)
                 break
-        if not body_found:
+        else:
             # No body for the function (or evidence of a non-function) was found.
             error(line_number, 'readability/fn_size', 5,
                   'Lint failed to find start of function body.')

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list