+2012-02-15 Sam Weinig <sam@webkit.org>
+
+ Add style check for ctype functions that are generally frowned upon in WebKit
+ https://bugs.webkit.org/show_bug.cgi?id=78748
+
+ Reviewed by Anders Carlsson.
+
+ Not every platform has DisallowCType.h to check for uses of the ctype.h
+ functions, so add a style check for them as well.
+
+ * Scripts/webkitpy/style/checkers/cpp.py:
+ (check_ctype_functions):
+ (check_style):
+ (CppChecker):
+ Add check.
+
+ * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+ (WebKitStyleTest.test_ctype_fucntion):
+ Add checker.
+
2012-02-15 Szilard Ledan <Ledan-Muntean.Szilard@stud.u-szeged.hu>
[Qt][WK2] WebKitTestRunner should use 480x360 sized view for W3C SVG tests
% (max_min_macro_lower, max_min_macro_lower, max_min_macro))
+def check_ctype_functions(clean_lines, line_number, file_state, error):
+ """Looks for use of the standard functions in ctype.h and suggest they be replaced
+ by use of equivilent ones in <wtf/ASCIICType.h>?.
+
+ Args:
+ clean_lines: A CleansedLines instance containing the file.
+ line_number: The number of the line to check.
+ file_state: A _FileState instance which maintains information about
+ the state of things in the file.
+ error: The function to call with any errors found.
+ """
+
+ line = clean_lines.elided[line_number] # Get rid of comments and strings.
+
+ ctype_function_search = search(r'\b(?P<ctype_function>(isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower|isprint|ispunct|isspace|isupper|isxdigit|toascii|tolower|toupper))\s*\(', line)
+ if not ctype_function_search:
+ return
+
+ ctype_function = ctype_function_search.group('ctype_function')
+ error(line_number, 'runtime/ctype_function', 4,
+ 'Use equivelent function in <wtf/ASCIICType.h> instead of the %s() function.'
+ % (ctype_function))
+
def check_switch_indentation(clean_lines, line_number, error):
"""Looks for indentation errors inside of switch statements.
check_namespace_indentation(clean_lines, line_number, file_extension, file_state, error)
check_using_std(clean_lines, line_number, file_state, error)
check_max_min_macros(clean_lines, line_number, file_state, error)
+ check_ctype_functions(clean_lines, line_number, file_state, error)
check_switch_indentation(clean_lines, line_number, error)
check_braces(clean_lines, line_number, error)
check_exit_statement_simplifications(clean_lines, line_number, error)
'runtime/arrays',
'runtime/bitfields',
'runtime/casting',
+ 'runtime/ctype_function',
'runtime/explicit',
'runtime/init',
'runtime/int',
' [runtime/max_min_macros] [4]',
'foo.h')
+ def test_ctype_fucntion(self):
+ self.assert_lint(
+ 'int i = isascii(8);',
+ 'Use equivelent function in <wtf/ASCIICType.h> instead of the '
+ 'isascii() function. [runtime/ctype_function] [4]',
+ 'foo.cpp')
+
def test_names(self):
name_underscore_error_message = " is incorrectly named. Don't use underscores in your identifier names. [readability/naming] [4]"
name_tooshort_error_message = " is incorrectly named. Don't use the single letter 'l' as an identifier name. [readability/naming] [4]"