My work's coding standard uses this bracket indentation:
some declaration
{
stuff = other stuff;
};
control structure, function, etc()
{
more stuff;
for(some amount of time)
{
do something;
}
more and more stuff;
}
I'm writing a perl script to detect incorrect indentation. Here's what I have in the body of a while(<some-file-handle>)
:
# $prev holds the previous line in the file
# $current holds the current in the file
if($prev =~ /^(\t*)[^;]+$/ and $current =~ /^(?<=!$1\t)[\{\}].+$/) {
print "$file @ line ${.}: Bracket indentation incorrect\n";
}
Here, I'm trying to match:
$prev
: A line not ended with a semi-colon, followed by...$current
: A line not having the number of leading tabs+1 of the previous line.
This doesn't seem to match anything, at the moment.