summaryrefslogtreecommitdiff
path: root/Tools/Scripts/webkitpy/style/checkers/cpp.py
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-07-18 13:59:13 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-07-18 13:59:28 +0200
commit4d6084feccab99c0a7b3ecef26bb49c41dd50201 (patch)
treefd1195897f551eee6d5a15d07ff5733b15aa2a5c /Tools/Scripts/webkitpy/style/checkers/cpp.py
parentae901828d4689ab9e89113f6b6ea8042b37a9fda (diff)
downloadqtwebkit-4d6084feccab99c0a7b3ecef26bb49c41dd50201.tar.gz
Imported WebKit commit ff52235a78888e5cb8e286a828a8698042200e67 (http://svn.webkit.org/repository/webkit/trunk@122948)
New snapshot that should fix the rendering issues recently introduced
Diffstat (limited to 'Tools/Scripts/webkitpy/style/checkers/cpp.py')
-rw-r--r--Tools/Scripts/webkitpy/style/checkers/cpp.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/Tools/Scripts/webkitpy/style/checkers/cpp.py b/Tools/Scripts/webkitpy/style/checkers/cpp.py
index aaad85d5c..ba1153087 100644
--- a/Tools/Scripts/webkitpy/style/checkers/cpp.py
+++ b/Tools/Scripts/webkitpy/style/checkers/cpp.py
@@ -1161,14 +1161,19 @@ class _FileState(object):
self._clean_lines = clean_lines
if file_extension in ['m', 'mm']:
self._is_objective_c = True
+ self._is_c = False
elif file_extension == 'h':
# In the case of header files, it is unknown if the file
- # is objective c or not, so set this value to None and then
+ # is c / objective c or not, so set this value to None and then
# if it is requested, use heuristics to guess the value.
self._is_objective_c = None
+ self._is_c = None
+ elif file_extension == 'c':
+ self._is_c = True
+ self._is_objective_c = False
else:
self._is_objective_c = False
- self._is_c = file_extension == 'c'
+ self._is_c = False
def set_did_inside_namespace_indent_warning(self):
self._did_inside_namespace_indent_warning = True
@@ -1188,9 +1193,21 @@ class _FileState(object):
self._is_objective_c = False
return self._is_objective_c
+ def is_c(self):
+ if self._is_c is None:
+ for line in self._clean_lines.lines:
+ # if extern "C" is found, then it is a good indication
+ # that we have a C header file.
+ if line.startswith('extern "C"'):
+ self._is_c = True
+ break
+ else:
+ self._is_c = False
+ return self._is_c
+
def is_c_or_objective_c(self):
"""Return whether the file extension corresponds to C or Objective-C."""
- return self._is_c or self.is_objective_c()
+ return self.is_c() or self.is_objective_c()
def check_for_non_standard_constructs(clean_lines, line_number,