Chromium Code Reviews| Index: cc/PRESUBMIT.py |
| diff --git a/cc/PRESUBMIT.py b/cc/PRESUBMIT.py |
| index bcf71ef0d52800f862be518a40f0bce2be1d7709..051a3eef28ec35bc3bba0392b24a302023ce1b4f 100644 |
| --- a/cc/PRESUBMIT.py |
| +++ b/cc/PRESUBMIT.py |
| @@ -76,9 +76,16 @@ def CheckStdAbs(input_api, output_api, |
| found_fabs_files.append(f.LocalPath()); |
| # The following regular expression in words says: |
| # "if there is no 'std::' behind an 'abs(' or 'absf(', |
| - # or if there is no 'std::' behind a 'fabs(' or 'fabsf(', |
| + # OR if there is no 'std::' behind a 'fabs(' or 'fabsf(', |
| + # AND if there's no '// NOLINT' on the same line of code, |
| # then it's a match." |
| - if re.search(r"((?<!std::)(\babsf?\()|(?<!std::)(\bfabsf?\())", contents): |
| + # Note that \ characters have to be escaped since these |
| + # are not explicitly defined as regexes. |
| + no_abs = "((?<!std::)(\\babsf?\\()" |
| + no_fabs = "(?<!std::)(\\bfabsf?\\())" |
| + no_nolint = "(?![^\\n]*// NOLINT)" |
|
enne (OOO)
2013/09/05 01:00:40
Maybe \s+ instead of the space in NOLINT?
|
| + expression = re.compile("%s|%s%s" % (no_abs, no_fabs, no_nolint)) |
|
enne (OOO)
2013/09/05 01:00:40
If you're going to put an | outside of the strings
|
| + if expression.search(contents): |
| missing_std_prefix_files.append(f.LocalPath()) |
| result = [] |