summaryrefslogtreecommitdiff
path: root/lib/checksrc.pl
diff options
context:
space:
mode:
authorDaniel Gustafsson <daniel@yesql.se>2018-04-25 21:53:27 +0200
committerDaniel Stenberg <daniel@haxx.se>2018-04-27 00:51:35 +0200
commit2f13e3d23d9acd448b1e1e2cad419b4c118c43e4 (patch)
tree9dc0c85afa6f373af02b03734c8c4d12f60d1667 /lib/checksrc.pl
parent1d71ce845a6ac3887205c2842fad0a476f7cf3ec (diff)
downloadcurl-2f13e3d23d9acd448b1e1e2cad419b4c118c43e4.tar.gz
checksrc: force indentation of lines after an else
This extends the INDENTATION case to also handle 'else' statements and require proper indentation on the following line. Also fixes the offending cases found in the codebase. Closes #2532
Diffstat (limited to 'lib/checksrc.pl')
-rwxr-xr-xlib/checksrc.pl8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/checksrc.pl b/lib/checksrc.pl
index 1a695ba2c..c90e245ee 100755
--- a/lib/checksrc.pl
+++ b/lib/checksrc.pl
@@ -499,9 +499,9 @@ sub scanfile {
}
# if the previous line starts with if/while/for AND ends with an open
- # brace, check that this line is indented $indent more steps, if not
- # a cpp line
- if($prevl =~ /^( *)(if|while|for)\(.*\{\z/) {
+ # brace, or an else statement, check that this line is indented $indent
+ # more steps, if not a cpp line
+ if($prevl =~ /^( *)((if|while|for)\(.*\{|else)\z/) {
my $first = length($1);
# this line has some character besides spaces
@@ -511,7 +511,7 @@ sub scanfile {
if($expect != $second) {
my $diff = $second - $first;
checkwarn("INDENTATION", $line, length($1), $file, $ol,
- "not indented $indent steps, uses $diff)");
+ "not indented $indent steps (uses $diff)");
}
}