aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy.py
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2015-08-14 09:11:54 -0400
committerJosh Matthews <josh@joshmatthews.net>2015-08-16 10:31:49 -0400
commitf6b3bebf84abd50025889b87bb5aca32cbece0b4 (patch)
tree65568bc52bedae1c0626cfca00029b9aa5013b68 /python/tidy.py
parenta147cbe0c14609faab9e3e64f3df823b0ae9973a (diff)
downloadservo-f6b3bebf84abd50025889b87bb5aca32cbece0b4.tar.gz
servo-f6b3bebf84abd50025889b87bb5aca32cbece0b4.zip
Deal with /* /* when checking syntax.
Diffstat (limited to 'python/tidy.py')
-rw-r--r--python/tidy.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/python/tidy.py b/python/tidy.py
index e2583ce87ba..20306baf1bb 100644
--- a/python/tidy.py
+++ b/python/tidy.py
@@ -175,22 +175,21 @@ def check_rust(file_name, contents):
comment_depth = 0
merged_lines = ''
for idx, line in enumerate(contents):
- # simplify the analisis
+ # simplify the analysis
line = line.strip()
- if line.find('/*') != -1:
- if line.find('*/') == -1:
- comment_depth += 1
- elif line.find('*/') != -1:
- comment_depth -= 1
+ # Simple heuristic to avoid common case of no comments.
+ if '/' in line:
+ comment_depth += line.count('/*')
+ comment_depth -= line.count('*/')
if line.endswith('\\'):
merged_lines += line[:-1]
continue
- elif comment_depth:
+ if comment_depth:
merged_lines += line
continue
- elif merged_lines:
+ if merged_lines:
line = merged_lines + line
merged_lines = ''