summaryrefslogtreecommitdiff
path: root/cesar/common/tools/check-filename
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/common/tools/check-filename')
-rwxr-xr-xcesar/common/tools/check-filename66
1 files changed, 66 insertions, 0 deletions
diff --git a/cesar/common/tools/check-filename b/cesar/common/tools/check-filename
new file mode 100755
index 0000000000..379bdac2fb
--- /dev/null
+++ b/cesar/common/tools/check-filename
@@ -0,0 +1,66 @@
+#!/usr/bin/perl
+#
+# Check that header guard defines and doxygen \file command are set
+# appropriately.
+#
+use strict;
+use warnings;
+use File::Find;
+
+-f 'common/tools/check-filename'
+ or die "should be run from base root\n";
+
+if ($ENV{'VIM'})
+{
+ print "nmap <buffer> <space> yy<cr>pkdd^df\"f\"D\n";
+ print "nmap <C-N> :copen<cr>j<space>\n";
+}
+
+sub check_file
+{
+ my $file = shift;
+ $file =~ s#^\./##;
+ my $cc = $file =~ /\.[ch]\{2\}$/;
+ my $filep;
+ ($filep = $file) =~ s#[/.]#_#g;
+ print "check $file\n";
+ open FILE, "<$file";
+ while (<FILE>)
+ {
+ chomp;
+ /^#(ifndef|define) (.*_h)$/ && $2 ne $filep
+ and print "$file:$.: should be \"#$1 $filep\"\n";
+ /^#(endif \/\*) (.*_h)( \*\/)$/ && $2 ne $filep
+ and print "$file:$.: should be \"#$1 $filep$3\"\n";
+ m#^((?:///| \*) \\file) +(.*)$# && $2 ne $file
+ and print "$file:$.: should be \"$1 $file\"\n";
+ }
+ close FILE;
+}
+
+my %exclude;
+@exclude{'ecos', 'obj', '.svn', 'html', 'test'} = ();
+
+@ARGV = ('.') if !@ARGV;
+
+for (@ARGV)
+{
+ if (-d $_)
+ {
+ find ({ no_chdir => 1, wanted => sub {
+ my $f = $_;
+ $f =~ s#.*/##;
+ exists $exclude{$f}
+ and $File::Find::prune = 1
+ or /\.[ch]+$/ and check_file $_;
+ } }, $_);
+ }
+ elsif (-f $_)
+ {
+ check_file ($_);
+ }
+ else
+ {
+ die "$_: not a directory, nor a file, what should I do?\n";
+ }
+}