PRESUBMIT #include check enhancement: <sys/..> includes can be in any order.
E.g.,
need to be in this order, since the latter uses definitions from the former.
BUG=NONE
Review URL: https://codereview.chromium.org/11418128
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169290 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 7d93fa2..2fba7a51 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -558,6 +558,9 @@
"""Checks the #include order for the given file f."""
system_include_pattern = input_api.re.compile(r'\s*#include \<.*')
+ # Exclude #include <.../...> includes from the check; e.g., <sys/...> includes
+ # often need to appear in a specific order.
+ excluded_include_pattern = input_api.re.compile(r'\s*#include \<.*/.*')
custom_include_pattern = input_api.re.compile(r'\s*#include "(?P<FILE>.*)"')
if_pattern = input_api.re.compile(r'\s*#\s*(if|elif|else|endif).*')
@@ -596,8 +599,9 @@
if if_pattern.match(line):
scopes.append(current_scope)
current_scope = []
- elif (system_include_pattern.match(line) or
- custom_include_pattern.match(line)):
+ elif ((system_include_pattern.match(line) or
+ custom_include_pattern.match(line)) and
+ not excluded_include_pattern.match(line)):
current_scope.append((line_num, line))
scopes.append(current_scope)