scripts: Added define.pl that warns if #define is used. Related with ticket #689

This commit is contained in:
Daniel Marjamäki 2011-01-10 22:24:02 +01:00
parent a5cf06f616
commit 98e77bda10
1 changed files with 35 additions and 0 deletions

35
scripts/define.pl Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/perl
# warn if there are #define in the code. it is often preferred with "const"
# usage:
# scripts/define.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 define?
if ($line =~ /^#define\s+[A-Za-z0-9_]+\s+[^\s]/)
{
print "[$filename:$linenr] found #define\n";
}
}
}
foreach $filename (@ARGV)
{
checkfile($filename)
}