From 2052bc1a59f3c1a58396fa9381a5ed81928b14b9 Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Wed, 25 Dec 2013 20:41:18 +1100 Subject: [PATCH] Add check for preprocessor indentation --- check_source/check_style_c.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/check_source/check_style_c.py b/check_source/check_style_c.py index 447d85f..eb1c0bb 100755 --- a/check_source/check_style_c.py +++ b/check_source/check_style_c.py @@ -812,8 +812,20 @@ def quick_check_indentation(lines): # comment or pre-processor if ls: # #ifdef ... or ... // comment - if (ls[0] == "#" or ls[0:2] == "//"): + if ls[0] == "#": + + # check preprocessor indentation here + # basic rules, NEVER INDENT + # just need to check multi-line macros. + if l[0] != "#": + # we have indent, check previous line + if not ls_prev.rstrip().endswith("\\"): + # report indented line + warning_lineonly("indentation found with preprocessor (expected none or after '#')", i + 1) + skip = True + if ls[0:2] == "//": + skip = true # label: elif (':' in ls and l[0] != '\t'): skip = True -- GitLab