Commit fc107a53 authored by Brett Wilkins's avatar Brett Wilkins
Browse files

Fixing check for gnu-style braces



Bug #803267
GNU-syle braces should only apply to function definitions and conditional
code blocks.

Change-Id: Ib598abef440ac9923fe5bbe95fe5025df11d82f8
Signed-off-by: default avatarBrett Wilkins <brett@catalyst.net.nz>
parent efd2c596
......@@ -6,6 +6,8 @@ my $found_bad = 0;
my $filename;
my $reported_filename = "";
my $lineno;
my $stack;
my $stackage;
sub bad_line {
my ($why, $line) = @_;
......@@ -62,14 +64,28 @@ while (<>) {
bad_line("conditional and looping statements should have a space between keywords ".
"and the condition brackets", $_);
}
if (/^\s*{/) {
bad_line("opening curly braces are do no need their own line.", $_);
if (/\)$/) {#Note no trailing semicolon
$stack = $_;
}
if (/^\s*{/ && $stack ne "") {
bad_line("opening curly braces do not need their own line.", "$stack\n$_");
$stack = "";
}
if (/require_once\s+\(?/) {
bad_line("a require_once statement should look like a function call, ".
"without a space between the keyword and the bracket.", $_);
}
}
#Implement aging of the stack to prevent
#erroneous matches of seccond condition
if ($stackage > 0) {
$stackage = 0;
$stack = "";
}
if ($stack ne "") {
$stackage++;
}
}
exit($found_bad);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment