scripts: added tabs.pl - in my opinion it is bad to use tabs inside string constants. spaces or \t should be used instead.

This commit is contained in:
Daniel Marjamäki 2011-02-05 12:53:28 +01:00
parent 95e917b27f
commit 26f017e9c6
5 changed files with 55 additions and 20 deletions

35
scripts/tabs.pl Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/perl
# warn if there are tabs in string constants, it can have surprising effects.
# example usage:
# scripts/tabs.pl lib/checkstl.cpp
sub checkfile
{
my $filename = $_[0];
# parse file
open(FILE, $filename);
my @lines = <FILE>;
close(FILE);
# check comments..
my $linenr = 0;
foreach $line (@lines)
{
$linenr = $linenr + 1;
# is there a tab in a string
if ($line =~ /".*\t.*"/)
{
print "[$filename:$linenr] tab inside string constant\n";
}
}
}
foreach $filename (@ARGV)
{
checkfile($filename)
}