diff --git a/buildsystem/codecompliance/cppstyle.py b/buildsystem/codecompliance/cppstyle.py index c05021e223..43a3a17af7 100644 --- a/buildsystem/codecompliance/cppstyle.py +++ b/buildsystem/codecompliance/cppstyle.py @@ -1,4 +1,4 @@ -# Copyright 2015-2017 the openage authors. See copying.md for legal info. +# Copyright 2015-2026 the openage authors. See copying.md for legal info. """ Checks some code style rules for cpp files. @@ -47,6 +47,33 @@ r")" ) +# Compound-assignment and comparison operators that must be surrounded by spaces. +# Ordered longest-first; < and >-based ops use lookbehind/lookahead to avoid +# matching the shorter pattern inside a longer one (e.g. >= inside >>=, +# <= inside <<= or the C++20 <=> spaceship operator). +_SPACED_OPS_ALT = ( + r'<<=|>>=|' + r'\+=|-=|\*=|%=|\^=|\|=|&=|~=|' + r'(?)|(?)>=|' + r'==|!=' +) + +OPERATOR_SPACING_RE = re.compile( + r'(?