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:
parent
95e917b27f
commit
26f017e9c6
|
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue