From 9c15bc7f0c909b19ce6876aff8b6bfcbf39da9e5 Mon Sep 17 00:00:00 2001 From: Grigory Serebryakov Date: Tue, 24 Jan 2017 10:43:52 +0300 Subject: [PATCH] Fix missing header finder regexp for a more general case --- cpplint/cpplint.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cpplint/cpplint.py b/cpplint/cpplint.py index 4708226..bed0210 100755 --- a/cpplint/cpplint.py +++ b/cpplint/cpplint.py @@ -169,8 +169,8 @@ Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...] The "root" option is similar in function to the --root flag (see example above). - - The "headers" option is similar in function to the --headers flag + + The "headers" option is similar in function to the --headers flag (see example above). CPPLINT.cfg has an effect on files in the same directory and all @@ -5323,7 +5323,22 @@ for _header, _templates in _HEADERS_MAYBE_TEMPLATES: # Match max(..., ...), max(..., ...), ::max(..., ...) but not # foo->max, foo.max or type::max(). _re_pattern_headers_maybe_templates.append( - (re.compile(r'[^>.](?)?\([^\)]'), + (re.compile(r""" + ( + \bstd:: | # starts with std:: + [(+\-=?%^&*/\[] | # used in arithmetic expression or ternary conditional operator + [^:]: | # the second part of ternary conditional operator + ^ # or just the start of the line + ) [\s]* # possibly we have spaces + """ + _template + + r""" + ( + [\s]* # possibly, spaces + <.*?> # the arguments for the template + )? # we can omit the template part + [\s]* #spaces + \( [^\)] # after function we should have opening brace + """, re.X), _template, _header))